TUE ADX/MACD Confluence V1.0

TradersUltimateEdge · study · 65 行 · 点赞 4,979 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Written by TradersUltimateEdge
// Code provided open source, feel free to use it for any purpose except resale
 
//@version=5
indicator("TUE ADX/MACD Confluence V1.0", overlay=true)
 
showsignals = input(true, title="Show BUY/SELL Signals")
showcandlecolors = input(true, title="Show Candle Colors")
length = input(14, title="ADX Length")
smoothing = input(10, title="ADX Smoothing")
macdsource = input(close, title="MACD Source")
macdfast = input(12, title="MACD Fast Length")
macdslow = input(26, title="MACD Slow Length")
macdsignal = input(9, title="MACD Signal Length")
colorup = input(color.green, title="Up Candle Color")
colordown = input(color.red, title="Down Candle Color")
 
 
/////////////////////////////////////////////////////////////////////////////////////////////// ADX AND MACD CALC
[diplus, diminus, adx] = ta.dmi(length, smoothing)
 
[macdline, signalline, histline] = ta.macd(macdsource, macdfast, macdslow, macdsignal)
 
//////////////////////////////////////////////////////////////////////////////////////////////TRADE CALC
 
longcheck = diplus > diminus and macdline > signalline
shortcheck = diminus > diplus and signalline > macdline
 
int trade = 0
 
//Open from nothing
 
if trade == 0 and longcheck
    trade := 1
 
else if trade == 0 and shortcheck
    trade := -1
    
//Reversal
 
else if trade == 1 and shortcheck
    trade := -1
    
else if trade == -1 and longcheck
    trade := 1
    
//Keep status quo until crossover
 
else
    trade := trade[1]
 
//////////////////////////////////////////////////////////////////////////////////////////////PLOT 
 
colors = longcheck ? colorup : shortcheck ? colordown : color.white
 
plotcandle(open, high, low, close, color = showcandlecolors ? colors : na)
 
plotshape(trade[1] != 1 and trade == 1 and showsignals, style=shape.labelup, text='BUY', textcolor=color.white, color=color.green, size=size.small, location=location.belowbar)
plotshape(trade[1] != -1 and trade == -1 and showsignals, style=shape.labeldown, text='SELL', textcolor=color.white, color=color.red, size=size.small, location=location.abovebar)
 
///////////////////////////////////////////////////////////////////////////////////////////// ALERTS
 
alertcondition(trade[1] != 1 and trade == 1, "LONG")
alertcondition(trade[1] != -1 and trade == -1, "SHORT")

← 返回列表