Tradingview: Profitable Well-Developed Price Change MA Strategy

in #trading5 years ago (edited)

Screenshot 2020-04-17 at 3.47.13 PM.png

This tool uses a trend-trading strategy that does what everyone wants: buy low, sell high.

It's designed to trade crypto markets >=6 hr timeframes, but it is profitable in short time frames and other market types if you have low or no trading fees.

This script looks at the open and close of each candle, calculates the price % change, and puts calculated values into a simple moving average ( SMA ) which is overlayed with an exponential moving average ( EMA ) that triggers trades when the EMA exceeds the SMA buy the trading-frequency parameter set by the user.

EMA and SMA length are pre-set for all markets and timeframes, but the option to adjust them is there if you want to fine tune for your comfort.

How to use:
-Adjust the trade-frequency parameter up in order to prevent over-trading, especially if trading short term charts and if you pay high comissions.
-Adjust the trade-frequency parameter down if not enough trades are being made.
-Profit.

If you have additions that lower trading frequency during chop, other than adjusting trade-frequency, I'm very interested.

Drop me a DM if you use/like the tool.

-The Beached Whale

Begin Script:

//@version=3

strategy("Price Change Moving Average", max_bars_back=1000, initial_capital=2000, default_qty_type=strategy.cash, default_qty_value=1500, commission_value = .5)

SMA_Length = input(60, minval=1)
EMA_Length = input(35, minval=1)
TradeFrequency = input(10.0, minval=0)
sellThreshhold = TradeFrequency/2

pc = sma(((close-open)/open)*100000,SMA_Length)
pc2 = ema(((close-open)/open)*100000,EMA_Length)

plotobj1 = plot(pc,color=red)
plotobj2 = plot(pc2,color=purple)

plot(0,color=gray, style=circles)

colored = pc2 > pc and pc2-pc > TradeFrequency ? green : red
fill(plotobj1, plotobj2, color=colored)

if (pc2 > pc and pc2-pc > TradeFrequency)
     strategy.entry("EL", strategy.long, oca_name="PC Moving AVG", oca_type=strategy.oca.cancel, comment="Long")

if (pc2 < pc and pc-pc2 > sellThreshhold)
     strategy.close(id="EL")