You are calling ObjectFind() , which checks if the object already exists. If the object already exists, it won't recreate it, but this doesn't refresh the levels if you change the indicator's settings. You could try using ObjectDelete() before creating the levels to ensure they get updated each time.
Something like
void CreateLevel(string name, double value) { if (ObjectFind(0, name) != -1) ObjectDelete(name); ObjectCreate(0, name, OBJ_HLINE, 0, 0, value); ObjectSetInteger(0, name, OBJPROP_COLOR, clrSilver); ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_DOT); ObjectSetInteger(0, name, OBJPROP_WIDTH, 1); }
the ChartSetInteger() function should also ideally be placed outside the initialization code
Check behaviour of
( CHART_COLOR_CANDLE_BULL and CHART_COLOR_CANDLE_BEAR )
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
Hi,
I need some help here.
I want to add stochastic oscillator with these custom levels with MQL4 to MT4.
I am also changing chart colour and candle stick colours,
When even I attach my custom stochastic indicator, I have to open and close settings manualy before it starts to work.
Any idea as to what I'm doing wrong?