From int start (which returns value) to be void OnTick (which don't returns values)

Abdelrahman Abdelgaied Mahmoud  

I have an old code MQL4 indicator, I want to use it to create EA but in new MQL4 language.

How to change this part of the code from int start() (which returns value) to be void OnTick (which don't returns values) ?


int start()
{
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
ExtMapBuffer1[pos]=iMA(Symbol(),0,ma_1,0,method,price,pos);
ExtMapBuffer2[pos]=iMA(Symbol(),0,ma_2,0,method,price,pos);
MACD_Map[pos]=ExtMapBuffer1[pos]-ExtMapBuffer2[pos];
pos--;
}
// signal lines
pos=Bars-ExtCountedBars-1;

while(pos>=0)
{
SignalMap[pos]= iMAOnArray(MACD_Map,0,signal,0,s_method,pos);
SignalLine[pos]= NormalizeDouble(ExtMapBuffer2[pos]+SignalMap[pos],Digits);

SignalMap2[pos]= iMAOnArray(MACD_Map,0,signal2,0,s_method2,pos);
SignalLine2[pos]= NormalizeDouble(SignalMap2[pos]+ExtMapBuffer2[pos],Digits);
pos--;
}

return(0);
}
Abdelrahman Abdelgaied Mahmoud  
William Roeder:

You don't! OnTick is for EAs. Your code is an indicator.

thank you for clarifying, I understand that OnTick is for EA, Mainly I want to create EA from this indicator which coded by the old event handlers! so how can i use this indicator to build my EA ?

this indicator draw a custom 4 array moving averages , I want to create EA conditions related to this indicator to open orders !

i know how to code the conditions to open orders ! but i can't take any data from that code , that's why the EA is not working !
Reason: