auto close all position after profit free

by m.kepka.90 in category Other at 23/11/2021
Description
If you want to close all positions after profit, this is for you. All you need to do is rewrite how much money you need before automating your positions. Cbot closes all positions, including pending orders!
Warning! Executing the following cBot may result in loss of funds. Use it at your own risk.
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgo
´╗┐using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

    public class closeallpositionafterprofit : Robot
    {
        protected override void OnTick()
        {
            if (Account.Equity - Account.Balance > 10)
            {
                foreach (var position in Account.Positions)
                {
                    Trade.Close(position);

                }

                foreach (var order in PendingOrders)
                {
                    CancelPendingOrder(order);
                }
            }

        }
    }
}



Comments

kanejoyce885 - November 24, 2021 @ 06:37

I loved reading your article and found it to be really useful. If you have any extra time, you are welcome to join me in playing smash karts

0