0% found this document useful (0 votes)
167 views

Pine Editor Script

This trading strategy uses the average true range (ATR) and volume indicators to generate entry and exit signals for long and short positions. It defines ATR and volume indicators, then sets thresholds for the indicators to determine entry signals when volume is above its threshold and ATR is above/below its threshold for long/short positions. Exit signals occur when volume falls below its threshold or ATR moves above/below its threshold. The strategy plots the signal shapes and enters/exits positions accordingly.

Uploaded by

deepakpushpad
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
167 views

Pine Editor Script

This trading strategy uses the average true range (ATR) and volume indicators to generate entry and exit signals for long and short positions. It defines ATR and volume indicators, then sets thresholds for the indicators to determine entry signals when volume is above its threshold and ATR is above/below its threshold for long/short positions. Exit signals occur when volume falls below its threshold or ATR moves above/below its threshold. The strategy plots the signal shapes and enters/exits positions accordingly.

Uploaded by

deepakpushpad
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//@version=5

strategy("ATR-Volume Strategy")

// Define ATR and volume indicators


atr_len = input.int(14, "ATR Length")
atr = ta.atr(atr_len)
vol = volume

// Define entry and exit signals


entry_vol_threshold = input.float(2.0, "Entry Volume Threshold")
entry_atr_move = input.float(1.5, "Entry ATR Move")
entry_atr_lookback = input.int(10, "Entry ATR Lookback")
exit_vol_threshold = input.float(0.5, "Exit Volume Threshold")
exit_atr_move = input.float(1.0, "Exit ATR Move")
long_entry = vol > entry_vol_threshold * ta.sma(vol, entry_atr_lookback) and atr >=
entry_atr_move
long_exit = vol < exit_vol_threshold * ta.sma(vol, entry_atr_lookback) or atr <= -
exit_atr_move
short_entry = vol > entry_vol_threshold * ta.sma(vol, entry_atr_lookback) and atr
<= -entry_atr_move
short_exit = vol < exit_vol_threshold * ta.sma(vol, entry_atr_lookback) or atr >=
exit_atr_move

// Plot signals
plotshape(long_entry, style=shape.triangleup, color=color.green,
location=location.belowbar, size=size.small, text="Long Entry")
plotshape(long_exit, style=shape.triangledown, color=color.red,
location=location.abovebar, size=size.small, text="Long Exit")
plotshape(short_entry, style=shape.triangledown, color=color.red,
location=location.abovebar, size=size.small, text="Short Entry")
plotshape(short_exit, style=shape.triangleup, color=color.green,
location=location.belowbar, size=size.small, text="Short Exit")

// Enter long position on entry signal


if long_entry
strategy.entry("Long", strategy.long)
strategy.exit("Exit", "Long", stop=atr * 0.5, limit=atr * 1.5)

// Exit long position on exit signal


if long_exit
strategy.close("Long")

// Enter short position on entry signal


if short_entry
strategy.entry("Short", strategy.short)
strategy.exit("Exit", "Short", stop=atr * 0.5, limit=atr * 1.5)

// Exit short position on exit signal


if short_exit
strategy.close("Short")

You might also like