Custom Indicator / Redraw Arrows

iMK

Newborn Forex baby :)
Hi,

I have written an indicator that unfortunately does not automatically retighten the arrows on a new candle. But if I change the timeframe and jump back, he pulls them accordingly.

Who can help?

//Sektion: Eigenschaften
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

//Sektion: Globale Variablen
int i;
int limit;
int y;
int temp1;
double temp2;
double bar_high;
double bar_low;
double SIB0[];
double SIB1[];

//Sektion: Init-Prozess
int init() {
if (Bars < 0 + 25 || 0 == 0) limit = Bars - 25;
else limit = 0;
IndicatorBuffers(2);
SetIndexLabel(0,"Buy");
SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 3);
SetIndexLabel(1,"Sell");
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 3);
SetIndexArrow(0, 159);
SetIndexArrow(1, 159);
SetIndexBuffer(0, SIB0);
SetIndexBuffer(1, SIB1);
SetIndexDrawBegin(0, Bars - limit);
SetIndexDrawBegin(1, Bars - limit);
ArrayInitialize(SIB1, 0.0);
ArrayInitialize(SIB0, 0.0);
return (0);
}

//Sektion: Start
int start(){
SetIndexDrawBegin(0, Bars - limit);
SetIndexDrawBegin(1, Bars - limit);

int counted_bars = IndicatorCounted();

if (counted_bars < 0) return (-1);

limit = Bars - counted_bars;

for (i = 1; i < limit; i++){
temp2 = 0;
for (y = i; y < i + 10; y++) temp2 += (i + 10 - y) * (High[y] - Low[y]);
temp2 /= 55;
bar_high = High[iHighest(NULL, 0, MODE_HIGH, 25, i)];
bar_low = Low[iLowest(NULL, 0, MODE_LOW, 25, i)];
if (Close > bar_high - (bar_high - bar_low) * 17 / 100 && temp1 != 1) {
SIB1 = High + temp2 / 2;
if (Close > bar_high - (bar_high - bar_low) * 17 / 100 && temp1 != 1) temp1 = 1;
} else {
if (Close < bar_low + (bar_high - bar_low) * 17 / 100 && temp1 != -1) {
SIB0 = Low - temp2 / 2;
if (Close < bar_low + (bar_high - bar_low) * 17 / 100 && temp1 != -1) temp1 = -1;
}
}
}
return (0);
}
 
Last edited:
Top