Category Other  Published on 21/04/2023

Break even Trailling stop - Template

Description

FINALLY.!!!!!!! I have successfully been able to code this. It has no sell or buy algorithm or strategy. THIS  IS A TEMPLATE YOU CAN PUT YOUR STRATEGY IN ONBAR, OR WHEREVER. LET IT DO ITS MAGIC. COMMENT PLEASE Its my first post On CBOTS. I  give it for FREE FREE FREE 

KINDLY Donate any amount my paypal - Davidmwabuka@gmail.com

If you have  a strategy you want me to code it for you,  EMAIL ME, check me on whatsapp, phone number is on top of this cbot section. 


// copyright: Lawrence Mujari(David MWABUKA)
//
// Break even with trailling
///
// Donate any amount my paypal - Davidmwabuka@gmail.com
///
//// If you want me to code your strategy check me on whatsapp +255717441440 Very affordable price


using System;
using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class BreakevenTrailingRobot : Robot
    {
        [Parameter("Breakeven Pips", DefaultValue = 10)]
        public int BreakevenPips { get; set; }

        [Parameter("Trailing Stop Pips", DefaultValue = 10)]
        public int TrailingStopPips { get; set; }

        private Position position;

        protected override void OnStart()
        {
            position = null;
        }

        protected override void OnTick()
        {
            if (position == null)
            {
                // If we don't have a position, check if we should open one
                if (IsBuySignal())
                {
                    var volumeInUnits = Symbol.QuantityToVolume(1);
                    var result = ExecuteMarketOrder(TradeType.Buy, Symbol, volumeInUnits, "Buy", null, null);
                    position = result.Position;
                }
                else if (IsSellSignal())
                {
                    var volumeInUnits = Symbol.QuantityToVolume(1);
                    var result = ExecuteMarketOrder(TradeType.Sell, Symbol, volumeInUnits, "Sell", null, null);
                    position = result.Position;
                }
            }
            else
            {
                // If we have a position, check if we need to adjust the stop loss
                if (position.TradeType == TradeType.Buy)
                {
                    var stopLossPrice = (byte)Math.Max(position.EntryPrice + Symbol.PipSize * BreakevenPips, position.StopLoss ?? 0);
                    var takeProfitPrice = position.EntryPrice + Symbol.PipSize * TrailingStopPips;
                    var result = ModifyPosition(position, stopLossPrice, takeProfitPrice, false);
                    if (result.IsSuccessful)
                    {
                        position = result.Position;
                    }
                }
                else if (position.TradeType == TradeType.Sell)
                {
                    var stopLossPrice = (byte)Math.Min(position.EntryPrice - Symbol.PipSize * BreakevenPips, position.StopLoss ?? 0);
                    var takeProfitPrice = position.EntryPrice - Symbol.PipSize * TrailingStopPips;
                    var result = ModifyPosition(position, stopLossPrice, takeProfitPrice, false);
                    if (result.IsSuccessful)
                    {
                        position = result.Position;
                    }
                }
            }
        }

        private bool IsBuySignal()
        {
            // Check if the current bar is the first bar of the day
            if (MarketSeries.OpenTime.Last(1).Day != MarketSeries.OpenTime.LastValue.Day)
            {
                return true;
            }
            return false;
        }

        private bool IsSellSignal()
        {
            // Insert your sell signal logic here
            return false;
        }
    }
}


DA
davidmwabuka

Joined on 07.03.2023

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: BREAKevernTRAIILLING WORKING (template).algo
  • Rating: 0
  • Installs: 783
  • Modified: 21/04/2023 07:52
Comments
Log in to add a comment.
DA
dajiba1021 · 1 year ago

I felt very happy while reading this site. This was really very informative site for me. I really liked it. This was really a cordial post. Thanks a lot!.샌즈카지

ZA
zaffarkhatri22 · 1 year ago

very nice publish, i certainly love this website, carry on ithow to become a credit card processing agent

VI
visapoy421 · 1 year ago

I have learned some points through your website post. One other stuff I would like to state is that there are plenty of games out there designed particularly for toddler age little ones. They include things like pattern identification, colors, dogs, and patterns. These often focus on familiarization in lieu of memorization. This keeps little kids engaged without sensing like they are studying. Thankshow to sell credit card processing

HE
heciraf296 · 1 year ago

vI like the way you conduct your posts. Hmm… v starting a credit card processing company

AR
arhamabdul429 · 1 year ago

glad to be one of the visitors on this amazing internet site : D.Packers and Movers Delhi