我如何将方向运动指数 (adx) "+DI" 高于 28 条件添加到令人兴奋的多头条件?
How can i add directional movement index (adx) "+DI" above 28 condition to exciting long condition?
//突破交易系统在Nifty和BankNifty的周线图和日线图中效果最好
//@version=4
strategy("Donchain BO",shorttitle = "DBO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)
length = input(20, minval=1)
exit = input(1, minval=1, maxval=2,title = "Exit Option") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line
lower = lowest(length)
upper = highest(length)
basis = avg(upper, lower)
l = plot(lower, color=color.blue)
u = plot(upper, color=color.blue)
plot(basis, color=color.orange)
fill(u, l, color=color.blue)
longCondition = crossover(close,upper[1])
if (longCondition)
strategy.entry("Long", strategy.long)
if(exit==1)
if (crossunder(close,lower[1]))
strategy.close("Long")
if(exit==2)
if (crossunder(close,basis[1]))
strategy.close("Long")
给你,我把 ADX- 和 ADX 保存在脚本中,如果你以后想用的话。
//@version=4
strategy("Donchain BO",shorttitle = "DBO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== ADX ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
len = input(14, "ADX Lenth", group="ADX")
TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0
SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)
plot(DIPlus, color=color.new(color.blue,100), title="DI+")
plot(DIMinus, color=color.new(color.red,100), title="DI-")
plot(ADX, color=color.new(color.navy,100), title="ADX")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== Donchain BO ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
length = input(20, minval=1, group="Donchain BO")
exit = input(1, minval=1, maxval=2,title = "Exit Option", group="Donchain BO") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line
lower = lowest(length)
upper = highest(length)
basis = avg(upper, lower)
l = plot(lower, color=color.blue)
u = plot(upper, color=color.blue)
plot(basis, color=color.orange)
fill(u, l, color=color.blue)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== ADX Filter ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ADXfilter_OnOff = input(true, title = "Enable ADX Filter", group="Trades Filter")
ADX_Plus = input(28, minval=1, title="DIPlus", group="Trades Filter")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== Strategy ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
longCondition = crossover(close,upper[1]) and (DIPlus > ADX_Plus or ADXfilter_OnOff == false)
if (longCondition)
strategy.entry("Long", strategy.long)
if(exit==1)
if (crossunder(close,lower[1]))
strategy.close("Long")
if(exit==2)
if (crossunder(close,basis[1]))
strategy.close("Long")
查看 ADX 的三个选项(ADX 不会显示,与价格不同)
1- 您可以在 Tradingview Data window 中查看 ADX、ADX+ 和 ADX- 的值,该数据位于观察列表、警报和新闻图标的右侧
2- 转到指标设置、样式并更改 ADX、ADX+ 和 ADX- 的颜色透明度,然后移动 Y 轴刻度以显示从 0 到更高的值。
3-添加如下指标https://www.tradingview.com/script/VTPMMOrx-ADX-and-DI/
//@version=4
strategy("Donchain BO",shorttitle = "DBO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== ADX ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
len = input(14, "ADX Lenth", group="ADX")
TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0
SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)
plot(DIPlus, color=color.new(color.blue,100), title="DI+")
plot(DIMinus, color=color.new(color.red,100), title="DI-")
plot(ADX, color=color.new(color.navy,100), title="ADX")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== Donchain BO ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
length = input(20, minval=1, group="Donchain BO")
exit = input(1, minval=1, maxval=2,title = "Exit Option", group="Donchain BO") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line
lower = lowest(length)
upper = highest(length)
basis = avg(upper, lower)
l = plot(lower, color=color.blue, title="lower")
u = plot(upper, color=color.blue, title="upper")
plot(basis, color=color.orange, title="basis")
fill(u, l, color=color.blue, title="fill")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== ADX Filter ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ADXfilter_OnOff = input(true, title = "Enable ADX Filter", group="Trades Filter")
ADX_Plus = input(28, minval=1, title="DIPlus", group="Trades Filter")
ADX_Minus = input(28, minval=1, title="DIMinus", group="Trades Filter")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== Strategy ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
longCondition = crossover(close,upper[1]) and (DIPlus > ADX_Plus or ADXfilter_OnOff == false)
shortCondition = crossunder(close,lower[1]) and (DIMinus > ADX_Minus or ADXfilter_OnOff == false)
if (longCondition)
strategy.entry("Long", strategy.long)
if(exit==1)
if (crossunder(close,lower[1]))
strategy.close("Long")
if(exit==2)
if (crossunder(close,basis[1]))
strategy.close("Long")
if (shortCondition)
strategy.entry("Short", strategy.short)
if(exit==1)
if (crossover(close,upper[1]))
strategy.close("Short")
if(exit==2)
if (crossover(close,basis[1]))
strategy.close("Short")
//突破交易系统在Nifty和BankNifty的周线图和日线图中效果最好 //@version=4
strategy("Donchain BO",shorttitle = "DBO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)
length = input(20, minval=1)
exit = input(1, minval=1, maxval=2,title = "Exit Option") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line
lower = lowest(length)
upper = highest(length)
basis = avg(upper, lower)
l = plot(lower, color=color.blue)
u = plot(upper, color=color.blue)
plot(basis, color=color.orange)
fill(u, l, color=color.blue)
longCondition = crossover(close,upper[1])
if (longCondition)
strategy.entry("Long", strategy.long)
if(exit==1)
if (crossunder(close,lower[1]))
strategy.close("Long")
if(exit==2)
if (crossunder(close,basis[1]))
strategy.close("Long")
给你,我把 ADX- 和 ADX 保存在脚本中,如果你以后想用的话。
//@version=4
strategy("Donchain BO",shorttitle = "DBO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== ADX ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
len = input(14, "ADX Lenth", group="ADX")
TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0
SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)
plot(DIPlus, color=color.new(color.blue,100), title="DI+")
plot(DIMinus, color=color.new(color.red,100), title="DI-")
plot(ADX, color=color.new(color.navy,100), title="ADX")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== Donchain BO ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
length = input(20, minval=1, group="Donchain BO")
exit = input(1, minval=1, maxval=2,title = "Exit Option", group="Donchain BO") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line
lower = lowest(length)
upper = highest(length)
basis = avg(upper, lower)
l = plot(lower, color=color.blue)
u = plot(upper, color=color.blue)
plot(basis, color=color.orange)
fill(u, l, color=color.blue)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== ADX Filter ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ADXfilter_OnOff = input(true, title = "Enable ADX Filter", group="Trades Filter")
ADX_Plus = input(28, minval=1, title="DIPlus", group="Trades Filter")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== Strategy ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
longCondition = crossover(close,upper[1]) and (DIPlus > ADX_Plus or ADXfilter_OnOff == false)
if (longCondition)
strategy.entry("Long", strategy.long)
if(exit==1)
if (crossunder(close,lower[1]))
strategy.close("Long")
if(exit==2)
if (crossunder(close,basis[1]))
strategy.close("Long")
查看 ADX 的三个选项(ADX 不会显示,与价格不同)
1- 您可以在 Tradingview Data window 中查看 ADX、ADX+ 和 ADX- 的值,该数据位于观察列表、警报和新闻图标的右侧
2- 转到指标设置、样式并更改 ADX、ADX+ 和 ADX- 的颜色透明度,然后移动 Y 轴刻度以显示从 0 到更高的值。
3-添加如下指标https://www.tradingview.com/script/VTPMMOrx-ADX-and-DI/
//@version=4
strategy("Donchain BO",shorttitle = "DBO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== ADX ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
len = input(14, "ADX Lenth", group="ADX")
TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0
SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)
plot(DIPlus, color=color.new(color.blue,100), title="DI+")
plot(DIMinus, color=color.new(color.red,100), title="DI-")
plot(ADX, color=color.new(color.navy,100), title="ADX")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== Donchain BO ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
length = input(20, minval=1, group="Donchain BO")
exit = input(1, minval=1, maxval=2,title = "Exit Option", group="Donchain BO") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line
lower = lowest(length)
upper = highest(length)
basis = avg(upper, lower)
l = plot(lower, color=color.blue, title="lower")
u = plot(upper, color=color.blue, title="upper")
plot(basis, color=color.orange, title="basis")
fill(u, l, color=color.blue, title="fill")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== ADX Filter ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ADXfilter_OnOff = input(true, title = "Enable ADX Filter", group="Trades Filter")
ADX_Plus = input(28, minval=1, title="DIPlus", group="Trades Filter")
ADX_Minus = input(28, minval=1, title="DIMinus", group="Trades Filter")
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////=== Strategy ===/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
longCondition = crossover(close,upper[1]) and (DIPlus > ADX_Plus or ADXfilter_OnOff == false)
shortCondition = crossunder(close,lower[1]) and (DIMinus > ADX_Minus or ADXfilter_OnOff == false)
if (longCondition)
strategy.entry("Long", strategy.long)
if(exit==1)
if (crossunder(close,lower[1]))
strategy.close("Long")
if(exit==2)
if (crossunder(close,basis[1]))
strategy.close("Long")
if (shortCondition)
strategy.entry("Short", strategy.short)
if(exit==1)
if (crossover(close,upper[1]))
strategy.close("Short")
if(exit==2)
if (crossover(close,basis[1]))
strategy.close("Short")