I sort of get this working(the line is replaced with the arrow for simplicity), but for some reason the code put in start() will only execute once. (I put this for the indicator)
How can I make it execute on every tick?
The idea is quite simple -- create the arrow for the first time, then when panning the bars since it's a tick-based detection, the arrow will move accordingly.
#property indicator_chart_window string SYMM_ARROW = "symm_arrow"; int start() { if (FindObject(SYMM_ARROW) < 0) { ObjectCreate(SYMM_ARROW, OBJ_ARROW, 0, 0, 0); ObjectSet(SYMM_ARROW, OBJPROP_ARROWCODE, SYMBOL_ARROWUP); } ObjectMove(SYMM_ARROW, 0, Time[WindowFirstVisibleBar()-15], Close[WindowFirstVisibleBar()-15]); return(0); } int FindObject(string Name) { if (StringLen(Name) <= 0) return(-1); else return(ObjectFind(Name)); }
Hi phy thanks for the reply :D
I believe my code is correct, since WindowFirstVisibleBar() will return the on-screen first available bar's index (an integer) and then offset back 15 (same as the Time[]), pointing to the Close position.
The only problem I have is the code just won't update per tick; it only executes once (when hitting F5 in MetaEditor) :(
How did you test it in the tester? It only works for EA doesn't it?
Or is there a way to simulate offline ticks?
(I start suspecting that the reason it doesn't work is due to the Close Market...)
Create a new EA, don't modify anything, name it Dummy.
Run it in visual mode. Slow it down with the slider.
Add an indicator, like Moving Average. It shows on the chart.
Add your indicator, it shows on the chart.
If you like, save a template, name it Dummy.
When Dummy EA is tested it will apply Dummy Template with your addtional settings.
Thanks for the step-by-step tips... they work :D
Really hope mt4 support user-events natively, using a event-driven system.
This will make this kind of probing way easier and more efficient.
In fact, Sector Positioning Relative to a Chart in the link below is what I'm looking for:
https://book.mql4.com/functions/objects
However seems that only Labels are native supported, and the scale won't get changed with the chart zoom unless done in code, bringing the same issue above.
The 'coordinates' can't be exchanged easily -- price/time vs window(x,y) in pixels.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
How could I draw a vertical line but keeps its position *related to* the screen?
So when dragging the candle lines this special line won't get moved and will stay at it's original drawn position.
Thanks.