Why this code doesn't make a trade.

 

Recently I was watching a video on the channel René Balke on Youtube, and to be honest, my code makes no trades even though the code is the same... The author of the code is René Balke

#property version "1.00"
#include <Trade/Trade.mqh>

int handle;
input double lotSize = 0.1;
input ENUM_TIMEFRAMES Timefrime = PERIOD_H1;
datetime lastSignal;
CTrade trade;
int OnInit()
  {

   string name = "Market\\ArrowZigZag.ex5";
   handle = iCustom(_Symbol,Timefrime,name, 12,5,3);
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {


  }


void OnTick()
  {

   int  indexCurrent = -1, indexLast = -1;
   for(int i = 0; i < 10000; i++)
     {
      double indiRed[1];
      CopyBuffer(handle,1,i,1,indiRed);

      double indiGreen[1];
      CopyBuffer(handle,2,i,1,indiGreen); 


      if(indiGreen[0] > 0 || indiRed[0] > 0){
         if(indexCurrent < 0){
            indexCurrent = i;
           }
         else{
            indexLast = i;
            datetime time = iTime(_Symbol,PERIOD_CURRENT,i);
            if(time > lastSignal)
              {
               if(indiGreen[0] > 0){
                 Print(__FUNCTION__," > New Buy Signal at", time);
                 trade.PositionClose(_Symbol);
                 trade.Buy(lotSize);
                 }else if(indiRed[0] > 0)
                    {
                    Print(__FUNCTION__," > New Sell Signal at", time);
                    trade.PositionClose(_Symbol);
                    trade.Sell(lotSize);
                    }
              }
               lastSignal = time;
               break;
           }
        }

     }
   Comment("\nIndex Current: ", indexCurrent,
           "\nIndex Last: ", indexLast,
           "\nLast Signal: ", lastSignal);

}

 
BetterBuyColombia:

Recently I was watching a video on the channel René Balke on Youtube, and to be honest, my code makes no trades even though the code is the same... The author of the code is René Balke

i dont see how it could. your code is saying to open a trade after 1 has closed. but there is no bit of code to open the first.

Chat to the coder/seller of the Market indicator for help.

 
BetterBuyColombia:

Recently I was watching a video on the channel René Balke on Youtube, and to be honest, my code makes no trades even though the code is the same... The author of the code is René Balke

Do you have the ArrowZigZag.ex5 indicator installed?

Are you encountering any errors?

If so, please share them.