Posts

Showing posts with the label Pinescript

Pine script for Intraday backtesting Previous Day high and Previous Day Low Breakout strategy

In this article, I will try to explain the backtesting of range breakout strategy using Pine Script.   Intraday range breakout strategy is a well known concept among trading community. We will test previous day range breakout, as soon as underlying script crosses previous day high we will initate buy and opposite conditions for sell (if script goes below previous day low, we will sell it). We will keep fixed stop loss which is configurable.   // © ObserveNifty //@version=4 strategy("Previous Day High and Low Breakout Strategy", overlay=true, calc_on_every_tick=true) D_High = security(syminfo.tickerid, 'D', high[1]) D_Low = security(syminfo.tickerid, 'D', low[1]) D_Close = security(syminfo.tickerid, 'D', close[1]) D_Open = security(syminfo.tickerid, 'D', open[1]) // Go Long - if prev day high is broken // Go Short - if prev day low is broken plot(timeframe.isintraday ? D_High : na, title="Daily High", style=plot.style_line, color=...

Pinescript Code for Hilega Milega

Image
  Strategy and image Credit: NK@StockTalk //@version=3 // © ObserveNifty study("Hilega Milega Strategy by @ObserveNifty", overlay=true) //length_RSI = input(9) priceRSI = close rsi = rsi(priceRSI, 9) wma_rsi = wma(rsi, 21) ema_rsi = ema(rsi, 3) vwap_close = vwap(close) // Deternine if we are currently LONG isLong = false isLong := nz(isLong[1], false) // Determine if we are currently SHORT isShort = false isShort := nz(isShort[1], false) // buytrigger = not isLong and crossover(vrsi14,50) and crossover(vrsi5,70) buytrigger = not isLong and wma_rsi < ema_rsi and wma_rsi > 50 and close > vwap_close plotshape(buytrigger, title="Buy Signal Generated", text="Buy", textcolor=white, style=shape.labeldown, location=location.abovebar, color=red, transp=0, size=size.tiny) buyExit = isLong and (wma_rsi > ema_rsi or wma_rsi <= 50 or close < vwap_close) plotshape(buyExit, title="Exit Buy", text="Exit Buy", textcolor=wh...