Profile Picture

How to code for a MACD Crossover after it has reached some strength?

Posted By sudharsanv 7 Years Ago

How to code for a MACD Crossover after it has reached some strength?

Message
Posted Tuesday February 09 2010
Hi,
I am new to RightEdge Trading System and its built in Indicators. I am just getting started . I would like to know if there is a way, I can code for an Entry Position, after a MACD CrossOver based on the condition that MACD.Diff shold be greater than 0.1. In other words, I don't want to enter immediately on crossover but after MACD.Dif reaches 0.1 or higher.
Please help me out on how I can achieve this.
Thanks,
Sudharsan
Posted Tuesday February 09 2010
I assume the diff is between 1 period? So you would have MACD.Current and MACD.LookBack(1). Then it would be a simple comparison ... something like.

if (MACD.Current - MACD.LookBack(1) > 0.1)
{
OpenPosition
}

sudharsanv (2/9/2010)
Hi,
I am new to RightEdge Trading System and its built in Indicators. I am just getting started . I would like to know if there is a way, I can code for an Entry Position, after a MACD CrossOver based on the condition that MACD.Diff shold be greater than 0.1. In other words, I don't want to enter immediately on crossover but after MACD.Dif reaches 0.1 or higher.
Please help me out on how I can achieve this.
Thanks,
Sudharsan
Posted Tuesday February 09 2010
Hi bilb,
Thank you. But how to combine it with the MACDCrossOver condition?.
I don't want to check for MACD CrossOver on each and every bar. Suppose MACD crossover occurs at end of bar1. And suppose at end of bar4, the Macd.Diff reaches 0.1 or higher, I want to enter on open of bar5.
I am understanding yor IF code to mean, test the strength of MACD.Diff() between any 2 consecutive bars. How to add the condition to this saying, test the strength but ONLY after a MACD Crossover has occurred?
Thanks,
Sudharsan.
Posted Wednesday February 10 2010
Then set a flag in your code. If the crossover occurs set your flag to true. Then when the difference reaches your threshold, open your position.

sudharsanv (2/9/2010)
Hi bilb,
Thank you. But how to combine it with the MACDCrossOver condition?.
I don't want to check for MACD CrossOver on each and every bar. Suppose MACD crossover occurs at end of bar1. And suppose at end of bar4, the Macd.Diff reaches 0.1 or higher, I want to enter on open of bar5.
I am understanding yor IF code to mean, test the strength of MACD.Diff() between any 2 consecutive bars. How to add the condition to this saying, test the strength but ONLY after a MACD Crossover has occurred?
Thanks,
Sudharsan.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems