Parabolic SAR Coding question

45
2016.01.09 22:46

Hi,

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

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

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

1463
2016.01.09 23:23

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.

45
2016.01.10 00:04
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.