♥ 0 |
Hello Mr. Hahn, can you create a scanner in which the macd is being crossed for the first time in a range of time? Say 60 days or beyond? declare lower; input fastLength = 12; plot Value = MovingAverage(averageType, close, fastLength) – MovingAverage(averageType, close, slowLength); plot Diff = Value – Avg; plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN; UpSignal.SetHiding(!showBreakoutSignals); Value.SetDefaultColor(GetColor(1));
Marked as spam
|
Private answer
Ok, now that we’ve cleared up a minor detail I have the code ready to go. For those trying to learn from this, be sure to check out a previous post: https://www.hahn-tech.com/ans/how-to-filter-a-scan-for-the-d-crossing-the-d-on-the-dmi-for-the-first-time-in-many-periods/ Each of these solutions contain a technique for testing if a condition has been true over a specified period of time, excluding the current bar. This is what makes it all possible. It’s used right there in the very last line of code:
If you are trying to learn and you don’t understand how this works, just post a new question in the forum asking for an explanation. Otherwise, just copy the code below and get some use out of it:
Marked as spam
|
Please log in to post questions.
For a standard indicator included with Thinkorswim, there is no need to include the code in your post. Unless you have made an attempt at solving the problem and would like me to explain why your code doesn’t work.
So for this particular question, you simply want to scan for stocks that have not crossed the zero line, in either direction, for 60 or more days?
Yes, I need a scanner that shows the macd crossing for the first time in 60 days. Please
Sorry, forgot to ask which plot of the MACD you want to test. There are three. The MACD Value, the MACD Average, and the MACD Difference (histogram).
No worries, MACD average