Trtailing stop doesnt trail on demo but does on the tester

Sphelele Sphesihle Lubanyana
156
My ea has 2 sets conditions for both buy and sell, uses martingale, Break even and trailing stop. They all work as written on the tester but on the Demo, it doesnt even move. My conditions are: Buy and break even and if previous buy on the next candle open Buy using martingale then trail. For those rude experienced programmers I'd appreciate if you respond with humanity. Where could the problem be? I dont even know which parts of code should I  put but there
         //+------------------------------------------------------------------+
         //|          Crash                                                   |
         //+------------------------------------------------------------------+
         // Open buy order
         if(_Symbol == "Crash 1000 Index" || _Symbol == "Crash 500 Index")
           {
            if(Allow_Buy == true)
              {

               if(glSignal == SIGNAL_BUY && (// signal
                  )
                  &&
                  Positions.Buy(Magic_Number) == 0)
                 {
                  if(glSellTicket > 0)
                    {
                     Trade.Close(glSellTicket);
                    }

                  glBuyTicket = Trade.Buy(_Symbol,tradeSize);

                  if(glBuyTicket > 0)
                    {
                     double openPrice = PositionOpenPrice(glBuyTicket);

                     double buyStop = BuyStopLoss(_Symbol,Stop_Loss,openPrice);
                     if(buyStop > 0)
                        AdjustBelowStopLevel(_Symbol,buyStop);

                     double buyProfit = BuyTakeProfit(_Symbol,Take_Profit,openPrice);
                     if(buyProfit > 0)
                        AdjustAboveStopLevel(_Symbol,buyProfit);

                     if(buyStop > 0 || buyProfit > 0)
                        Trade.ModifyPosition(glBuyTicket,buyStop,buyProfit);

                     glSignal = SIGNAL_NONE;
                    }
                 }
              }
           }

         // Open sell order
         if(Allow_Sell == true)
           {
            if(glSignal == SIGNAL_SELL && (//signal
               )  && Positions.Sell(Magic_Number) == 0)
              {
               if(glBuyTicket > 0)
                 {
                  Trade.Close(glBuyTicket);
                 }

               glSellTicket = Trade.Sell(_Symbol,tradeSize);

               if(glSellTicket > 0)
                 {
                  double openPrice = PositionOpenPrice(glSellTicket);

                  double sellStop = SellStopLoss(_Symbol,Stop_Loss,openPrice);
                  if(sellStop > 0)
                     sellStop = AdjustAboveStopLevel(_Symbol,sellStop);

                  double sellProfit = SellTakeProfit(_Symbol,Take_Profit,openPrice);
                  if(sellProfit > 0)
                     sellProfit = AdjustBelowStopLevel(_Symbol,sellProfit);

                  if(sellStop > 0 || sellProfit > 0)
                     Trade.ModifyPosition(glSellTicket,sellStop,sellProfit);

                  glSignal = SIGNAL_NONE;
                 }
              }
           }

         //+------------------------------------------------------------------+
         //|          Boom                                                    |
         //+------------------------------------------------------------------+
         if(_Symbol == "Boom 1000 Index" || _Symbol == "Boom 500 Index")
           {
            if(Allow_Buy == true)
              {

               if(glSignal == SIGNAL_BUY && (//signal
               )

                     &&
                     Positions.Buy(Magic_Number) == 0)
              {
               if(glSellTicket > 0)
                    {
                     Trade.Close(glSellTicket);
                    }

                  glBuyTicket = Trade.Buy(_Symbol,tradeSize);

                  if(glBuyTicket > 0)
                    {
                     double openPrice = PositionOpenPrice(glBuyTicket);

                     double buyStop = BuyStopLoss(_Symbol,Stop_Loss,openPrice);
                     if(buyStop > 0)
                        AdjustBelowStopLevel(_Symbol,buyStop);

                     double buyProfit = BuyTakeProfit(_Symbol,Take_Profit,openPrice);
                     if(buyProfit > 0)
                        AdjustAboveStopLevel(_Symbol,buyProfit);

                     if(buyStop > 0 || buyProfit > 0)
                        Trade.ModifyPosition(glBuyTicket,buyStop,buyProfit);

                     glSignal = SIGNAL_NONE;
                    }
                 }
              }
           }

         // Open sell order
         if(Allow_Sell == true)
           {
            if(glSignal == SIGNAL_SELL  && (//signal
               )&&Positions.Sell(Magic_Number) == 0)
              {
               if(glBuyTicket > 0)
                 {
                  Trade.Close(glBuyTicket);
                 }

               glSellTicket = Trade.Sell(_Symbol,tradeSize);

               if(glSellTicket > 0)
                 {
                  double openPrice = PositionOpenPrice(glSellTicket);

                  double sellStop = SellStopLoss(_Symbol,Stop_Loss,openPrice);
                  if(sellStop > 0)
                     sellStop = AdjustAboveStopLevel(_Symbol,sellStop);

                  double sellProfit = SellTakeProfit(_Symbol,Take_Profit,openPrice);
                  if(sellProfit > 0)
                     sellProfit = AdjustBelowStopLevel(_Symbol,sellProfit);

                  if(sellStop > 0 || sellProfit > 0)
                     Trade.ModifyPosition(glSellTicket,sellStop,sellProfit);

                  glSignal = SIGNAL_NONE;
                 }
               // Order placement end
              }
           }
        }
      // Break even
      if(Use_Break_Even == true && numTickets > 0)
        {
         for(int i = 0; i < numTickets; i++)
           {
            Trail.BreakEven(tickets[i], Break_Even_Profit, Lock_Profit);
           }
        }
      //+------------------------------------------------------------------+
      //|          Stop loss insurance                                     |
      //+------------------------------------------------------------------+
      bool ord;
      double TotalLot=0;
      HistorySelect(TimeCurrent()-HistoryDaysLoadI*86400,TimeCurrent());
      for(int i=HistoryDealsTotal()-1; i>=0; i--)
        {
         ulong ticket=HistoryDealGetTicket(i);
         ord=HistoryDealSelect(ticket);

         double cake = HistoryDealGetDouble(ticket,DEAL_VOLUME);
         if(ord && HistoryDealGetString(ticket,DEAL_SYMBOL) == _Symbol
            && HistoryDealGetInteger(ticket,DEAL_MAGIC) == Magic_Number
            && HistoryDealGetInteger(ticket,DEAL_ENTRY) == DEAL_ENTRY_OUT)
           {
            if(HistoryDealGetDouble(ticket,DEAL_PROFIT) < 0 && cake < Multiply)
              {
               if(newBar == true && timerOn == true)
                 {
                  if(Allow_Buy == true)
                    {
                     if(_Symbol == "Crash 1000 Index" || _Symbol == "Crash 500 Index")
                        if(co[0]  && Positions.Buy(Magic_Number) == 0)
                          {
                           if(glSellTicket > 0)
                             {
                              Trade.Close(glSellTicket);
                             }
                           glBuyTicket = Trade.Buy(_Symbol,Multiply);
                           if(glBuyTicket > 0)
                             {
                              double openPrice = PositionOpenPrice(glBuyTicket);

                              double buyStop = BuyStopLoss(_Symbol,sl,openPrice);
                              if(buyStop > 0)
                                 AdjustBelowStopLevel(_Symbol,buyStop);

                              double buyProfit = BuyTakeProfit(_Symbol,NULL,openPrice);
                              if(buyProfit > 0)
                                 AdjustAboveStopLevel(_Symbol,sl);

                              if(buyStop > 0 || NULL > 0)
                                 Trade.ModifyPosition(glBuyTicket,buyStop,NULL);

                              glSignal = SIGNAL_NONE;

                             }
                          }
                    }
                  if(Allow_Sell == true)
                    {
                     if(_Symbol == "Boom 1000 Index" || _Symbol == "Boom 500 Index")
                       {
                        if(co[0] && Positions.Sell(Magic_Number) == 0)
                          {
                           if(glBuyTicket > 0)
                             {
                              Trade.Close(glBuyTicket);
                             }

                           glSellTicket = Trade.Sell(_Symbol,Multiply);

                           if(glSellTicket > 0)
                             {
                              double openPrice = PositionOpenPrice(glSellTicket);

                              double sellStop = SellStopLoss(_Symbol,sl,openPrice);
                              if(sellStop > 0)
                                 sellStop = AdjustAboveStopLevel(_Symbol,sellStop);

                              double sellProfit = NULL;
                              if(sellProfit > 0)
                                 sellProfit = AdjustBelowStopLevel(_Symbol,NULL);

                              if(sellStop > 0)
                                 Trade.ModifyPosition(glSellTicket,sellStop,NULL);

                              glSignal = SIGNAL_NONE;
                             }
                          }
                       }
                    }
                 }
               if(Use_Trailing_Stop == true && numTickets > 0)
                 {
                  for(int i = 0; i < numTickets; i++)
                    {
                     Trail.TrailingStop(tickets[0], Trailing_Stop, Minimum_Profit, Step);
                    }
                 }
              }
            else
              {
               break;
              }

           }
        }
     }
Revo Trades
644
Revo Trades  
Sphelele Sphesihle Lubanyana:
My ea has 2 sets conditions for both buy and sell, uses martingale, Break even and trailing stop. They all work as written on the tester but on the Demo, it doesnt even move. My conditions are: Buy and break even and if previous buy on the next candle open Buy using martingale then trail. For those rude experienced programmers I'd appreciate if you respond with humanity. Where could the problem be? I dont even know which parts of code should I  put but there

without more of the code i can only make suggestions where to look in the limited parts of the code that is posted, but things i notice is that there is no explanation of numTickets or maybe numTickets should be replaced with i ? Only other suggestion i can make is that maybe a break is in the wrong place?

Sphelele Sphesihle Lubanyana
156
Revo Trades #:

without more of the code i can only make suggestions where to look in the limited parts of the code that is posted, but things i notice is that there is no explanation of numTickets or maybe numTickets should be replaced with i ? Only other suggestion i can make is that maybe a break is in the wrong place?

numTickets has been explained at the beginning of the onTick and the break exits the buy on candle open Loop. Thanks for responding

Revo Trades
644
Revo Trades  
Sphelele Sphesihle Lubanyana #:

numTickets has been explained at the beginning of the onTick and the break exits the buy on candle open Loop. Thanks for responding

ok. if you want help you will need to post more of the code.

Revo Trades
644
Revo Trades  
you ask for help regarding the Trail stop, but you have not posted the Trail stop function. The cause of the issue will probably lie in that function.
Sphelele Sphesihle Lubanyana
156
Revo Trades #:
you ask for help regarding the Trail stop, but you have not posted the Trail stop function. The cause of the issue will probably lie in that function.

There is the function

Files:
Revo Trades
644
Revo Trades  
Sphelele Sphesihle Lubanyana #:

There is the function

sorry for late response, but it looks too advanced for me :) however i did notice that there is a couple variables named currentTake, lines 101 and 159, are commented out/hidden, but they are not in the rest of the code, maybe there is something in that?