Scan Alert for MACD crossover below Zeroline in ThinkorSwim

rad14733

Well-known member
VIP
This code works... Whether the "within 2 bars" is required or not is subjective...

Ruby:
MACD()."Value" is greater than MACD()."Value"[1] within 2 bars
 

sshaniga

New member
VIP
@BenTen can you help to code an scanner and alert based on fast ATR (1.5 and 5 parameter values) and macd retrace (Below Code)

Code:
input fast = 12;
input slow = 26;
input length = 9;
input averageType = AverageType.EXPONENTIAL;

def M0 = MACD(fast, slow, length, averageType).Avg;
def M1 = MACD(fast, slow, length, averageType).Avg[1];
def M2 = MACD(fast, slow, length, averageType).Avg[2];
def M3 = MACD(fast, slow, length, averageType).Avg[3];
def M4 = MACD(fast, slow, length, averageType).Avg[4];
plot signalUp = M4>M3 and M3>M2 and M2>M1 and M0>M1;
plot signalDown = M4<M3 and M3<M2 and M2<M1 and M0<M1;
signalUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signalDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

V1HTJkd.jpg


Alert has to trigger only if the macd has crossed over and has gone is below (For short) or above (For long) the ATR line
 

rad14733

Well-known member
VIP
@Kingvt Are you simply looking for downtrend or specifically for downtrend related to the MACD...??? Using a Moving Average or simple comparison can determine downtrend... I use Moving Average... I'm sure we have several Trend indicators here in the forums... Mine triggers off my Moving Average Stack...

Give us more details and we'll go from there...

Until then something as simple as comparing close to close[1] or whatever barcount you want would suffice for scanning...
 

rad14733

Well-known member
VIP
@Kingvt How about something like the following... It can be tweaked to your needs... The code provided looks back two bars for downtrend...

Ruby:
MACD()."Value" is less than MACD()."Value"[1] and MACD()."Value"[1] is less than MACD()."Value"[2]
 

JP382

Member
I run 4 charts (1,2,5&15min) on any trade I take and I like using the MACD. I get distracted going through my list of the day seeing where things stand, where in some cases Ive actually missed entries for other stocks bc I was looking away checking the charts. I made this scanner to save time and from being distracted to alert me (like to add bells & whistles once its working reliably) when all 4 charts are in "sync" where the MACD is greater than the Signal but it's not working as you can see in the pics below.
If I just run any of these scans on their own I get a result, even just running the 5&15 together I got results sometimes but running all four fail. As you can see in the example the MACD was greater than the Signal in all 4 charts for SRNE but the scanner said no results!?

I had sporadic results running each timeframe on their own too, where I would pull a stock up it would be positive yet the scanner wasnt picking it up.

Also when I added this as a Watchlist it wouldnt produce any results, even though I was getting some sporadically when I would hit the scan button.

What am I doing wrong?

RJcfM59.png

fOq08Q5.png
 

rad14733

Well-known member
VIP
@JP382 How long is your watchlist...??? I monitor under 30 symbols and only trade a portion of those... The rest are just to get the feel of the market... On any given day I can easily come up with 4 - 6 symbols, minimum that are worth taking trades on, and sometimes multiple opportunities per day... As I've mentioned in other topics, I monitor a 4-up chart window set to 3m, 5m, 10m, and 15m... I also monitor a 30m chart and a 5m chart with additional indicators... Sometimes I may have a few more full panel charts up... I can monitor my watchlist, which has just a few Custom Watchlist Columns, and view a 5m, 10m, or 30m chart in the right panel... If a symbols shows promise I can check the 4-up chart window for additional information... Then I have anywhere from 3 - 5 Windows with my scalping setups for individual trades... This setup makes trading efficient... It has taken years to refine the setup to my needs... All I can say is it works for me and has garnered the attention of several members here as well as customer/friends who also trade... I can post images here if you'd like to see my overall setup or you can contact me on the Discord Channel... Perhaps we can refine your system to suit your needs...
 

jraharris89

New member
Hello, so you know the MACD histogram how it has 4 colors by default? Green, Darker Green, Red, and Darker red.

So i'm wondering if theres a way to setup a scanner to detect the first darker red bar of the MACD Histogram (beginning of reversal). In the attached pic it would be the fourth bar in on the right side.
-Thanks in advance

https://ibb.co/0fS6GY4
 

rad14733

Well-known member
VIP
@jraharris89 You might as well get used to the fact that we don't scan for or code to look for colors because they are subjective... We code for "conditions" or "criteria", not "colors"... If there is logic to change colors then that is what you use... So, yes, it is possible... You just need to code your scan accordingly...
 

petech

Member
VIP
I've looked at many months of charts MACD crossover. In general the higher probability trade is to take the crossover heading away from the zero line. For the MACD crossover that is heading towards the zero line from afar, those are a crap shoot, sometimes they work great and sometimes they make you lose money. Are there any clues to which MACD crossover heading towards the zero line are higher probability trades?
 

Similar threads

Top