Page 1 of 1

HELP ME WITH MY SCRIPT

Posted: Wed Sep 21, 2022 11:13 am
by Atlanta_17
Hi everyone, I'm new to this forum and the pine language. I started designing my first key level based indicator. I simply created horizontal lines on some price levels using the "hline" function. Now I would like my script to detect when the price hits one of the levels and moves away by a specific number of pips. I would also like to add an alert about this feature. Can anyone give me some advice?

Re: HELP ME WITH MY SCRIPT

Posted: Sun Oct 16, 2022 11:01 pm
by purplemint22
I would suggest using an input to set the number of pips away from the price that you are looking for. That way you won't have to change your code if you decide to use a different number. You can just change this in the settings.

numberOfPipsAway = input.int(14)

Then you could pass this variable as part of the conditions for an if statement.

if(numberOfPipsAway == 14)
alert(message="the price has moved" + str.tostring(numberOfPipsAway) + "pips away", freq=alert.freq_once_per_bar)