Pine Script - Add a Long and Short Strategy to existing script

Job ID: 34648013

Budget: $10 – $12 USD

I am using a pinescript in TRADINGVIEW that plots alerts on a chart. I have highlighted the alerts I want in green (see JPG). In the script I think the alerts are :"bool_0_mt_4" and " bool_0_lt_4"

I simply want to add strategy.entry() and strategy.exit() with inputs for a STOP LOSS/PROFIT (see simple example below )..so i can set up a TRADING STRATEGY.

I need it documented in the SCRIPT so I can understand how to use it.

Example below of a simple pinescript that does this


I.e
//@version=3
strategy("Stop Loss Example: Simple Stoploss", overlay=true)

sma_per = input(200, title=‘SMA', minval=1)
sl_inp = input(2.0, title='Stop Loss %', type=float)/100
tp_inp = input(4.0, title='Take Profit %', type=float)/100

sma = sma(close, sma_per)

stop_level = strategy.position_avg_price * (1 - sl_inp)
take_level = strategy.position_avg_price * (1 + tp_inp)

strategy.entry("Simple SMA Entry", strategy.long, when=crossover(close, sma))

strategy.exit("Stop Loss/TP","Simple SMA Entry", stop=stop_level, limit=take_level)

plot(sma, color=orange, linewidth=2)
plot(stop_level, color=red, style=linebr, linewidth=2)
plot(take_level, color=green, style=linebr, linewidth=2)
Related categories: Pine Script Trading