ObjectCreate "OBJ_RECTANGLE" doesn't work in other timeframes
FrazeColder: But if I change the timeframe to e.g. M15 the rectangle doesn't appear right...
-
Play videoPlease edit your post.
For large amounts of code, attach it. - You created the rectangle with the chart's time. If you created it using the D1 then the end points will be midnight. Moving to a smaller timeframe means the rectangle will not be on the extreme bar. but still on midnight. Draw a trendline from the lowest to the highest and then move down one timeframe and examine it.
- If you want it to be correct on all timeframes, find the lowest/highest bar in the M1 so you have accurate timestamps.
Hey Guys,
I'm programming actually a EA. I need to visualize a specified area and I want to do this with the rectangle. But the problem is:
In the initialized is the specified area right. But if I change the timeframe to e.g. M15 the rectangle doesn't appear right... - Why is that so?
Everything else works. E.g. the object lines...
Her the code:
string point = ".";
string spacer = " ";
string doublepoint = ":";
string year = IntegerToString(Year());
string month = IntegerToString(Month());
string day = IntegerToString(Day());
StringAdd(year, point);
StringAdd(month, point);
StringAdd(day, spacer);
StringAdd(fromH, doublepoint);
StringAdd(toH, doublepoint);
datetime lowest = StrToTime(fromFinal);
datetime highest = StrToTime(toFinal);
int leftToShiftLowest = iBarShift(NULL, 0, lowest);
int leftToShiftHighest = iBarShift(NULL, 0, highest);
lowestPrice = iLow(NULL, 0, lowestShifts);
highestPrice = iHigh(NULL, 0, highestShifts);
span = (highestPrice - lowestPrice);
datetime lowestBar = iTime(Symbol(), 0, lowestShifts);
datetime highestBar = iTime(Symbol(), 0, highestShifts);
ObjectCreate("Range", OBJ_RECTANGLE, 0, lowestBar, lowestPrice, highestBar, highestPrice);