Hello,
i'm new to mql programming so excuse me please, if the following is a stupid question.
But i was trying around several hours without success. Perhaps sombody here could
help me.
I want to draw horizontal lines on certain levels, depending on the current close.
For example: If current price is 1,3515, the lines should be on 1,3460 1,3480 1,
3500 1,3520 1,2540 and 13560. Always 3 lines above and below the current close
in 20-Pips-steps.
Does anybody have an idea how i could solve my problem?
My goal is to build an EA which trades always, if one of this levels is reached.
Thanks in advance for any help or tips.
Michael
P.S.: Sorry for my bad english, but its not my mother tongue
- How to draw a moving horizontal line
- How will the order be closed after a certain period of time?
- Indicator help needed
see https://docs.mql4.com/objects.
for example:
for example:
double level1=Close[0]+20*Point; double level2=level1+20*Point; if(ObjectFind("HorizontalLine1")==-1) { ObjectCreate("HorizontalLine1",OBJ_HLINE,0,level1); ObjectSet("HorizontalLine1",OBJPROP_COLOR,Red); ObjectSet("HorizontalLine1",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("HorizontalLine1",OBJPROP_WIDTH,1); } else if(ObjectFind("HorizontalLine1")==0) { ObjectSet("HorizontalLine1",OBJPROP_PRICE1,level1); } if(ObjectFind("HorizontalLine2")==-1) { ObjectCreate("HorizontalLine2",OBJ_HLINE,0,level2); ObjectSet("HorizontalLine2",OBJPROP_COLOR,Red); ObjectSet("HorizontalLine2",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("HorizontalLine2",OBJPROP_WIDTH,1); } else if(ObjectFind("HorizontalLine2")==0) { ObjectSet("HorizontalLine2",OBJPROP_PRICE1,level2); }
Thanks for your fast reply, Luptator.
Perhaps i didn't ask clearly enough what my problem is.
Drawing the lines is not the problem. my problem ist to define the level itself.
If i use your code, the lines move up and down with every tick.
But i want them to stay until they were hit.
Hope i could express in english words, what i want to say. ;)
Thanks again for any help.
just an additional comment:
if anybody coul tell me how to determine the nearest multiples of 0.0020 (above and below current close) i would be an big step closer to the solution of my problem.

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