Another strategy from Relaxed Trader at https://relaxedtrader.com/opening-range-breakout-strategy/
I decided to code this in Pinescript this time. Although I tried to code as close as I can, results are not reflecting the original author's findings. Please check my code.
I decided to code this in Pinescript this time. Although I tried to code as close as I can, results are not reflecting the original author's findings. Please check my code.
Code:
// SPY Short with ORB
// Free for use. Header credits must be included when any form of the code included in this package is used.
// v1.0 - barbaros - converted for b4signals.com
//@version=5
strategy("SPY Short with ORB", overlay=true, initial_capital=100000)
UseMoneyManagement = input.bool(true, "Use Money Management")
ConstractsSet = input.int(1, "Contracts Set")
riskPercent = input.int(10, "Risk Percent")
var1 = input.int(39, "var1")
var2 = input.int(1, "var2")
var3 = input.float(.25, "var3")
var4 = input.int(11, "var4")
atr = ta.atr(var1)
Range = math.abs(close[1] - open[1])
LargestRange = ta.highest(Range[1], var4)
contractsToTrade = UseMoneyManagement ? ((riskPercent * 0.01) * strategy.equity) / (atr * 2.6) : ConstractsSet
float LimitPrice = na
LimitPrice := LimitPrice[1]
SellSignal = strategy.position_size == 0 and Range >= LargestRange and Range >= var2 * atr and close > open
SellExit = strategy.position_size < 0 and high >= LimitPrice
plotshape(SellSignal, text="Sell", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white)
if SellSignal
LimitPrice := close + var3 * atr
strategy.entry("SE", strategy.short, contractsToTrade, limit = LimitPrice)
if SellExit
LimitPrice := na
strategy.close_all(SellExit)
plot(LimitPrice, "LimitPrice", style=plot.style_linebr)
