I think your problem is your LengthOfBox variable, is it specified in H1 candles ?
That is OK, but if it is the case you can't use these to work out the time for the ends of the box . . .
ObjectSet("Box", OBJPROP_TIME1, Time[LengthOfBox]); // <--- only works on H1 ObjectSet("Box", OBJPROP_PRICE1, HighestHighInBox); ObjectSet("Box", OBJPROP_TIME2, Time[1]); // <--- only works on H1
. . . instead try . . .
ObjectSet("Box", OBJPROP_TIME1, iTime(NULL, PERIOD_H1, LengthOfBox) ); // <--- works on any TF ObjectSet("Box", OBJPROP_PRICE1, HighestHighInBox); ObjectSet("Box", OBJPROP_TIME2, iTime(NULL, PERIOD_H1, 1) ); // <--- works on any TF
You will also have a similar issue for the top and bottom of the box but I'll leave that to you to address.
Will get right on it. Thank you!
int HighestIndex = iHighest(NULL,PERIOD_H1,MODE_HIGH,LengthOfBox,1); HighestHighInBox = iHigh[NULL,PERIOD_H1,HighestIndex]; //<------- int LowestIndex = iLowest(NULL,PERIOD_H1,MODE_LOW,LengthOfBox,1); LowestLowInBox = iLow[NULL,PERIOD_H1,LowestIndex]; //<-------
Got it! Thank you for the task.
Always better to teach somebody fishing than just giving him a fish.
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
Hello folks.
I'm making calculations for the box size according to H1. So if my chart is set on H1 while the box is drawn I'm fine. If I'm on another timeframe, I'm messed up, because the box is drawn according to the candles and not time.
How can I tell in the code to draw the box on H1, no matter what time I currently have?
In case this is not working: How can I approach what I need?
Just to clarify: If I calculate a box for the last 4 hours, it will be including 4 H1 candles. If I have my chart in H4 when the box is drawn, the box will include 4 H4 candles, while it should only be one in my case.
Anybody some input?
Thanks.
WorstCases