What about when High[2] - Low[2] < High[1] - Low[1] ? in this case bar 1 is larger than bar 2
Shouldn't this . . .
if(Low[i-2] > Low[i-1] && High[i-2] < High[i-1])
be this . . .
if(Low[i+1] > Low[i] && High[i+1] < High[i])
RaptorUK:
What about when High[2] - Low[2] < High[1] - Low[1] ? in this case bar 1 is larger than bar 2
Shouldn't this . . .
be this . . .
yes, that was a logical error on my part. but even after i changed that line, mt4 still freezes, so there must be a greater problem, than my own stupidity...
Show your code . . .
Add to the very first line:
#property indicator_chart_window
Move i-- to the next outer block:
while(i >= 0) { if(Low[i-2] > Low[i-1] && High[i-2] < High[i-1]) { B2[i]=Low[i]; } i--; }
if(Low[i-2] > Low[i-1] && High[i-2] < High[i-1])
i-n is the future. If you want to highlight the engulfing bar, your test should be:if(Low[i+2] > Low[i+1] && High[i+2] < High[i+1])
int counted = indicatorCounted(); if (counted < 2) counted = 2; // Looking back 2 bars for (int i = Bars - 1 - counted; i >= 0; i--){
Arrow on i, testing candle[i+1] and candle[i+2]- If you want your test to be "place arrow when bar is larger" and place it on the larger bar:
int counted = indicatorCounted(); if (counted < 1) counted = 1; // Looking back 1 bar for (int i = Bars - 1 - counted; i >= 0; i--){ double range1 = High[i+1] - Low[i+1], range0 = High[i ] - Low[i ]; if (range0 > range1) B2[i] = Low[i]; else B2[i] = EMPTY_VALUE; // Or in init() SetIndexEmptyValue(0,0) }
You also have to set the buffer to NOT show arrows when the condition is not true. Either explicitly set it to empty or let it default to zero and use SetIndexEmpty.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hi
so the title says it all. i would like an arrow to be placed every time this happens: Low[2] > Low[1] && High[2] < High[1]
this is what i came up with, but it only causes mt4 to crash. any help would be appreciated! thank you!
#property indicator_buffers 1 #property indicator_color1 White
extern int Period = 24; double B2[];