Category Other  Published on 01/11/2018

Stop Syncer

Description

this is a VERY Simple algo, that syncs, TP, TSL and SL with all orders in the same Symbol, it's very useful if you have multiple entries (like you can see on my day trades here) and want to exit all of them via trail or with the same TP, or re-sync the Stoploss 

this is the first version of this Algo, it will be extended over time, please make sure you get the latest version from www.swingfish.trade/stop-syncer (its free forever)

quick example video https://youtu.be/v_pVJrUyS70

 


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 StopSyncer : Robot
    {

        [Parameter("SL", DefaultValue = 0)]
        public double SL { get; set; }

        [Parameter("TP", DefaultValue = 0)]
        public double TP { get; set; }

        [Parameter("Trail at", DefaultValue = false)]
        public bool TPT { get; set; }



        protected override void OnStart()
        {
            ModifyOrders();
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }


        private void ModifyOrders()
        {

            foreach (var pos in Positions)
            {
                if (pos.SymbolCode == Symbol.Code)
                {
                    if (SL < 0)
                    {
                        SL = 0;
                    }

                    if (TP < 0)
                    {
                        TP = 0;
                    }
                    if (TPT)
                    {
                        ModifyPositionAsync(pos, SL, TP, true);
                    }
                    else
                    {
                        ModifyPositionAsync(pos, SL, TP, false);
                    }
                }
            }
            Stop();
        }

    }


}




swingfish's avatar
swingfish

Joined on 25.06.2016

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: StopSyncer.algo
  • Rating: 0
  • Installs: 1875
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.