I am toying with some ideas for a future indicator and I am stumped at this problem:
The indicator draws some lines across the screen as soon as it is loaded, as expected. Then I save the chart as a template. Then I load the template in another chart and the indicator is loaded, but it doesn't draw the lines. I've spent a long time analysing this and can't find the reason. Can someone please help?
TIA
You can delete the remaining objects from the old chart in the Inıt function.
ObjectsDeleteAll ();
Or
LineName = "SliceLine_" + i;
You can try to run the code as follows.
LineName = Symbol () + string (Period ()) + "SliceLine_" + i;
You can delete the remaining objects from the old chart in the Inıt function.
ObjectsDeleteAll ();
Or
LineName = "SliceLine_" + i;
You can try to run the code as follows.
LineName = Symbol () + string (Period ()) + "SliceLine_" + i;
Neither suggestion works.
I can't understand them either.
int OnInit() { PriceMax = WindowPriceMax(); PriceMin = WindowPriceMin();
Do not use price or server related calls on OnInit. Waiit for OnCalc.
Neither suggestion works.
I can't understand them either.
I wonder if it gives any errors in the Expert tab?
I wonder if it gives any errors in the Expert tab?
No errors. I planted a few Print statements that only proved that everything was running as expected, except the lines weren't drawn as expected.
William's solution does the job, but only if the market is opened. That is another thing for me not to understand very well, because my code never fails to detect the current price, for example, when the market is either opened or closed.
There are many things in MQL4 that I don't quite understand.
No errors. I planted a few Print statements that only proved that everything was running as expected, except the lines weren't drawn as expected.
William's solution does the job, but only if the market is opened. That is another thing for me not to understand very well, because my code never fails to detect the current price, for example, when the market is either opened or closed.
There are many things in MQL4 that I don't quite understand.
drawSlices () and drawLines (string name, double price)
Can you write the code for calling functions for
OnCalculate()
drawSlices () and drawLines (string name, double price)
Can you write the code for calling functions for
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- return value of prev_calculated for next call //I want the code to call these functions here. Since the code is not all, // it will be difficult for us to find the error. drawSlices (); drawLines(); return(rates_total); }whoowl:
I'm sorry, are you asking me? Do you want me to post something? Your comment is not clear enough to me.
@ whoowl
![whoowl whoowl](https://c.mql5.com/36/47/whoowl.png)
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am toying with some ideas for a future indicator and I am stumped at this problem:
The indicator draws some lines across the screen as soon as it is loaded, as expected. Then I save the chart as a template. Then I load the template in another chart and the indicator is loaded, but it doesn't draw the lines. I've spent a long time analysing this and can't find the reason. Can someone please help?
TIA