I've amended (LPrice>LLPrice) , should the (HPrice>HHPrice) sign be amended?
No. When checking whether a value is greater than max, always use >. Conversely, when checking whether a value is smaller than min, always use <. And HHPrice is the max, LLPrice is the min.
I don't know... I've tested already, should work. Anyway, I've attached my full code with both uptrend and downtrend - see if it differs from yours.
Seng,
Thank you very much it works , l did scratch my head quite a lot on this problem...... One more final question:
If for example I want to to recall the retracement for the past 15 candles, should i leave the -1 on the oninit( or onstart on your code) like below and on my code just use 1? Do I need to use -1 on both?
double Result = 0;
Result = FindBiggestRetracement(15,-1);
and on my code....
double RETRACE = FindBiggestRetracement(15, 1);
Thank you very much it works , l did scratch my head quite a lot on this problem...... One more final question:
If for example I want to to recall the retracement for the past 15 candles, should i leave the -1 on the oninit( or onstart on your code) like below and on my code just use 1? Do I need to use -1 on both?
The 1 or -1 here represents the trend direction.
Or if you don't want to have to tell the function which direction the trend is heading, you can modify the function to determine based on a moving average, for example.
Seng Joo Thio: The 1 or -1 here represents the trend direction.
Or if you don't want to have to tell the function which direction the trend is heading, you can modify the function to determine based on a moving average, for example.
Ok to determine the trend drawdown in 15 bars, in uptrend or downtrend i've used this code further down within ontick:
double TRENDUP = FindBiggestRetracement(15, 1);// Trend up drawdowndouble TRENDDOWN = FindBiggestRetracement(15, -1);//Trend down drawdown
I've amended (LPrice>LLPrice) , should the (HPrice>HHPrice) sign be amended?
Seng,
I'm sorry, The function is now returning 0.0 for downtrend throughout, what is wrong?
Seng,
I'm sorry, The function is now returning 0.0 for downtrend throughout, what is wrong?
Here's the error:
if (LPrice<LLPrice && LLPrice!=0 && InRetracement) { InRetracement = false; LLPrice = 0; double CurrRetracement = iHigh(NULL,0,HighBars[ArrayIdx])-iLow(NULL,0,LowBars[ArrayIdx]); if (CurrRetracement>MaxRetracement || MaxRetracement==0) MaxRetracement = CurrRetracement; ArrayIdx++; }Should change to HHPrice = 0;
Here's the error:
Should change to HHPrice = 0;
There is still a problem with this function, returns o. Could it be this: if (Direction<0)?
There is still a problem with this function, returns o. Could it be this: if (Direction<0)?
I don't know... I've tested already, should work. Anyway, I've attached my full code with both uptrend and downtrend - see if it differs from yours.
I don't know... I've tested already, should work. Anyway, I've attached my full code with both uptrend and downtrend - see if it differs from yours.
Seng,
Thank you very much it works , l did scratch my head quite a lot on this problem...... One more final question:
If for example I want to to recall the retracement for the past 15 candles, should i leave the -1 on the oninit( or onstart on your code) like below and on my code just use 1? Do I need to use -1 on both?
Seng,
Thank you very much it works , l did scratch my head quite a lot on this problem...... One more final question:
If for example I want to to recall the retracement for the past 15 candles, should i leave the -1 on the oninit( or onstart on your code) like below and on my code just use 1? Do I need to use -1 on both?
The 1 or -1 here represents the trend direction.
Ok to determine the trend drawdown in 15 bars, in uptrend or downtrend i've used this code further down within ontick:
Is this ok?
Ok to determine the trend drawdown in 15 bars, in uptrend or downtrend i've used this code further down within ontick:
Is this ok?
Yes.