Problem in drawing the horizantal line

 
HI,Can some solve my problem please find the attach .Actaully what i m trying to do is to print the horizontal line and if you see the image it does print the line but i want to print the line on the same point when cross occur and another thing and also i don't want lines when there is no cross if you see there is line happenning whenever there is no cross occur so i have to remove that thing also can somebody help me to solve this issues
 
 
ankityadav: need a horizontal lines when ever the two line crosses each other a
     if(fastsma>=slowsma)
You check for fast above or below slow, not a cross of fast and slow
    double fastsma=iBands(NULL,0,InpFastSMA,Inpdev,0,PRICE_CLOSE,MODE_SMA,limit);
    double slowsma =iBands(NULL,0,InpSlowSMA,Inpdev,0,PRICE_CLOSE,MODE_SMA,limit);
    ExtBuffer1[limit]=fastsma;
    ExtBuffer2[limit]=slowsma;
     if(fastsma>=slowsma)
You want a line when they cross.
    double fastsma=iBands(NULL,0,InpFastSMA,Inpdev,0,PRICE_CLOSE,MODE_SMA,limit); 
    double slowsma =iBands(NULL,0,InpSlowSMA,Inpdev,0,PRICE_CLOSE,MODE_SMA,limit);
    ExtBuffer1[limit]=fastsma;                                                    
    ExtBuffer2[limit]=slowsma;                                                    

    double fastPre=iBands(NULL,0,InpFastSMA,Inpdev,0,PRICE_CLOSE,MODE_SMA,limit+1),
           slowPre=iBands(NULL,0,InpSlowSMA,Inpdev,0,PRICE_CLOSE,MODE_SMA,limit+1);
    bool wasAbove = fastPre > slowPre,
          isAbove = fastsma > slowsma,
         isCross = wasAbove != isAbove;
  if(isCross){                 test for a cross
     if(fastsma>=slowsma)                                                         
      :
//   else if(fastsma<=slowsma) unnecessary test removed
     else
      :
  }
 

: Hi Thanks for your valuable answer i will use it and get back to you and again very thankful for you . Yes i did a mistake and thanks for your concern again again thankfull to you WHRoeder

 
: HI its working thanks again but can you let me know if i want to show lines depending upon bars let say there were 100 bars and i want to see only lines in past 50 bars what i need to use.ThanksWHRoeder
 
ankityadav: i want to see only lines in past 50 bars what i need to use.T
a trend line instead of a hline
Reason: