Parabolic SAR Coding question

 

Hi,

Can anyone tell me why this code doesn't open orders? What is the wrong?

// Sell Order  

      if (Close[1]>get_Parabolic(0, 0.02, 0.2, 1)&&iClose(NULL,0,0)<get_Parabolic(0, 0.02, 0.2, 0)) return(2); // Sell

// Buy Order

      if (Close[1]<get_Parabolic(0, 0.02, 0.2, 1)&&iClose(NULL,0,0)>get_Parabolic(0, 0.02, 0.2, 0)) return(1); // Buy

 

Why not write OpenBuy( ) or OpenSell( ) instead of return(x) ... This is not important much as what is the return value of get_parabolic( ) function ...

I suggest,  

to write Comment("Get Parabolic Buy = ", get_Parabolic(0, 0.02, 0.2, 1)); after if( ) for Buy  order  ... and,

to write also Comment("Get Parabolic Sell = ", get_Parabolic(0, 0.02, 0.2, 1)); after if( ) for Sell  order

to see how things works inside the code to trace the error, if any !. 

You may be need to convert the output result to string using  DoubleToString( ) ... but it is not important for now. You just need to see numbers at this stage. 

 
Osama Shaban:

Why not write OpenBuy( ) or OpenSell( ) instead of return(x) ... This is not important much as what is the return value of get_parabolic( ) function ...

I suggest,  

to write Comment("Get Parabolic Buy = ", get_Parabolic(0, 0.02, 0.2, 1)); after if( ) for Buy  order  ... and,

to write also Comment("Get Parabolic Sell = ", get_Parabolic(0, 0.02, 0.2, 1)); after if( ) for Sell  order

to see how things works inside the code to trace the error, if any !. 

You may be need to convert the output result to string using  DoubleToString( ) ... but it is not important for now. You just need to see numbers at this stage. 

My problem is it ignore the value of iClose(NULL,0,0)<get_Parabolic(0, 0.02, 0.2, 0)) 

Is SAR calculate the value of current bar? Does the shift=0 in SAR calculate the value of live SAR?

 It is working fine if the condition applied on shift=1 0r 2, but when it =0 it ignore it.

by the way, I wrote Comment(DoubleToString(iClose(NULL,0,0),4)+ "  -----  " + DoubleToString(get_Parabolic(0, 0.02, 0.2, 0),4)); and it displayed the values and met the condition but the order not created.

Reason: