double high1 = iHigh(_Symbol,_Period,1); double high3 = iHigh(_Symbol,_Period,3); double low1 = iLow(_Symbol,_Period,1); double low3 = iLow(_Symbol,_Period,3); bool barTriangle = (high1 < high3 && low1 > low3);
Objects are only drawn if barTriangle is true.
It makes no sense that you use values from bars 1 and 3 for the condition in a loop that uses i.
string signal1 = "signal1 "+TimeToStr(time); string signal2 = "signal2 "+TimeToStr(time); double tBHigh1 = iHigh(NULL,PERIOD_M30,i); double tBHigh3 = iHigh(NULL,PERIOD_M30,i+bc3); // Here i use i (which is 1 then +bc3 which is 3 so it should always count 3 bars back from 1) double tBLow1 = iLow(NULL,PERIOD_M30,i); double tBLow3 = iLow(NULL,PERIOD_M30,i+bc3); datetime tBTime1 = iTime(NULL,0,i); datetime tBTime3 = iTime(NULL,0,i+bc3); if(barTriangle) { ObjectCreate(0,signal1,OBJ_TREND,0,tBTime1,tBHigh1,tBTime3,tBHigh3); ObjectCreate(0,signal2,OBJ_TREND,0,tBTime1,tBLow1,tBTime3,tBLow3); ObjectSet(signal1,OBJPROP_RAY,false); ObjectSet(signal2,OBJPROP_RAY,false); }
Here you are mixing time from the current timeframe with prices from M30 using the same bar index, Again, it makes no sense.
double tBLow3 = iLow(NULL,PERIOD_M30,i+bc3); datetime tBTime3 = iTime(NULL,0,i+bc3);You are mixing apples and oranges

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
Im trying to see why it is that the following Indicator code only creates objects on strategytester as and when each bar closes. But when I place the Indicator onto a chart it doesn't draw any previous objects?