RSI oversold with macd cross strategy


Category:
0
0

Trying to make study to buy once the macd has a bullish cross, but only if the RSI was recently oversold in the last few candles. It would be nice the reverse the position once its overbought too.

Thanks Pete!

Marked as spam
Posted by (Questions: 10, Answers: 14)
Asked on March 4, 2017 2:31 pm
825 views
0

You used the word study in your question, but this is posted to the Strategy Guide topic so I will treat this as a Strategy question. Be sure to review this video: https://www.hahn-tech.com/thinkorswim-scan-macd-rsi-part-two/
It shows chart based study rather than a strategy. But if this does most of the grunt work for you it should be pretty simple to convert it to a strategy file.
And don’t forget we also published a video showing how to perform that conversion: https://www.hahn-tech.com/thinkorswim-scan-to-strategy/

( at March 4, 2017 3:20 pm)
0

I meant strategy* sorry thanks

( at March 4, 2017 4:33 pm)
0

The RSI part 2 uses pivots on the MACD histogram, I would like to only get alerts when the MACD crosses. I tried changing your
def pivotLowMACD = Diff > Diff[1] and Diff[1] > Diff[2] and Diff[2] < Diff[3] and Diff[3] < Diff [4]; def pivotHighMACD = Diff < Diff[1] and Diff[1] < Diff[2] and Diff[2] > Diff[3] and Diff[3] > Diff[4];
to
#def pivotHighMACD = slowLength crosses above fastLength;
#def pivotLowMACD = slowLength crosses below fastLength;

but no luck.
Thanks for your help! Im just starting to learn ?

( at March 4, 2017 5:04 pm)
0

First error is you are using inputs for your condition. Inputs are not plots. They are fixed values and will never cross.
Beside that, you had them backwards. (not picking on you, just pointing out important details)
You only need the histogram of the MACD to do this. Histogram is defined in that code as ”Diff”. When the histogram crosses the zero line, the fast and slow lines of the MACD are also crossing.
So:
def crossAbove = Diff[1] < 0 and Diff > 0;
def crossBelow = Diff[1] > 0 and Diff < 0; In your strategy, replace pivotLowMACD with crossAbove and replace pivotHighMACD with crossBelow.

( at March 4, 2017 6:35 pm)