Parabolic Sar Trading Strategy (Amibroker And Tradestation Code)

The original article can be found here.

The logic in plain English strategy 1:

  • When the Parabolic Sar crosses above the close, we go long.
  • When the close crosses above the Parabolic Sar, we sell our position.

Amibroker code:

Buy = Cross(SAR(.02,.2),Close);
BuyPrice=Close;
Sell = Cross(Close,SAR(0.02,.2));
SellPrice= Close;

The logic in plain English strategy 2:

  • When the close crosses above the Parabolic Sar, we buy at the close.
  • When the Parabolic Sar crosses above the close, we sell at the close.

Amibroker code:

Buy = Cross(Close,SAR(0.02,.2));
BuyPrice=Close;
Sell = Cross(sAR(.02,.2),Close) ;
SellPrice= Close;

Tradestation code:

{
Strategy 132A - parabolic SAR
When the Parabolic Sar crosses above the close, we go long.
When the close crosses above the Parabolic Sar, we sell our position.
}

Inputs:
	AfStep(0.02),
	AfLimit(0.2);
	
Vars:
	int ret(0),
	double oParCl(0),
	double oParOp(0),
	double oPosition(0),
	double oTransition(0);

ret = ParabolicSAR(AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition);

if oParCl cross over Close then buy this bar on close;

if oParCl cross under Close then sell this bar on close;




-----------------------------------------------------------------------------


{
Strategy 132B - parabolic SAR
When the close crosses above the Parabolic Sar, we buy at the close.
When the Parabolic Sar crosses above the close, we sell at the close.
}

Inputs:
	AfStep(0.02),
	AfLimit(0.2);
	
Vars:
	int ret(0),
	double oParCl(0),
	double oParOp(0),
	double oPosition(0),
	double oTransition(0);

ret = ParabolicSAR(AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition);

if oParCl cross under Close then buy this bar on close;

if oParCl cross over Close then sell this bar on close;