TUE ADX/MACD Confluence For ThinkOrSwim

Please can anyone Convert tv free indicator to TOS

TUE ADX/MACD Confluence V1.0
https://www.tradingview.com/v/A37vsAuW/
check the below

CSS:
#// 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
#indicator("TUE ADX/MACD Confluence V1.0", overlay=true)
# Converted by Sam4Cok@Samer800    - 07/2023
input showSignals = yes;        # "Show BUY/SELL Signals")
input showCandleColors = yes;   # "Show Candle Colors")
input adxLength = 14;           #, title="ADX Length")
input adxSmoothing = 10;        #, title="ADX Smoothing")
input macdSource = close;       #, title="MACD Source")
input macdFastLength = 12;      #, title="MACD Fast Length")
input macdSlowLength = 26;      #, title="MACD Slow Length")
input macdSignalLength = 9;     #, title="MACD Signal Length")

#// ADX AND MACD CALC
def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = WildersAverage(TrueRange(high, close, low), adxLength);
def diplus = 100 * WildersAverage(plusDM, adxLength) / ATR;
def diminus = 100 * WildersAverage(minusDM, adxLength) / ATR;
def DX = if (diplus + diminus > 0) then 100 * AbsValue(diplus - diminus) / (diplus + diminus) else 0;
def ADX = WildersAverage(DX, adxSmoothing);

def macdline = ExpAverage(macdsource, macdfastLength) - ExpAverage(macdsource, macdslowLength);
def signalline = ExpAverage(macdline, macdsignalLength);

#//TRADE CALC

def longcheck = diplus > diminus and macdline > signalline;
def shortcheck = diminus > diplus and signalline > macdline;

def trade;
#//Open from nothing
if trade[1] == 0 and longcheck {
    trade = 1;
} else
if trade[1] == 0 and shortcheck {
    trade = -1;
} else
if trade[1] == 1 and shortcheck {
    trade = -1;
} else
if trade[1] == -1 and longcheck {
    trade = 1;
} else {
    trade = trade[1];
}

#/PLOT
def colors = if longcheck then 1 else if shortcheck then -1 else 0;
AssignPriceColor(if !showcandlecolors then Color.CURRENT else
                 if colors>0 then Color.GREEN else
                 if colors<0 then Color.RED else Color.GRAY);

AddChartBubble(trade[1] != 1 and trade == 1 and showsignals,low, "BUY", color.green, no);
AddChartBubble(trade[1] != -1 and trade == -1 and showsignals, high, "SELL", color.red, yes);

#-- END OF CODE
 
so much thankful to you..is there a way to convert mtf ?
check below

CSS:
#// 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
#indicator("TUE ADX/MACD Confluence V1.0", overlay=true)
# Converted by Sam4Cok@Samer800    - 07/2023
# MTF option added by Sam4Cok@Samer800
input useChartTimeframe = {Default "Yes", "No"};
input manualTimeframe   = AggregationPeriod.FIFTEEN_MIN;
input showSignals = yes;        # "Show BUY/SELL Signals")
input showCandleColors = yes;   # "Show Candle Colors")
input adxLength = 14;           #, title="ADX Length")
input adxSmoothing = 10;        #, title="ADX Smoothing")
input macdSource = close;       #, title="MACD Source")
input macdFastLength = 12;      #, title="MACD Fast Length")
input macdSlowLength = 26;      #, title="MACD Slow Length")
input macdSignalLength = 9;     #, title="MACD Signal Length")

def l; def c; def h; def macdSrc;
Switch (useChartTimeframe) {
Case "Yes" :
    macdSrc = macdSource;
    l = low;
    c = close;
    h = high;
Case "No" :
    macdSrc = close(Period=manualTimeframe);;
    l = low(Period=manualTimeframe);
    c = close(Period=manualTimeframe);
    h = high(Period=manualTimeframe);
}
#// ADX AND MACD CALC
def hiDiff = h - h[1];
def loDiff = l[1] - l;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = WildersAverage(TrueRange(h, c, l), adxLength);
def diplus = 100 * WildersAverage(plusDM, adxLength) / ATR;
def diminus = 100 * WildersAverage(minusDM, adxLength) / ATR;
def DX = if (diplus + diminus > 0) then 100 * AbsValue(diplus - diminus) / (diplus + diminus) else 0;
def ADX = WildersAverage(DX, adxSmoothing);

def macdline = ExpAverage(macdSrc, macdfastLength) - ExpAverage(macdSrc, macdslowLength);
def signalline = ExpAverage(macdline, macdsignalLength);

#//TRADE CALC

def longcheck = diplus > diminus and macdline > signalline;
def shortcheck = diminus > diplus and signalline > macdline;

def trade;
#//Open from nothing
if trade[1] == 0 and longcheck {
    trade = 1;
} else
if trade[1] == 0 and shortcheck {
    trade = -1;
} else
if trade[1] == 1 and shortcheck {
    trade = -1;
} else
if trade[1] == -1 and longcheck {
    trade = 1;
} else {
    trade = trade[1];
}

#/PLOT
def colors = if longcheck then 1 else if shortcheck then -1 else 0;
AssignPriceColor(if !showcandlecolors then Color.CURRENT else
                 if colors>0 then Color.GREEN else
                 if colors<0 then Color.RED else Color.GRAY);

AddChartBubble(trade[1] != 1 and trade == 1 and showsignals,low, "BUY", color.green, no);
AddChartBubble(trade[1] != -1 and trade == -1 and showsignals, high, "SELL", color.red, yes);

#-- END OF CODE
 
Can you please make a scan for when the buy or sell condition is true within one bar?
I tried using the condition wizard for this but it doesnt give you any drop down options
I think i was able to replicate using MACD and DMI separately but was wondering if it could be done within this code as opposed to that. thanks!

As a follow up, here's how I think you'd do it using the DMI and MACD separately:
DMI()."DI-" crosses above DMI()."DI+" and MACDHistogram()."Diff" is less than or equal to 0
(Short/sell candidate example)

I'm wondering if the scan can be made using this indicator.

thanks
 
Last edited by a moderator:
Can you please make a scan for when the buy or sell condition is true within one bar?
I tried using the condition wizard for this but it doesnt give you any drop down options
I think i was able to replicate using MACD and DMI separately but was wondering if it could be done within this code as opposed to that. thanks!

As a follow up, here's how I think you'd do it using the DMI and MACD separately:
DMI()."DI-" crosses above DMI()."DI+" and MACDHistogram()."Diff" is less than or equal to 0
(Short/sell candidate example)

I'm wondering if the scan can be made using this indicator.

thanks
This scan is created to find the buy or sell bubble:
shared scan link: http://tos.mx/JRUJCrp Click here for --> Easiest way to load shared links
rcPuwwe.png
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
407 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top