Download MetaTrader 5
To add comments, please log in or register
Unable to find the right application? Order it!
ankityadav
208
ankityadav 2014.03.26 19:29 
 if(limit<=Xbars)
    {
     if(isCross)
      { 
        if(fastsma>=slowsma && fastsma>MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint )                                                      
         {
          DrawHorizontalLine("fastsma"+i,fastsma,color1,STYLE_DASH);
         }
        else if(fastsma<=slowsma && fastsma<MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint)
         {
         DrawHorizontalLine("slowsma"+i,slowsma,color2,STYLE_DASH);
        } 
    } 
Please find the code what i m trying to do is to print the horizontal lines when it is in xbars let say 50 bars and the lines which are Distancepips lets say 30 from above the market .I mtrying to do this code but having issue with it .IT showing only red lines dont why ??Can some body help me
JPS1
239
JPS1 2014.03.27 02:15  

Telling us it only draws red lines isn't helpful as we have no idea which is the red line here. The first or the second????

I have an idea what it could be, but posting it is useless if I don't know which is the red line (color1 or color2).


Tjipke de Vries
6298
Tjipke de Vries 2014.03.27 07:02  
ankityadav:
Please find the code what i m trying to do is to print the horizontal lines when it is in xbars let say 50 bars and the lines which are Distancepips lets say 30 from above the market .I mtrying to do this code but having issue with it .IT showing only red lines dont why ??Can some body help me


Then where do you check the values moment isCross happens

Print( )

This way you learn yourself to see what happens

Cross just happens now fastsma>=slowsma is that moment fastma also > Bid + DistancePips*mPoint ???

ankityadav
208
ankityadav 2014.03.27 08:50  
deVries:


Then where do you check the values moment isCross happens

Print( )

This way you learn yourself to see what happens

Cross just happens now fastsma>=slowsma is that moment fastma also > Bid + DistancePips*mPoint ???


HI thanks for your reply but what i m trying to do is i m printing the horizontal line at some cross happen.And you know there are so many lines will generate so i am filtering the criteria .first i m filtering with the bars as you see

1)if(limit<=Xbars )

2)And second I want to see those lines in the past which are greater than current market price Plus 10 pips .But it is not working as i have already attach the code above what condition i put so it works

IS this code is correct because it just go in to the else condition and showing only red lines can you help me ??

if(limit<=Xbars)// last 50 bars say the value of xbars=50 bars so it will show only the lines under fifty bars 
    {
     if(isCross)
      { 
        if(fastsma>=slowsma && fastsma>MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint )  //second criteria  I would like just too be drawn the lines that are  say  3000 points  away from the present market lines                                                
         {
          DrawHorizontalLine("fastsma"+i,fastsma,color1,STYLE_DASH);
         }
        else if(fastsma<=slowsma && fastsma<MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint)
         {
         DrawHorizontalLine("slowsma"+i,slowsma,color2,STYLE_DASH);
        } 
    } 
ankityadav
208
ankityadav 2014.03.27 08:54  
JPS:

Telling us it only draws red lines isn't helpful as we have no idea which is the red line here. The first or the second????

I have an idea what it could be, but posting it is useless if I don't know which is the red line (color1 or color2).


Hi thanks for your reply

HI thanks for your reply but what i m trying to do is i m printing the horizontal line at some cross happen.And you know there are so many lines will generate so i am filtering the criteria .first i m filtering with the bars as you see

1)if(limit<=Xbars )

2)And second I want to see those lines in the past which are greater than current market price Plus 10 pips .But it is not working as i have already attach the code above what condition i put so it works

IS this code is correct because it just go in to the else condition and showing only red lines can you help me ??
if(limit<=Xbars)// last 50 bars say the value of xbars=50 bars so it will show only the lines under fifty bars 
    {
     if(isCross)
      { 
        if(fastsma>=slowsma && fastsma>MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint )  //second criteria  I would like just too be drawn the lines that are  say  3000 points  away from the present market lines                                                
         {
          DrawHorizontalLine("fastsma"+i,fastsma,color1,STYLE_DASH);//yellow lines
         }
        else if(fastsma<=slowsma && fastsma<MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint)
         {
         DrawHorizontalLine("slowsma"+i,slowsma,color2,STYLE_DASH);//red line 
        } 
    } 
Keith Watford
Moderator
9543
Keith Watford 2014.03.27 09:43  

Now, we have absolutely no idea what value

+DistancePips*mPoint

equates to.

What we DO know is that we have probably all adopted the habit of writing code for a buy signal and then copying and pasting that code for a sell condition, intending to make the necessary adjustments. After all, it is often only that a > has to be substituted with a < or a + has to be changed to a -. But then we still manage not to check properly and then the code does not do as expected.

Not intended as a criticism as I am sure that we have all done it.

Probably you started with

if(limit<=Xbars)// last 50 bars say the value of xbars=50 bars so it will show only the lines under fifty bars 
    {
     if(isCross)
      { 
        if(fastsma>=slowsma && fastsma>MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint )  //second criteria  I would like just too be drawn the lines that are  say  3000 points  away from the present market lines                                                
         {
          DrawHorizontalLine("fastsma"+i,fastsma,color1,STYLE_DASH);//yellow lines
         }
       } 
    } 

Then you copied and pasted to save time and then made some changes

if(limit<=Xbars)// last 50 bars say the value of xbars=50 bars so it will show only the lines under fifty bars 
    {
     if(isCross)
      { 
        if(fastsma>=slowsma && fastsma>MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint )  //second criteria  I would like just too be drawn the lines that are  say  3000 points  away from the present market lines                                                
         {
          DrawHorizontalLine("fastsma"+i,fastsma,color1,STYLE_DASH);//yellow lines
         }
        else if(fastsma<=slowsma && fastsma<MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint)
         {
         DrawHorizontalLine("slowsma"+i,slowsma,color2,STYLE_DASH);//red line 
        } 
    } 

Now you remembered to make the highlighted changes, but I guess that you totally missed

+DistancePips*mPoint
ankityadav
208
ankityadav 2014.03.27 10:31  
HI thanks for your reply but i don't understand what you are telling i just want to look back and filtered out the horizontal lines which are 30 pips say away from the market i don't understand hw to get this can you let me know what i change in the code so that i can get the lines which are 30 pips away from the current value of the market ??
Keith Watford
Moderator
9543
Keith Watford 2014.03.27 11:40  
ankityadav:
HI thanks for your reply but i don't understand what you are telling i just want to look back and filtered out the horizontal lines which are 30 pips say away from the market i don't understand hw to get this can you let me know what i change in the code so that i can get the lines which are 30 pips away from the current value of the market ??

Then read my post properly and then you will understand.
Keith Watford
Moderator
9543
Keith Watford 2014.03.28 20:21  

Ok.

The logic is not logical. Assuming that DistancePips*mPoint is equivalent to 30 pips

(fastsma>MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint)

for the above condition to be true, the fastsma must be more than 30 pips above the bid price

But in this case

(fastsma<MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint) 

the condition is true as long as the fastsma is less than 30 pips above the bid price, equal to the bid or lower than the bid.

I really cannot believe that is your intention.

(fastsma<MarketInfo(Symbol(),MODE_BID)-DistancePips*mPoint) 

is more logical

ankityadav
208
ankityadav 2014.03.30 19:32  
GumRai:

Ok.

The logic is not logical. Assuming that DistancePips*mPoint is equivalent to 30 pips

for the above condition to be true, the fastsma must be more than 30 pips above the bid price

But in this case

the condition is true as long as the fastsma is less than 30 pips above the bid price, equal to the bid or lower than the bid.

I really cannot believe that is your intention.

is more logical


Hi it does work and already used that but what i m trying to do is to see the lines the past generated by filtering it what i want to that is whever the lines where they are printing must be yellow when they are say 30 pips or say10 pips away from the market so if this the condition when i set then the indicator will only show those lines which are 10 pips away from the market price so the condition for that is i think AMy be i was wrong but can you let me know if i want to make this then where i m going wrong ??

(fastsma>MarketInfo(Symbol(),MODE_BID)+DistancePips*mPoint)
Keith Watford
Moderator
9543
Keith Watford 2014.03.30 22:54  
ankityadav:

Hi it does work and already used that but what i m trying to do is to see the lines the past generated by filtering it what i want to that is whever the lines where they are printing must be yellow when they are say 30 pips or say10 pips away from the market so if this the condition when i set then the indicator will only show those lines which are 10 pips away from the market price so the condition for that is i think AMy be i was wrong but can you let me know if i want to make this then where i m going wrong ??


Is there a full stop or a comma in there?

Sorry, I cannot understand what you are asking.

/ /12
To add comments, please log in or register