stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Script to draw line at 50% of candle
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5264
Page 1 of 2
Author:  GT3RS [ Thu Aug 31, 2017 5:30 am ]
Post subject:  Script to draw line at 50% of candle

Hi all,

I'm very interested in trading around the 50% level of certain candles.

Currently, I have to select the candle, drag a fib on it, make sure the 0 and 100 levels are bang on correct, then draw my horizontal trendline [with ray] on the 50%.

I wondered if there's such a thing as a script where I can just drag something to the specific candle and it draws the line automatically at 50%? Would make the process SOOOO much faster!!

Thanks in advance guys!

Rob
Author:  mrpipstrader [ Thu Aug 31, 2017 7:34 am ]
Post subject:  Script to draw line at 50% of candle

Hi Rob,

What you need can probably be derived from this SHF thread by happytrader http://www.stevehopwoodforex.com/phpBB3 ... =48&t=2086 - "Simple script to snap lines to high or low of candles".

His script does more than high and low lines in the title. For your purposes pay particular attention to his MyMidLine variable and calculation. The complete script is near the end of the thread and you should be able to adapt this to whatever you want. It seems obvious even to a non-coder like me.

Cheers,
mrpipstrader
Author:  GT3RS [ Thu Aug 31, 2017 3:58 pm ]
Post subject:  Script to draw line at 50% of candle

Many thanks mate!

Just looking at it makes my head spin though!!

Will try to figure it all out. If you don't hear anything more on this thread, assume I've cracked it!! [highly unlikely!!!]

Cheers,

Rob
Author:  SteveHopwood [ Thu Aug 31, 2017 8:16 pm ]
Post subject:  Script to draw line at 50% of candle

Here you go. It only took a minute. You have been a member for a long time and I do not recall you endlessly jumping up and down demanding stuff, so take it with my blessing. I hope it helps you.

CandleShift is the candle you want to look at. The default of 1 means the previous candle. The rest I leave you to work out for yourself.

:xm:
Author:  GT3RS [ Fri Sep 01, 2017 5:18 pm ]
Post subject:  Script to draw line at 50% of candle

Wow!!

Many thanks Steve! Works a treat!!!
Author:  GT3RS [ Sun Sep 03, 2017 7:27 am ]
Post subject:  Script to draw line at 50% of candle

Steve, maybe you shouldn't have helped, because now I AM jumping up and down, demanding things!!! :smile: :smile: :smile: :smile:

When I use your wonderful [!] script on the same chart more than once, I have to give the each trendline its own object name manually. Otherwise the script deletes the first one and then draws the new one.

Is it possible to give each instance it's own object name/number in order to avoid this?

Not a major problem if it can't be done.

Thanks once again!

Rob
Author:  SteveHopwood [ Sun Sep 03, 2017 9:22 am ]
Post subject:  Script to draw line at 50% of candle

Here you are.

Each trendline has its own unique name. This was the time and date the line was created, converted to a string and using the broker's time. This does not work over the weekend because the broker's time does not change. This version uses your own local time, so each line name is different.

:xm:
Author:  GT3RS [ Wed Sep 06, 2017 2:17 pm ]
Post subject:  Script to draw line at 50% of candle

Perfect!!! :clap: :clap: :clap: :clap:

Many thanks once again Steve!
Author:  GT3RS [ Fri Feb 09, 2018 10:47 am ]
Post subject:  Script to draw line at 50% of candle

This really is a great tool for me and my trading. I have even managed to change it, so that I can draw a line from the high or low of a candle. AMAZING coding skills by me!!! :smile: :smile: :smile:

When I have refined some more, I will share what I am doing.

In the meantime, would any of you wonderful coders like to assist a little bit further?

1. It would be fantastic to have push notifications from this script.

2. It would be equally fantastic to have it so that it only shows the line it creates, on the timeframe it is created on, and all timeframes below that one.

3. Finally, what would be MEGA fantastic [!], would be to have it draw the lines in different colours for different timeframes.

If anyone is able to help, I'd be extremely grateful. I guess no.1 is the most important, with no.s 2 and 3 being "nice to haves."

I've attached the 3 scripts: One for 50% of the candle and the other 2 for hi and lo, respectively.

Many thanks in advance,

Rob
Author:  SteveHopwood [ Fri Feb 09, 2018 12:24 pm ]
Post subject:  Script to draw line at 50% of candle

Why not see if you can sort it out for yourself - an excellent way to learn.

Load the attached into the editor and do a search for "// Enable to send push notification on alert" to take you to the inputs.

Then do a search for the AlertPush input to take you to the places where calls are sent to the AlertNow() function that sends the call.

Then do a search for the AlertSent variable. This will show you how it is used to avoid multiple pushes and how to turn it off at the open of a new candle.

:xm:
All times are UTC Page 1 of 2