Speed up a indicator- I_XO_A_H

 

i am backtesting a EA -"scalp_net"

and it run very slow, since it use indicator I_XO_A_H, i want to ask how to let indicator not re-calculate previous bar in the ea ? (except the bar[0] )

thanks

below is the code of indicator I_XO_A_H

//+------------------------------------------------------------------+

//| Amir.mq4 |

//| Copyright ?2005, Amir |

//| |

//+------------------------------------------------------------------+

#property copyright "Copyright ?2005, Amir"

#property link ""

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Green

#property indicator_color2 Red

//---- input parameters

extern int BoxSize=15;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

int Cur=0;

int KirUp=0;

int KirDn=0;

int kr=0;

int no=0;

double valueh=0;

double valuel=0;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexLabel(0,"XOUP");

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexLabel(1,"XODOWN");

IndicatorShortName("I-XO-A-H");

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//---- TODO: add your code here

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int CurrentBar;

double Hi,Lo,Curb;

int counted_bars=IndicatorCounted();

//---- TODO: add your code here

//----Calculation---------------------------

for(int i=0;i<=Bars;i++)

{

CurrentBar = Bars-i;

if (Cur<1)

{

Hi=Close[CurrentBar];

Lo=Close[CurrentBar];

Cur=1;

}

Curb=Close[CurrentBar];

if (Curb>(Hi+BoxSize*Point))

{

Cur+=1;

Hi=Curb;

Lo=Curb-BoxSize*Point;

KirUp=1;

KirDn=0;

kr+=1;

no=0;

}

if (Curb<(Lo-BoxSize*Point))

{

Cur+=1;

Lo=Curb;

Hi=Curb+BoxSize*Point;

KirUp=0;

KirDn=1;

no+=1;

kr=0;

}

valueh=kr;

valuel=0-no;

ExtMapBuffer1[CurrentBar]=valueh;

ExtMapBuffer2[CurrentBar]=valuel;

}

//----

return(0);

}

//+------------------------------------------------------------------+

 

btw, do i_XO_A_H essential to re-calculate previous bar?

 

Speed up a indicator- I_XO_A_H

Here you go. Interesting Indicator. A setting of around 20 picks up the current 1hr eurusd trend quite nicely.

Indicator now has an extra parameter where you set the maximum number of indicator bars to display.

Cheers, Jim

Files:
amir.mq4  3 kb
 

maybe i set too many bar allowed in the chart, so it cause slow, does it?

 

Благодарность

Jims Shed,спасибо за индикатор Amir , я из России и очень вам благодарен за этот индикатор я его использую на паре GBP/USD на 4H графике с настройкой BOX SIZE-60