NexusFi: Find Your Edge


Home Menu

 





ADX_DMI cross over arrow


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,228 views
    2. thumb_up 4 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 6 attachments




 
Search this Thread

ADX_DMI cross over arrow

  #1 (permalink)
 Lady 
Medellín, CO
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Playing with eMinis, coming from Options
Posts: 83 since Jun 2015
Thanks Given: 14
Thanks Received: 43

Can anyone help me with his? I want the indicator to plot an up or down arrow when ever the ADXAvg crosses ADX. And not a balloon but a print at the cross over location. Similar to the indicator picture below

declare lower;
input MACDfastLen = 10;
input MACDslowLen = 30;
input MACDLen = 10;
input showADX_DMI = { "No", default "Yes"};
input showMACD = { "No", default "Yes"};
input invertNegMACD = { "Yes", default "No"};
input MACDHeight = 50;
input MACDWidth = 3;
input ADX_Avg = 3;
input DMI_Len = 9;
input No_Trend = 20;
input Low_Trend = 45;
input Strong_Trend = 60;


def fastAvg = EMA2(data = close, "smoothing factor" = 2 / (1 + MACDfastLen));
def slowAvg = EMA2(data = close, "smoothing factor" = 2 / (1 + MACDslowLen));
def Value = fastAvg - slowAvg;
def nextAvg = ExpAverage(data = Value, MACDLen);
def HistoBar = Value - nextAvg[1];
def HiScale = HighestAll(HistoBar);
def LoScale = AbsValue(LowestAll(HistoBar));
def BarScale = if HiScale > LoScale then HiScale else LoScale;

plot macd_plot = If (showMACD, If( invertNegMACD, If ( HistoBar < 0, ( -1 * HistoBar * MACDHeight / BarScale ), ( HistoBar * MACDHeight / BarScale )), HistoBar * MACDHeight / BarScale), Double.NaN);

macd_plot.AssignValueColor(if invertNegMACD then if HistoBar >= 0 then Color.CYAN else Color.MAGENTA else Color.CYAN);
macd_plot.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
macd_plot.SetLineWeight(MACDWidth);

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), DMI_Len);
plot "DI+" =
if showADX_DMI then 100 * WildersAverage(plusDM, DMI_Len) / ATR
else Double.NaN;
plot "DI-" =
if showADX_DMI then 100 * WildersAverage(minusDM, DMI_Len) / ATR
else Double.NaN;
def DX =
if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-")
else 0;
plot ADX = if showADX_DMI then WildersAverage(DX, DMI_Len) else Double.NaN;
plot ADXAvg = if showADX_DMI then ExpAverage(ADX, ADX_Avg) else Double.NaN;
plot NoTrend = No_Trend;
plot LowTrend = Low_Trend;
plot StrngTrend = Strong_Trend;

plot ArrowUp = if ADXAvg crosses above ADX
then low
else double.nan;
ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
ArrowUP.SetLineWeight(3);
ArrowUP.SetDefaultColor(Color.Green);
plot ArrowDN = if ADXAvg crosses below ADX
then high
else double.nan;
ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
ArrowDN.SetLineWeight(3);
ArrowDN.SetDefaultColor(Color.Red);
Alert(ArrowUp, " ", Alert.Bar, Sound.Chimes);
Alert(ArrowDN, " ", Alert.Bar, Sound.Bell);

"DI+".SetDefaultColor(Color.GREEN);
"DI-".SetDefaultColor(Color.RED);
ADX.SetDefaultColor(Color.WHITE);
ADXAvg.SetDefaultColor(Color.YELLOW);

Attached Thumbnails
Click image for larger version

Name:	arrows.JPG
Views:	270
Size:	16.9 KB
ID:	271940   Click image for larger version

Name:	arrow 2.JPG
Views:	253
Size:	66.9 KB
ID:	271949   Click image for larger version

Name:	script.JPG
Views:	232
Size:	274.9 KB
ID:	271952   Click image for larger version

Name:	arrow 3.JPG
Views:	224
Size:	102.2 KB
ID:	271955  
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 kjhosken 
Seattle, WA/USA
 
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
Posts: 96 since Sep 2016
Thanks Given: 7
Thanks Received: 35


Lady View Post
Can anyone help me with his? I want the indicator to plot an up or down arrow when ever the ADXAvg crosses ADX. And not a balloon but a print at the cross over location. Similar to the indicator picture below

declare lower;
input MACDfastLen = 10;
input MACDslowLen = 30;
input MACDLen = 10;
input showADX_DMI = { "No", default "Yes"};
input showMACD = { "No", default "Yes"};
input invertNegMACD = { "Yes", default "No"};
input MACDHeight = 50;
input MACDWidth = 3;
input ADX_Avg = 3;
input DMI_Len = 9;
input No_Trend = 20;
input Low_Trend = 45;
input Strong_Trend = 60;


def fastAvg = EMA2(data = close, "smoothing factor" = 2 / (1 + MACDfastLen));
def slowAvg = EMA2(data = close, "smoothing factor" = 2 / (1 + MACDslowLen));
def Value = fastAvg - slowAvg;
def nextAvg = ExpAverage(data = Value, MACDLen);
def HistoBar = Value - nextAvg[1];
def HiScale = HighestAll(HistoBar);
def LoScale = AbsValue(LowestAll(HistoBar));
def BarScale = if HiScale > LoScale then HiScale else LoScale;

plot macd_plot = If (showMACD, If( invertNegMACD, If ( HistoBar < 0, ( -1 * HistoBar * MACDHeight / BarScale ), ( HistoBar * MACDHeight / BarScale )), HistoBar * MACDHeight / BarScale), Double.NaN);

macd_plot.AssignValueColor(if invertNegMACD then if HistoBar >= 0 then Color.CYAN else Color.MAGENTA else Color.CYAN);
macd_plot.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
macd_plot.SetLineWeight(MACDWidth);

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), DMI_Len);
plot "DI+" =
if showADX_DMI then 100 * WildersAverage(plusDM, DMI_Len) / ATR
else Double.NaN;
plot "DI-" =
if showADX_DMI then 100 * WildersAverage(minusDM, DMI_Len) / ATR
else Double.NaN;
def DX =
if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-")
else 0;
plot ADX = if showADX_DMI then WildersAverage(DX, DMI_Len) else Double.NaN;
plot ADXAvg = if showADX_DMI then ExpAverage(ADX, ADX_Avg) else Double.NaN;
plot NoTrend = No_Trend;
plot LowTrend = Low_Trend;
plot StrngTrend = Strong_Trend;

plot ArrowUp = if ADXAvg crosses above ADX
then low
else double.nan;
ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
ArrowUP.SetLineWeight(3);
ArrowUP.SetDefaultColor(Color.Green);
plot ArrowDN = if ADXAvg crosses below ADX
then high
else double.nan;
ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
ArrowDN.SetLineWeight(3);
ArrowDN.SetDefaultColor(Color.Red);
Alert(ArrowUp, " ", Alert.Bar, Sound.Chimes);
Alert(ArrowDN, " ", Alert.Bar, Sound.Bell);

"DI+".SetDefaultColor(Color.GREEN);
"DI-".SetDefaultColor(Color.RED);
ADX.SetDefaultColor(Color.WHITE);
ADXAvg.SetDefaultColor(Color.YELLOW);

Your code is calling out the high and the low of the underlying, not of the indicator, hence why you're getting floating arrows. One option is to assign the high and low mark to an arbitrarily number (ie. overbought, oversold). The other, similar to the first attachment you have, is delete the if/then parts of the statement. It should plot at the indiciator value

 
Code
plot ArrowUp = if ADXAvg crosses above ADX
               then 0
               else double.nan;
     ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
     ArrowUP.SetLineWeight(3);
     ArrowUP.SetDefaultColor(Color.Green);
plot ArrowDN = if ADXAvg crosses below ADX
               then 100
               else double.nan;
     ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
     ArrowDN.SetLineWeight(3);
     ArrowDN.SetDefaultColor(Color.Red);
Alert(ArrowUp, " ", Alert.Bar, Sound.Chimes);
Alert(ArrowDN, " ", Alert.Bar, Sound.Bell);
or

 
Code
plot ArrowUp = ADXAvg crosses above ADX;
     ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
     ArrowUP.SetLineWeight(3);
     ArrowUP.SetDefaultColor(Color.Green);
plot ArrowDN = ADXAvg crosses below ADX;
     ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
     ArrowDN.SetLineWeight(3);
     ArrowDN.SetDefaultColor(Color.Red);
Alert(ArrowUp, " ", Alert.Bar, Sound.Chimes);
Alert(ArrowDN, " ", Alert.Bar, Sound.Bell);

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 Lady 
Medellín, CO
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Playing with eMinis, coming from Options
Posts: 83 since Jun 2015
Thanks Given: 14
Thanks Received: 43


https://tos.mx/SV5YSHs

Attached Thumbnails
Click image for larger version

Name:	DMI.JPG
Views:	274
Size:	47.2 KB
ID:	279492  
Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 Lady 
Medellín, CO
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Playing with eMinis, coming from Options
Posts: 83 since Jun 2015
Thanks Given: 14
Thanks Received: 43

https://tos.mx/BeZ0Ywz

Attached Thumbnails
Click image for larger version

Name:	AAdx.JPG
Views:	232
Size:	66.5 KB
ID:	279495  
Started this thread Reply With Quote
Thanked by:




Last Updated on November 12, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts