OnTick only appears to happen once.

 

I was watching a video on how to make an EA, and noticed very far in that the on tick function is only being used once or only plays one line of it per tick

full code and screenshots attached although not much works.  important part is

OnTick(

trade.Buy;

trade.Sell;

trade.Buy;

)

#include <Trade/Trade.mqh>
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"


int handleHeikenAshi;

CTrade trade;

int barsTotal;

int posTicket;


int OnInit()
  {
posTicket = 0

  barsTotal = iBars(_Symbol,PERIOD_CURRENT);

  handleHeikenAshi = iCustom(_Symbol,PERIOD_CURRENT,"Examples\\Heiken_Ashi.ex5"); //try changing ex5 to mq5
  
  
   return(INIT_SUCCEEDED);
   
  }
  
void OnDeinit(const int reason)
  {
  
  }
  

  
void OnTick()
  {
trade.Buy(0.01);
trade.Sell(0.01);
trade.Buy(0.01);   
   double haOpen[], haClose[],haHigh[],haLow[];
   
   CopyBuffer(handleHeikenAshi,0,0,1,haOpen);//handle...=callindicator,0=whitch indicator, 1=whitch candle, haOpen=?
   CopyBuffer(handleHeikenAshi,3,0,1,haClose);
   CopyBuffer(handleHeikenAshi,0,1,1,haOpen);
   CopyBuffer(handleHeikenAshi,1,1,1,haHigh);
   CopyBuffer(handleHeikenAshi,2,1,1,haLow);
   CopyBuffer(handleHeikenAshi,3,1,1,haClose);
   
   if(haOpen[0] < haClose[0]){
   //if(posTicket = 2){close order}
   if(haLow[0] <= haOpen[1]){
   }else
      {
       if(posTicket != 1){
       trade.Buy(0.01);
       posTicket = 1;
       }
      }
   
   }else
      {
       if(haClose[0] < haOpen[0]){
       //if(posTicket = 1){close order} 
       if(haHigh[0]  > haOpen[1]){
       }else
          {
          if(posTicket != 2){
             trade.Sell(0.01);
             posTicket = 2;
            }
          }
       }
      } 
 
 
   
   Comment("\nHA Open:  ",DoubleToString(haOpen[0],_Digits));
   
   
   
   
  }
 

It's weekend!

Run your EA in the debugger (in the editor) with hist. quotes Ctrl+F5 but set the times etc in Tools => Options: