AlcoParticipant
Senior
Could someone help me to draw lines on round numbers with a code?
For example:
1.1600
1.1650
1.1700
Thanks
LeoParticipant
Veteran
very simple
retourn 1.1600,1.650, 1.1700
All the People here is eager to help you but you should do first your homework: read, learn and practice a lot.
Kind Regards
Maybe Alco want them to be drawn automatically, each 50 points, starting from a round number?
AlcoParticipant
Senior
Yes Nicolas, that’s what i mean.
I made a French video before new graphical instructions, so it’s a bit messy on chart, but that was a good code before that: https://www.prorealcode.com/blog/video-tutorials/trading-des-chiffres-ronds-grace-a-probuilder/
Here is the code:
//round number to nearest upper 25
roundnumber = 50
for i = 1 to roundnumber do
if (close+i*pointsize) mod roundnumber*pointsize = 0 then
upper = round(close+i*pointsize)
if upper mod roundnumber = 1 then
upper = upper-1
endif
break
endif
next
for i = roundnumber downto 1 do
if (close-i*pointsize) mod roundnumber*pointsize = 0 then
lower = round(close-i*pointsize)
if lower mod roundnumber = 1 then
lower = lower-1
endif
break
endif
next
for i = 1 to roundnumber do
if (upper+i*pointsize) mod roundnumber*pointsize = 0 then
upper1 = round(upper+i*pointsize)
if upper1 mod roundnumber = 1 then
upper1 = upper1-1
endif
break
endif
next
for i = roundnumber downto 1 do
if (lower-i*pointsize) mod roundnumber*pointsize = 0 then
lower1 = round(lower-i*pointsize)
if lower1 mod roundnumber = 1 then
lower1 = lower1-1
endif
break
endif
next
return upper, lower, upper1, lower1
I’m sorry, very busy now so I can’t transform it now with DRAWSEGMENT or DRAWHLINE, maybe someone could help?