Scan for DMI plus crosses DMI minus


Category:
0
0

Hello Mr. Hahn, I keep trying to get a scan searching when the dmi + crosses the dmi –

input length = 14;

input averageType = AverageType.WILDERS;

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 = MovingAverage(averageType, TrueRange(high, close, low), length);

plot “DI+” = 100 * MovingAverage(averageType, plusDM, length) / ATR;

plot “DI-” = 100 * MovingAverage(averageType, minusDM, length) / ATR;

def DX = if (“DI+” + “DI-” > 0) then 100 * AbsValue(“DI+” – “DI-“) / (“DI+” + “DI-“) else 0;

plot ADX = MovingAverage(averageType, DX, length);

“DI+”.SetDefaultColor(GetColor(1));

“DI-“.SetDefaultColor(GetColor(8));

ADX.SetDefaultColor(GetColor(5));

Marked as spam
Posted by (Questions: 6, Answers: 14)
Asked on June 2, 2017 1:47 am
597 views
0

Editor’s note: The title and URL of the question has been modified to make it easier for other viewers to search for and find this post. The original title has been moved to the first line of the question description.

( at June 2, 2017 8:01 am)
1
Private answer

It seems so strange to me that I still get questions about how to do these. I have done so many examples of lines crossing other lines that I figure by now you guys should be able to do this in your sleep. Code is listed here and a screenshot to show what it looks like using the Study Alert view.

input length = 14;
input averageType = AverageType.WILDERS;
input threshold = 20;
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 = MovingAverage(averageType, TrueRange(high, close, low), length);
def diPlus = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def diMinus = 100 * MovingAverage(averageType, minusDM, length) / ATR;
def DX = if (diPlus + diMinus > 0) then 100 * AbsValue(diPlus - diMinus) / (diPlus + diMinus) else 0;
def diPlusCrossesAbove = diPlus[1] < diMinus[1] and diPlus > diMinus;
def diPlusCrossesBelow = diPlus[1] > diMinus[1] and diPlus < diMinus;
# use this scan to check for DI+ crossing above DI-
plot scan = diPlusCrossesAbove;
# use this scan to check for DI+ crossing below DI-
#plot scan = diPlussCrossesBelow;

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on June 2, 2017 8:05 am
0

Thank you Mr. Hahn, its just that I am not the best at coding, I will continue to watch your videos so I can learn more about creating custom scans.

( at June 3, 2017 12:13 am)