Hi saji!
Your Indicator works as defined.
You want two lines. One with hights and one wits lows. Thats what you got.
You have to specify what shall be done, if the trend changes. And then implement it.
eddie
Hello saji,
Whenever you get a change in trend, both HighBuffer and LowBuffer will need the same value. That way you will have a continuous line.
honest_knave: Whenever you get a change in trend, both HighBuffer and LowBuffer will need the same value. That way you will have a continuous line.
if(TrendCondition[shift] == 1) { HighBuffer[shift] = 0; LowBuffer[shift] = Low[shift]; } | if(TrendCondition[shift] == 1) { HighBuffer[shift] = HighBuffer[shift+1] != 0 ? Low[shift] : 0; LowBuffer[shift] = Low[shift]; } |
honest_knave:
Hello saji,
Whenever you get a change in trend, both HighBuffer and LowBuffer will need the same value. That way you will have a continuous line.
WHRoeder:
thank you, guys
it's exactly what you say! After I change my code, i got the right result:
the code is below:
//------TrendLine Value Calculation if(TrendCondition[shift] == 1) { if(TrendCondition[shift+1] == 1) //UpWard { HighBuffer[shift] = 0; LowBuffer[shift] = Low[shift]; } else if(TrendCondition[shift+1] == 2) //DownWard to UpWard { HighBuffer[shift] = Low[shift]; LowBuffer[shift] = Low[shift]; } } else if(TrendCondition[shift] == 2) { if(TrendCondition[shift+1] == 2) //DownWard { HighBuffer[shift] = High[shift]; LowBuffer[shift] = 0; } else if(TrendCondition[shift+1] == 1) //UpWard to DownWard { HighBuffer[shift] = High[shift]; LowBuffer[shift] = High[shift]; } }
Most probably will repaint when the value changes.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,All:
I just finish a trendline indicator. The logic is quite simple:
I make a judgement of the current market trendcondition( up or down ) ;
then if it's UP, the line value is current bar's LOW;
if it's DOWN, the line value is current bar's HIGH;
AND i want to use different color for it's trendline display, just like the HMA line below:
but what i got is below:
You can see that the trendline is not continous when the trendcondition change!
the code for trendline value is below:
And I have check the relevant code of HMA indicator, it use the same logic......
Can anyone help?
saji