A question about Indicator Lines displaying

Back to topics list To post a new topic, please log in or register
avatar
54
saji 2015.02.07 16:17
 

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:

hma

but what i got is below:

my  

You can see that the trendline is not continous when the trendcondition change!

the code for trendline value is below: 

      if(TrendCondition[shift] == 1)
      {
         HighBuffer[shift] = 0;
         LowBuffer[shift] = Low[shift];
      }
      else if(TrendCondition[shift] == 2)
      {
         HighBuffer[shift] = High[shift];
         LowBuffer[shift] = 0;
      }

And I have check the relevant code of HMA indicator, it use the same logic......

Can anyone help?

 saji 

avatar
108
eddie 2015.02.07 16:41 #
 

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

avatar
735
honest_knave 2015.02.07 17:04 #
 

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.

avatar
12985
WHRoeder 2015.02.07 20:40 #
 
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];
      }

avatar
54
saji 2015.02.08 07:00 #
 
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:

right 

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];
         }
      }      

 

avatar
1211
deysmacro 2015.02.08 07:26 #
 
Most probably will repaint when the value changes.
Back to topics list  

To add comments, please log in or register