Stop Syncer

by Mario Hennenberger in category Other at 01/11/2018
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

 

Download
123 downloads
How to install
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 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();
        }

    }


}


Comments
0