Atlanta_17
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: September 21st, 2022

HELP ME WITH MY SCRIPT

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?

purplemint22
Pine Script Rookie
Pine Script Rookie
Posts: 17
Joined: October 14th, 2022

Re: HELP ME WITH MY SCRIPT

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)

Return to “Pine Script Q&A”