Posts

Showing posts with the label Trading

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=...

Golden Crossover with MA strategy

Most of the fundamental investors believe in Buy and Hold strategy, but I think most of the retail fundament investors doesn't know when to exit. Also in most cases they get trapped when there is a sudden deterioration in the fundaments. So, for such investors, I believe below is a very good strategy and may save from huge draw-down. This strategy is purely for long term or positional investors. It is combination of two different strategies which are famous among swing or positional traders namely golden crossover (50/200) and 200 moving average. Strategy:  Open stock on a daily time frame chart, draw moving average indicators for 50 and 200 on the chart, these MA indicators will draw 50 days and 200 days moving average of stock. Now for buying the stock you need to see below two conditions: Stock should trade above 200 moving average line. Shorter moving average line should be above longer duration moving average, that means 50 ma line should be above 200 ma line. Similarly f...