RSIcrossover


Category:
0
0

Hello,

I have a strategy and I am trying to find a way to write a code that can achieve a simple thing: the strategy should *not* open a short trade if the RSIcrossover happened at the same time (or within a certain number of bars).

The problem is that I do not know what values the study “RSIcrossover” takes. If it was a normal study (say a MovingAverage) I add something like this to my code: “and MovingAverage >30” if 30 was the desired threshold.

However, how can I do it with the RSIcrossover (which on my chart shows up as an arrow at the bottom of the bar for the crossing “above” option)? Is there a way?

Many thanks,

RT

Marked as spam
Posted by (Questions: 7, Answers: 6)
Asked on January 5, 2017 12:30 pm
391 views
0

I have found with the TOS system you can only have one crossing type in one script. So you would have to add a second rsi cross over study and select cross over type to below and adjust the threshold value to 70. 70 is considered
to be overbought. But don’t act on that signal alone as you would want to look for a divergence. You can also use
a reversal oscillator for confirmation like the fisher transform. I hope that helps reach your trade idea goal. Kevin

( at January 6, 2017 5:24 pm)
0
Private answer

Note: You state you are working on a “Strategy” yet you have posted this question under the “Chart Studies” topic. Let me know if this needs to be moved to the “Strategy Guide” topic.

Lacking  a screenshot, or an example of the code you are building, I have to take a stab at this and hope I am close to understanding your question. It seems like you want to incorporate the behavior of RSICrossover into your strategy. The RSICrossover is a built-in study provided by Thinkorswim. Have you taken a look at the code for that study? It has an input called ‘threshold’. It has another input called ‘crossingType’. You should be able to copy and paste this into whatever code you are building and then simply set the parameters as needed. Then you have a plot called ‘signal’. This is a true/false condition that you can plug into your AddOrder() statement to block orders if signal == true. (AddOrder assumes you are working on a Strategy and not a Study).

For reference, I have included the original code from the RSICrossover built in study:

#
# TD Ameritrade IP Company, Inc. (c) 2009-2016
#

#wizard text: RSI crosses
#wizard input: crossingType
#wizard input: threshold
#wizard text: Inputs: length:
#wizard input: length
#wizard text: average type:
#wizard input: averageType

input length = 14;
input crossingType = {default above, below};
input threshold = 30;
input averageType = AverageType.WILDERS;

plot signal = crosses(RSI(length=length, averageType=averageType).RSI, threshold, crossingType == CrossingType.above);

signal.DefineColor(“Above”, GetColor(7));
signal.DefineColor(“Below”, GetColor(8));
signal.AssignValueColor(if crossingType == CrossingType.above then signal.color(“Above”) else signal.color(“Below”));

signal.SetPaintingStrategy(if crossingType == CrossingType.above
then PaintingStrategy.BOOLEAN_ARROW_UP
else PaintingStrategy.BOOLEAN_ARROW_DOWN);

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on January 5, 2017 12:55 pm
0
Private answer

Pete,

As usual you’re GREAT! Many many thanks (for both replies to my questions)!

Marked as spam
Posted by (Questions: 7, Answers: 6)
Answered on January 5, 2017 2:46 pm
0

I saw your answer on the RSICrossover post. Glad I was able to help.
For the benefit of future visitors, it would be really great if you would also answer back on the other post.
But most importantly of all, if you could “up-vote” my answers to each question this will help future visitors see that the question was answered.

Thanks for your assistance in this matter. Best of luck in your trading!

( at January 5, 2017 3:03 pm)