hi, how to write code like this?

 

hi, I am just a beginner I need some help.
one simple code request 

 I tried to write it but fail, I am not sure how to write it.

here is  concept 



if (Close[0]>Close[1]>Close[2])
{
//show signal on chart
}

possible to show signal for 500 bars.

 

thanks in advance

 

.
 

You need to break the code up, as I don't think you want what you have written. I think this is what you mean:

if (Close[0]>Close[1] && Close[1]>Close[2])
{
//show signal on chart
}

 

What you have written means something quite different: if (Close[0]>Close[1]>Close[2])

 

If Close[0] is greater than Close[1], the first bit will evaluate as true (which is numerically represented as 1)

This means you are actually asking if 1 is greater than Close[2].

 

If Close[0] is less than or equal to Close[1], the first bit will evaluate as false (which is numerically represented as 0)

This means you are actually asking if 0 is greater than Close[2].

 

You would get a warning about the above code (unsafe use of bool) 


 
honest_knave: What you have written means something quite different: if (Close[0]>Close[1]>Close[2])
Exactly. true = 1 and false = 0 so you get
if( 3 < 2 < 1 )
if( false < 1 )
if(     0 < 1 )
if(     true  )
if( 3 > 2 > 1 )
if(  true > 1 )
if(     1 > 1 )
if(     false )
Reason: