Modifying free cBots

Created at 16 Oct 2018, 04:27
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
WI

willd7781

Joined 18.09.2018

Modifying free cBots
16 Oct 2018, 04:27


I downloaded a cBot from the free cBots on cTrader. This downloaded as an Algo file, however when I tried to edit this file in cTrader, upon editing the source code and trying to "build" it, it said that I couldn't as the location of the file didn’t exist. I then attempted to copy and paste the code into a new file, this gave several messages based around the general error message that the assembly or directive is missing. The cBot is using the GannHighLow method and private variables such as GHneu, GannHighLowwws1, and several other private variables aren't working. Can anyone explain how, assembles and directives for and

using System;
using cAlgo.API;
using cAlgo.API.Requests;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

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

        private GHneu _GHneuIndicator;
        private GHneu1 _GHneu1Indicator;

        private GannHighLowwws _gannHighLowwwsIndicator;
        private GannHighLowtri _gannHighLowtriIndicator;
        private GannHighLowWeight _gannHighLowWeightIndicator;

        private GannHighLowwws1 _gannHighLowwws1Indicator;
        private GannHighLowtri1 _gannHighLowtri1Indicator;
        private GannHighLowWeight1 _gannHighLowWeight1Indicator;

        private GannHighLowsmatri _gannHighLowsmatriIndicator;
        private GannHighLowsmatri1 _gannHighLowsmatri1Indicator;

        private GannHighLowsmaweight _gannHighLowsmaweightIndicator;
        private GannHighLowsmaweight1 _gannHighLowsmaweight1Indicator;

        private GHExp _GHExpIndicator;
        private GHExp1 _GHExp1Indicator;

        private GannHighLowTS _gannHighLowTSIndicator;



        private MovingAverage MA1;
        private MovingAverage MA2;
        private MovingAverage MA3;
        private MovingAverage MA4;

        private MovingAverage MA5;
        private MovingAverage MA6;
        private MovingAverage MA7;


        private MovingAverage MA10;
        private MovingAverage MA11;

        private MovingAverage MA12;
        private MovingAverage MA13;

        private MovingAverage MA20;
        private MovingAverage MA21;

        private MovingAverage MA30;
        private MovingAverage MA31;


        private Position _position;
        private int k;



        [Parameter("Period-Buy", DefaultValue = 67)]
        public int Period { get; set; }

        [Parameter("Period1-Buy", DefaultValue = 41)]
        public int Period1 { get; set; }

        [Parameter("Period2-Sell", DefaultValue = 57)]
        public int Period2 { get; set; }

        [Parameter("Period3-Sell", DefaultValue = 27)]
        public int Period3 { get; set; }

        [Parameter("Period4-Sell", DefaultValue = 30)]
        public int Period4 { get; set; }

        [Parameter("Period5-Sell", DefaultValue = 31)]
        public int Period5 { get; set; }

        [Parameter("Period6-Buy", DefaultValue = 19)]
        public int Period6 { get; set; }

        [Parameter("Period7-Sell", DefaultValue = 21)]
        public int Period7 { get; set; }


        [Parameter("Period8-Buy", DefaultValue = 55)]
        public int Period8 { get; set; }


        [Parameter("Period9-Buy", DefaultValue = 84)]
        public int Period9 { get; set; }

        [Parameter("Period10-Buy", DefaultValue = 33)]
        public int Period10 { get; set; }


        [Parameter("Period11-Sell", DefaultValue = 22)]
        public int Period11 { get; set; }

        [Parameter("Period12-Buy", DefaultValue = 21)]
        public int Period12 { get; set; }


        [Parameter("Period13-Sell", DefaultValue = 35)]
        public int Period13 { get; set; }

        [Parameter("Period14-Buy", DefaultValue = 21)]
        public int Period14 { get; set; }


        [Parameter("Period15-Sell", DefaultValue = 26)]
        public int Period15 { get; set; }

        [Parameter("Period16-Sell", DefaultValue = 25)]
        public int Period16 { get; set; }





        [Parameter("Volume-Buy", DefaultValue = 10000)]
        public int Volume { get; set; }

        [Parameter("Volume1-Sell", DefaultValue = 10000)]
        public int Volume1 { get; set; }




        [Parameter("StopLoss-Buy", DefaultValue = 64)]
        public int StopLoss { get; set; }

        [Parameter("StopLoss1-Sell", DefaultValue = 55)]
        public int StopLoss1 { get; set; }

        [Parameter("TakeProfit-Buy", DefaultValue = 156)]
        public int TakeProfit { get; set; }

        [Parameter("TakeProfit1-Sell", DefaultValue = 198)]
        public int TakeProfit1 { get; set; }


        [Parameter("MA_period1-Buy", DefaultValue = 52)]
        public int MA_period1 { get; set; }



        [Parameter("MA_period2-Buy", DefaultValue = 41)]
        public int MA_period2 { get; set; }



        [Parameter("MA_period3-Sell", DefaultValue = 63)]
        public int MA_period3 { get; set; }



        [Parameter("MA_period4-Sell", DefaultValue = 49)]
        public int MA_period4 { get; set; }



        [Parameter("MA_period5-Sell", DefaultValue = 65)]
        public int MA_period5 { get; set; }



        [Parameter("MA_period6-Sell", DefaultValue = 44)]
        public int MA_period6 { get; set; }



        [Parameter("MA_period7-Buy", DefaultValue = 27)]
        public int MA_period7 { get; set; }



        [Parameter("MA_period10-Buy", DefaultValue = 70)]
        public int MA_period10 { get; set; }



        [Parameter("MA_period11-Buy", DefaultValue = 51)]
        public int MA_period11 { get; set; }



        [Parameter("MA_period12-Sell", DefaultValue = 46)]
        public int MA_period12 { get; set; }



        [Parameter("MA_period13-Sell", DefaultValue = 38)]
        public int MA_period13 { get; set; }



        [Parameter("MA_period20-Buy", DefaultValue = 65)]
        public int MA_period20 { get; set; }



        [Parameter("MA_period21-Buy", DefaultValue = 50)]
        public int MA_period21 { get; set; }



        [Parameter("MA_period30-Sell", DefaultValue = 69)]
        public int MA_period30 { get; set; }



        [Parameter("MA_period31-Sell", DefaultValue = 48)]
        public int MA_period31 { get; set; }




        [Parameter("Tral_Start-Buy", DefaultValue = 165)]
        public int Tral_Start { get; set; }

        [Parameter("Tral_Start1-Sell", DefaultValue = 167)]
        public int Tral_Start1 { get; set; }

        [Parameter("Tral_Stop-Buy", DefaultValue = 129)]
        public int Tral_Stop { get; set; }

        [Parameter("Tral_Stop1-Sell", DefaultValue = 107)]
        public int Tral_Stop1 { get; set; }



        [Parameter("MFI_period-Buy", DefaultValue = 26)]
        public int MFI_period { get; set; }

        [Parameter("MFI_period1-Sell", DefaultValue = 16)]
        public int MFI_period1 { get; set; }

        [Parameter("MFI_period2-Sell", DefaultValue = 12)]
        public int MFI_period2 { get; set; }




        [Parameter("MO_period-Sell", DefaultValue = 26)]
        public int MO_period { get; set; }



        [Parameter("MO_period1-Buy", DefaultValue = 13)]
        public int MO_period1 { get; set; }



        [Parameter("MO_period2-Sell", DefaultValue = 16)]
        public int MO_period2 { get; set; }




        [Parameter("MO_period3-Buy", DefaultValue = 33)]
        public int MO_period3 { get; set; }



        private ChaikinMoneyFlow MFI;
        private ChaikinMoneyFlow MFI1;

        private MoneyFlowIndex MFI3;


        private VerticalHorizontalFilter MO;
        private VerticalHorizontalFilter MO1;

        private MomentumOscillator MO3;
        private MomentumOscillator MO4;




        protected override void OnStart()
        {

            _GHneuIndicator = Indicators.GetIndicator<GHneu>(Period, Period1);

            _GHneu1Indicator = Indicators.GetIndicator<GHneu1>(Period2, Period3);


            _gannHighLowwwsIndicator = Indicators.GetIndicator<GannHighLowwws>(Period4);

            _gannHighLowtriIndicator = Indicators.GetIndicator<GannHighLowtri>(Period5);

            _gannHighLowWeightIndicator = Indicators.GetIndicator<GannHighLowWeight>(Period6);

            _gannHighLowwws1Indicator = Indicators.GetIndicator<GannHighLowwws1>(Period7);

            _gannHighLowtri1Indicator = Indicators.GetIndicator<GannHighLowtri1>(Period8);

            _gannHighLowWeight1Indicator = Indicators.GetIndicator<GannHighLowWeight1>(Period9);

            _gannHighLowsmatriIndicator = Indicators.GetIndicator<GannHighLowsmatri>(Period10);
            _gannHighLowsmatri1Indicator = Indicators.GetIndicator<GannHighLowsmatri1>(Period11);

            _gannHighLowsmaweightIndicator = Indicators.GetIndicator<GannHighLowsmaweight>(Period12);
            _gannHighLowsmaweight1Indicator = Indicators.GetIndicator<GannHighLowsmaweight1>(Period13);

            _GHExpIndicator = Indicators.GetIndicator<GHExp>(Period14);
            _GHExp1Indicator = Indicators.GetIndicator<GHExp1>(Period15);

            _gannHighLowTSIndicator = Indicators.GetIndicator<GannHighLowTS>(Period16);








            MFI = Indicators.ChaikinMoneyFlow(MFI_period);
            MFI1 = Indicators.ChaikinMoneyFlow(MFI_period1);

            MFI3 = Indicators.MoneyFlowIndex(MFI_period2);


            MO = Indicators.VerticalHorizontalFilter(MarketSeries.Close, MO_period);
            MO1 = Indicators.VerticalHorizontalFilter(MarketSeries.Close, MO_period1);

            MO3 = Indicators.MomentumOscillator(MarketSeries.Close, MO_period2);
            MO4 = Indicators.MomentumOscillator(MarketSeries.Close, MO_period3);


            MA1 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period1);
            MA2 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period2);
            MA3 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period3);
            MA4 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period4);

            MA5 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period5);
            MA6 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period6);
            MA7 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period7);


            MA10 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period10);
            MA11 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period11);

            MA12 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period12);
            MA13 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period13);

            MA20 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period20);
            MA21 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period21);

            MA30 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period30);
            MA31 = Indicators.SimpleMovingAverage(MarketSeries.Close, MA_period31);




        }



        protected override void OnPositionOpened(Position openedPosition)
        {
            _position = openedPosition;

            if (_position.TradeType == TradeType.Buy)
            {
                Trade.ModifyPosition(openedPosition, _position.EntryPrice - StopLoss * Symbol.PipSize, _position.EntryPrice + TakeProfit * Symbol.PipSize);
                k = 1;
            }

            if (_position.TradeType == TradeType.Sell)
            {
                Trade.ModifyPosition(openedPosition, _position.EntryPrice + StopLoss1 * Symbol.PipSize, _position.EntryPrice - TakeProfit1 * Symbol.PipSize);
                k = 1;
            }
        }




        protected override void OnBar()
        {

            double Bid = Symbol.Bid;
            double Ask = Symbol.Ask;
            double Point = Symbol.PointSize;


            double MO2 = MO.Result[MO.Result.Count - 2];


            double MFI2 = MFI.Result[MFI.Result.Count - 2];










            if (Trade.IsExecuting)
                return;


            if (_GHneuIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO1.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_GHneuIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA10.Result.IsRising() && MA11.Result.IsFalling() && MO1.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.05 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_GHneuIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA20.Result.IsRising() && MA21.Result.IsFalling() && MO1.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.05 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_GHneuIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MA7.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.3 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }



            if (_GHneuIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_GHneuIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA10.Result.IsRising() && MA11.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }



            if (_gannHighLowWeightIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO1.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }



            if (_gannHighLowWeight1Indicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_gannHighLowWeight1Indicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA20.Result.IsRising() && MA21.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.1 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }



            if (_gannHighLowtri1Indicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }



            if (_gannHighLowtri1Indicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MFI2 > -0.05 && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_gannHighLowsmatriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }



            if (_gannHighLowsmatriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_gannHighLowsmatriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA10.Result.IsRising() && MA11.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }


            if (_gannHighLowsmatriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MA7.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_gannHighLowsmatriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA20.Result.IsRising() && MA21.Result.IsFalling() && MA7.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.15 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_gannHighLowsmatriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MA7.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_gannHighLowsmatriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA20.Result.IsRising() && MA21.Result.IsFalling() && MA7.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_gannHighLowsmaweightIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MFI2 > 0.0 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }



            if (_gannHighLowsmaweightIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_gannHighLowsmaweightIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA20.Result.IsRising() && MA21.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;

            }

            if (_GHExpIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA1.Result.IsRising() && MA2.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }

            if (_GHExpIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA10.Result.IsRising() && MA11.Result.IsFalling() && MO4.Result.IsRising() && MFI.Result.IsRising() && MO2 > 0.35 && k == 0)
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
                Print("Trade Buy was successfully open");
                k = 1;


            }



























            if (_GHneu1Indicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA3.Result.IsFalling() && MA4.Result.IsRising() && MO3.Result.IsFalling() && MFI3.Result.IsFalling() && MFI2 < 0.0 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_GHneu1Indicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA30.Result.IsFalling() && MA31.Result.IsRising() && MO3.Result.IsFalling() && MFI3.Result.IsFalling() && MO2 < 0.2 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_GHneu1Indicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA30.Result.IsFalling() && MA31.Result.IsRising() && MO.Result.IsFalling() && MFI1.Result.IsFalling() && MFI2 < -0.05 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }



            if (_GHneu1Indicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA3.Result.IsFalling() && MA4.Result.IsRising() && MO3.Result.IsFalling() && MFI3.Result.IsFalling() && MO2 < 0.2 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_gannHighLowwwsIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA3.Result.IsFalling() && MA4.Result.IsRising() && MO.Result.IsRising() && MFI1.Result.IsFalling() && MFI2 < 0.0 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_gannHighLowwwsIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA12.Result.IsFalling() && MA13.Result.IsRising() && MO.Result.IsRising() && MFI1.Result.IsFalling() && MFI2 < -0.05 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }





            if (_gannHighLowtriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA3.Result.IsFalling() && MA4.Result.IsRising() && MO.Result.IsRising() && MFI1.Result.IsFalling() && MFI2 < 0.0 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_gannHighLowtriIndicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA30.Result.IsFalling() && MA31.Result.IsRising() && MO.Result.IsRising() && MFI1.Result.IsFalling() && MFI2 < 0.0 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }





            if (_gannHighLowwws1Indicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO3.Result.IsFalling() && MFI1.Result.IsFalling() && MFI2 < 0.0 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }



            if (_gannHighLowwws1Indicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO.Result.IsFalling() && MFI1.Result.IsFalling() && MFI2 < 0.0 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }






            if (_gannHighLowsmatri1Indicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO3.Result.IsFalling() && MFI1.Result.IsFalling() && MFI2 < -0.05 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_gannHighLowsmatri1Indicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO.Result.IsFalling() && MFI1.Result.IsFalling() && MFI2 < 0.0 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_gannHighLowsmatri1Indicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO.Result.IsFalling() && MFI1.Result.IsFalling() && MO2 < 0.2 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }



            if (_gannHighLowsmaweight1Indicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO3.Result.IsFalling() && MFI1.Result.IsFalling() && MFI2 < -0.05 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_GHExp1Indicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO.Result.IsFalling() && MFI1.Result.IsFalling() && MO2 < 0.25 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_GHExp1Indicator.Result.HasCrossedBelow(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO3.Result.IsFalling() && MFI1.Result.IsFalling() && MFI2 < 0.0 && MO2 < 0.25 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

            if (_gannHighLowTSIndicator.Result.HasCrossedAbove(MarketSeries.Open, 1) && MA5.Result.IsFalling() && MA6.Result.IsFalling() && MO3.Result.IsFalling() && MFI1.Result.IsFalling() && MFI2 < -0.1 && MO2 < 0.2 && k == 0)
            {
                Trade.CreateSellMarketOrder(Symbol, Volume1);
                Print("Trade Sell was successfully open");
                k = 1;


            }

































            foreach (var position in Account.Positions)
            {




                if (position.SymbolCode == Symbol.Code)
                {

                    if (position.TradeType == TradeType.Buy)
                    {
                        if (Bid - position.EntryPrice >= Tral_Start * Point)
                            if (Bid - Tral_Stop * Point >= position.StopLoss)
                                Trade.ModifyPosition(position, Bid - Tral_Stop * Point, position.TakeProfit);
                    }

                    if (position.TradeType == TradeType.Sell)
                    {
                        if (position.EntryPrice - Ask >= Tral_Start1 * Point)
                            if (Ask + Tral_Stop1 * Point <= position.StopLoss)
                                Trade.ModifyPosition(position, Ask + Tral_Stop1 * Point, position.TakeProfit);
                    }
                }
            }

        }








        protected override void OnPositionClosed(Position pos)
        {
            k = 0;

        }

        protected override void OnStop()
        {
            Print("Successful day!");
        }




    }
}

why the code bellow doesn’t work. 


@willd7781
Replies

PanagiotisCharalampous
16 Oct 2018, 10:04

Hi willd7781,

Can you please provide the link to the cBot?

Best Regards,

Panagiotis


@PanagiotisCharalampous

cfuorvito@gmail.com
21 Feb 2023, 12:16

RE:

PanagiotisCharalampous said:

Hi willd7781,

Can you please provide the link to the cBot?

Best Regards,

Panagiotis

Bit of an old thread but I believe this is the link to the algo willd7781 presented.

I also cannot get this algo to work properly.  The sl and tp work well in back tests but in live trading are not accurate.


@cfuorvito@gmail.com