When you post code please use the CODE button (Alt-S)!
int breakCandle = 0; ⋮ if ( bidPrice > High && breakCandle <= 0 ){ return "Long"; breakCandle = 1; } else if (bidPrice < Low && breakCandle >= 0 ){ return "Short"; breakCandle = -1;Your variable, breakCandle, is never set, always zero..
Your variable, breakCandle, is never set, always zero..
I'm not pretty sure what you mean, but i initialized it first as zero at the beginning then lets say an upward candle is happening so the price will be more than High and because that " breakCandle " is zero then a position will be opened so if it goes the same direction because breakCandle is now " 1 " no extra position should open till it goes down....
anyway that iTime function will prevent it to open .... any idea?
Your posted code never changes it. It is still zero. Your posted code doesn't open positions.
That is the only time. Your posted code never changes it.
Your posted code never changes it. It is still zero. Your posted code doesn't open positions.
When in doubt, think!
Your posted code never changes the variable. | if ( bidPrice > High && breakCandle <= 0 ){ return "Long"; breakCandle = 1; } else if (bidPrice < Low && breakCandle >= 0 ){ return "Short"; breakCandle = -1; |
This will. | if ( bidPrice > High && breakCandle <= 0 ){ breakCandle = 1; return "Long"; } else if (bidPrice < Low && breakCandle >= 0 ){ breakCandle = -1; return "Short"; |
Damn man it actually worked ! omg now i see what you mean saying " this part will always be zero " you'd been trying to make me realized my mistake by addressing it ... you are genius.... thanks man.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello there
I'm trying to work around iHigh and iLow functions but when i set the shift argument on " 1 " it doesn't execute the program but it sounds fine when the shift is set on " 2 " . Here is my following code....
it's just a simple code whenever the price passes the High of the candle it opens Buy and vice versa, one more thing when i remove that iTime function it works fine but the problem is it opens many positions by every Tick even though i put that expression in if statements ( breakCandle )...
I will appreciate if anyone gives me any solutions....