The strategy is pretty simple:
1. buy when we get 2 new consecutive parabolic SAR dots below price.
2. sell short when we get 2 consecutive parabolic SAR dots above price.
The idea of buying/selling short is to use the second consecutive dot as a confirmation of trend change.
If anybody can help me, I will really appreciate it. Thanks for your time!!
Need help to create a parabolic SAR strategy
-
- Posts: 33
- Joined: 12 Mar 2015
- Has thanked: 4 times
Re: Need help to create a parabolic SAR strategy
Here's a basic version of what you described.
If two consecutive bars closes are ABOVE the parabolic SAR on those bars, AND the bar previous to the to has a close BELOW it's parabolic SAR, then we buy at market on the next bar.
Opposite for short.
I added the test for the 3rd bar to ensure that this doesn't take a signal in the middle of a sequence of closes > SAR or vice-vers.
Hope this helps.
If two consecutive bars closes are ABOVE the parabolic SAR on those bars, AND the bar previous to the to has a close BELOW it's parabolic SAR, then we buy at market on the next bar.
Opposite for short.
I added the test for the 3rd bar to ensure that this doesn't take a signal in the middle of a sequence of closes > SAR or vice-vers.
Hope this helps.
Code: Select all
inputs:
AfStep( 0.02 ), AfLimit( 0.2 ) ;
variables:
parsar(0), var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 ) ;
parsar = ParabolicSAR( AfStep, AfLimit, var0, var1, var2, var3 ) ;
if BarNumber > 2 then begin
if close > var0 and close[1] > var0[1] and close[2] < var0[2] then
buy next bar at market;
if close < var0 and close[1] < var0[1] and close[2] > var0[2] then
sellshort next bar at market;
end;