FiatExIntl

MACD & BB Strategy

FiatExIntl Telah dikemas kini   
BITTREX:ETHUSDT   Ethereum / Tether
I finished this MACD & BB strategy. Back testing shows promising results in just 7 months worth of trades. Below is the script feel free to play around with it, and if you can make any improvements please share..

Oh, on the alerts.. I realize that the script has to be in study mode.. I may use this in study mode once I'm done to trigger alerts to be sent to Gunbot.. Any ideas on that are welcomed too.

//@version=3
strategy("MACD & BB Strategy Script - ETH/USDT 4 HR", overlay=true)

/////
MacdSrc = input(close, title="Source")

macdfastLength = input(4, minval=1)
macdslowLength=input(22,minval=1)
macdsignalLength = input(9,minval=1)

fastMA = ema(MacdSrc, macdfastLength)
slowMA = ema(MacdSrc, macdslowLength)
macd = fastMA - slowMA
macdsignal = sma(macd, macdsignalLength)
macdhist = macd - macdsignal

/////
BBsrc = input(high, title = "source")

len = input(19, title = "timeframe / # of period's")
bbbase = ema(BBsrc,len)
evar = (BBsrc - bbbase)*(BBsrc - bbbase)
evar2 = (sum(evar,len))/len
std = sqrt(evar2)
Multiplier = input(2, minval = 0.01, title = "# of STDEV's")
bbupper = bbbase + (Multiplier * std)
bblower = bbbase - (Multiplier * std)

/////
buyMACD = cross(macd, macdsignal) and macd > macdsignal
sellMACD = cross(macd, macdsignal) and macd < macdsignal
buyBB = crossunder(BBsrc, bblower)
sellBB = crossover(BBsrc, bbupper)

if (crossover(macdhist, 0))
strategy.entry("MacdLE", strategy.long, comment="MACD Entry", when=buyMACD)

if (crossunder(macdhist, 0))
strategy.close_all(when = sellMACD)

longCondition = crossunder(BBsrc, bblower)
if (longCondition)
strategy.entry("BB Entry", strategy.long, comment="BB Entry", when=buyBB)

shortCondition = crossover(BBsrc, bbupper)
if (shortCondition)
strategy.close_all(when=sellBB)

/////
alertcondition(buyMACD, title='MACD Buy')
alertcondition(sellMACD, title='MACD Sell', message='MACD Sell Signal!')
alertcondition(buyBB, title='BB Buy', message='BB Buy Signal!')
alertcondition(sellBB, title='BB Sell', message='BB Sell Signal!')

/////
plot(bbbase, color = purple, linewidth = 1, title = "BB Basis")
plot(bbupper, color = blue, linewidth = 1, title = "BB Upper band")
plot(bblower, color = blue, linewidth = 1, title = "BB Down band")
Komen:
All trading involves high risk; past performance is not necessarily indicative of future results. Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not actually been executed, the results may have under- or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown.
Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.