It will try to create a line on every tick which will definitely be problematic.
if(ObjectFind()<0) ObjectCreate() and all the parameter setting.
Also ObjectCreate(0,..., not ObjectCreate(_Symbol,...
MqlDateTime has hours and minutes in it.It will try to create a line on every tick which will definitely be problematic.
if(ObjectFind()<0) ObjectCreate() and all the parameter setting.
Also ObjectCreate(0,..., not ObjectCreate(_Symbol,...
MqlDateTime has hours and minutes in it.You must get TimeLocal, turn it to MqlDateTime, set the hour to 10/11 then turn it to datetime. It's actually way more complicated than your solution, I don't know why I've mentioned it.
For CopyHigh/Low I think arrays must be resized manually, especially if the copying is by time, not by index. But you don't really need those since you have CopyRates later (whose array's size should probably also be fixed).
Return of CopyRates should be checked as it might not copy the rates on first try.
Hi MrSeeden,
There are several issues with your code. It appears that you've tried several things and now they're unsuccessfully intermingling. Sometimes it's better to scrap and start over. Like kypa mentioned, you can only call objectcreate once per "name". Create your objects once, and then update the price only. Removing all the redundant and unnecessary code your project would look something like this.
input color InpColor=clrRed; // Linienfarbe input ENUM_LINE_STYLE InpStyle=STYLE_DASH; // Linienstil input int InpWidth=2; // Linienbreite input int Periode=PERIOD_M5; //Eingabe der Zeiten für die ORB input datetime anfangszeit = D'1:00'; input datetime endzeit = D'11:00'; #include <ChartObjects\ChartObjectsLines.mqh> CChartObjectHLine high_line, low_line; int OnInit() { high_line.Create(0, "high", 0, 0.0); high_line.Color(InpColor); high_line.Style(InpStyle); high_line.Width(InpWidth); low_line.Create(0, "low", 0, 0.0); low_line.Color(InpColor); low_line.Style(InpStyle); low_line.Width(InpWidth); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnTick() { double hoch[], tief[]; CopyHigh(_Symbol, _Period, anfangszeit, endzeit, hoch); CopyLow (_Symbol, _Period, anfangszeit, endzeit, tief); high_line.Price(0, hoch[ArrayMaximum(hoch)]); low_line.Price(0, tief[ArrayMinimum(tief)]); }
Hi MrSeeden,
There are several issues with your code. It appears that you've tried several things and now they're unsuccessfully intermingling. Sometimes it's better to scrap and start over. Like kypa mentioned, you can only call objectcreate once per "name". Create your objects once, and then update the price only. Removing all the redundant and unnecessary code your project would look something like this.
- 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. I would like my expert advisor to create 2 lines, where the high and low of a certain timeframe (10:00 until 11:00) is. When compiling my code doesnt not seem to have an error, but it stops working while backtesting because array is out of range (47,70) (there is only a comment in line 47). Thank you for your help.