TradingView
KivancOzbilgic
Aug 8, 2022 2:25 PM

AlphaTrend Strategy 

Bitcoin / TetherUSBinance

描述

The strategy version of AlphaTrend indicator for backtesting and optimisation purposes for TradingView users:

tradingview.com/script/o50NYLAZ-AlphaTrend/


Screener / Explorer version and an English explantion video will be published soon...

AlphaTrend's parameters are designed for daily and 4H charts, feel free to optimize on all time frames.

Hope you all use Alphatrend in your profitable trades.

Kıvanç

版本注释

Backtest parameters updated:
-Backtested with default parameters (14/1) of AlphaTrend BTCUSDT daily Binance chart (with all available price data)
-Backtested initial capital updated to 1000USD
-Order size set as 1000USD
-Commission is set to 0.1% same as this is a Binance chart so 0.1% is the default user level on that exchange
-Slippage set to 100 ticks which could be meaningful
-AlphaTrend is a trend following indicator so it's main purpose is to enter positions in trending markets and not to enter in sidewys vice versa. So It won't make too much trades (in this example with deafult values number of trades limited with 41 which would be more meaningful if it was near to 100)
-Users can cahnge and optimize the parameters to get more efficiens results. I personally advise to choose smaller parameters in bigger time frames and smaller ones in big time frames.

Hope you all use AlphaTrend on your profitable trades.
Also personally thank all the community to make AlphaTrend one of the top 3 most popular scripts in the world in 2022:

Kıvanç Özbilgiç
评论
UnknownUnicorn16043985
This is great! I found that it was helpful to try this strategy as "long" only when testing by removing the short part of the strategy. I also added a window so that the user could specify the duration as the Deep Backtesting feature wasn't very helpful.

// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// author © KivancOzbilgic
// developer © KivancOzbilgic
//@version=5

strategy("AlphaTrend Strategy", shorttitle='ATst', overlay=true, format=format.price, precision=2, margin_long=100, margin_short=100)
coeff = input.float(1, 'Multiplier', step=0.1)
AP = input(14, 'Common Period')
ATR = ta.sma(ta.tr, AP)
src = input(close)
showsignalsk = input(title='Show Signals?', defval=false)
novolumedata = input(title='Change calculation (no volume data)?', defval=false)
upT = low - ATR * coeff
downT = high + ATR * coeff
AlphaTrend = 0.0
AlphaTrend := (novolumedata ? ta.rsi(src, AP) >= 50 : ta.mfi(hlc3, AP) >= 50) ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT

FromMonth = input.int(defval=1, title='From Month', minval=1, maxval=12)
FromDay = input.int(defval=1, title='From Day', minval=1, maxval=31)
FromYear = input.int(defval=1900, title='From Year', minval=999)
ToMonth = input.int(defval=1, title='To Month', minval=1, maxval=12)
ToDay = input.int(defval=1, title='To Day', minval=1, maxval=31)
ToYear = input.int(defval=9999, title='To Year', minval=999)
start = timestamp(FromYear, FromMonth, FromDay, 00, 00)
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)
window() =>
time >= start and time <= finish ? true : false

color1 = AlphaTrend > AlphaTrend[2] ? #00E60F : AlphaTrend < AlphaTrend[2] ? #80000B : AlphaTrend[1] > AlphaTrend[3] ? #00E60F : #80000B
k1 = plot(AlphaTrend, color=color.new(#0022FC, 0), linewidth=3)
k2 = plot(AlphaTrend[2], color=color.new(#FC0400, 0), linewidth=3)

fill(k1, k2, color=color1)

buySignalk = ta.crossover(AlphaTrend, AlphaTrend[2])
sellSignalk = ta.crossunder(AlphaTrend, AlphaTrend[2])

K1 = ta.barssince(buySignalk)
K2 = ta.barssince(sellSignalk)
O1 = ta.barssince(buySignalk[1])
O2 = ta.barssince(sellSignalk[1])

plotshape(buySignalk and showsignalsk and O1 > K2 ? AlphaTrend[2] * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0022FC, 0), textcolor=color.new(color.white, 0))

plotshape(sellSignalk and showsignalsk and O2 > K1 ? AlphaTrend[2] * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.maroon, 0), textcolor=color.new(color.white, 0))

// track the number of orders placed on current candle
ordersCreatedOnCurrentCandle = false
ordersCreatedOnCurrentCandle := false

if (window() and strategy.position_size == 0 and ordersCreatedOnCurrentCandle == false and buySignalk)
strategy.entry("Long", strategy.long)
// set to true since orders have now
Mhsnts
@JustInNovel, Hello, I wanted to try but couldn't add. (time >= start and time <= finish ? true : false) This line gives an error.
UnknownUnicorn16043985
@Mhsnts, idk, it works for me
jag0113
@Mhsnts, getting the same
isaacdouglasharmon
@Mhsnts, Add a tab after window() =>
time >= start and time <= finish ? true : false
tvphigroup
@isaacdouglasharmon, could you please post the correct script in your opinion? It doesn't work with your suggestion
champi0ntrades
@JustInNovel, hey im having a few problems, can i dm u
tvphigroup
@JustInNovel, it gives error message
itraderscalp
Hocam selamlar;

Bu stratejiyi 1 dakikalık ve iz süren stop ile kullanmak istiyorum.Matriksiq binance futureste kullanılacak 2 yönlü işlem
enpasss
metatrader da backtest yapabilmek için mql kodu var mı?
更多