I need a trading system coded onto pine script so that I can backtest this strategy on Tradingview.
Indicators: 5 EMA, 21 EMA, 50 EMA & 100 Bollinger bands.
1. I need an option to switch "short strategy" off. I may not want to short a particular market, so I would like the toggle option to switch the "short the market" on or off.
So that it is either:
Short mode off: buy on signal and exit on signal, no to selling.
Short mode on: buy on signal and sell on signal, yes to selling.
2. Trading direction: Defined by the 21 EMA being above the 50 EMA for buying (long), or by the 21 EMA being below the 50 EMA for selling (short) or exiting position (optional).
3. Trading example # 1, the core of the system:
Enter market as a buy (long) when the 5 EMA & 21 EMA crosses and are above the 50 EMA on a candle close.
Take profit on a candle close on the outside of the upper 100 Bollinger band, or take a loss if the 5 EMA closes below the 50 EMA.
4. Trading example # 2, re entry into the market after a profit:
if the price is still in an uptrend (21 EMA is above the 50 EMA) but the 5 EMA is below the 21 EMA (during a pullback) and crosses above the 21 EMA again, enter to buy again. Take profit on a close on the outside of the upper bollinger band. exit position if the 5 EMA crosses the %) EMA.
If you need any more info on this system, please ask and I will elaborate further.