Sar entry
Forums › ProRealTime English forum › ProOrder support › Sar entry
- This topic has 5 replies, 4 voices, and was last updated 2 years ago by maleczek.
-
-
02/01/2021 at 6:50 PM #160076
Hi
I have been trying to code a SAR entry with no success.
What I am after is after a set entry time the next change in SAR colour we enter a trade.
Eg at 0800 SAR is green and so no orders at that point. On the next reverse (red) we go short and vice a versa.
Is it then possible on the next reverse to enter as well? So for above SAR turns green and we go long.
So just the initial SAR colour is ignored at the start time of the algo
Many thanks for any guidance
02/01/2021 at 7:29 PM #160077There you go:
1234567891011121314151617DEFPARAM CumulateOrders = FALSEMySAR = SAR[0.02,0.02,0.2]Green = close > MySARRed = close < MySARChange = (Green AND Red[1]) OR (Green[1] AND Red)MyTime = 080000IF MyTime = 080000 THENChange = 0ENDIF// LONGIF Change AND Green AND Not LongOnMarket THENBUY 1 Contract AT MarketENDIF// SHORTIF Change AND Red AND Not ShortOnMarket THENSELLSHORT 1 Contract AT MarketENDIF02/02/2021 at 9:22 AM #160099Change from red to green (and vice-versa) with Parabolic SAR can be detected with Close CROSSES OVER or Close CROSSES UNDER.
1 user thanked author for this post.
03/24/2022 at 12:18 PM #190406Hello,
I have tried at length to develop another step to the SAR entry and have had no luck.
I am hoping fresh eyes could suggest a way forward :-
On a five minute timeframe I want to detect a change (crossover) in the SAR from Red to Green or vice versa … then in the bar of the change I want to be able to detect if the bar is the same colour as the SAR upon close (otherwise, say green SAE and red bar, it is ignored).
If it is the same colour I want to store the ‘HIGH’ value of the bar if it is green or the LOW value of the bar if ithe bar and SAR are red.
Over the following bars – until the next crossover – I want to check the ‘CLOSE’ of the bars to check if they are higher than the ‘HIGH’ if the bar of the crossover (if green) or lower than the ‘LOW’ of the first bar after the crossover if it was red (only one transaction – either BUY or SELLSHORT per inter SAR crossover).
If higher then I would like to BUY a contract as quickly as possible and correspondingly if lower than the stored low I would like to SELLSHORT a contract. When this happens there should be not be any further transactions till the after next crossover.
I hope this makes sense as I have spent days, if not weeks, playing around with MTF and ARRAYS to try and make it return a consistent result and have failed.
Thank you in anticipation,
Joe
03/24/2022 at 4:07 PM #190421There you go:
12345678910111213141516171819202122232425262728293031323334353637383940414243// MySystemSAR//// https://www.prorealcode.com/topic/sar-entry///ONCE Read = 1ONCE Green = 1ONCE ChangePrice = 0Bullish = close > openBearish = close < openMySAR = SAR[0.02,0.02,0.2]IF Red THENGreen = close CROSSES OVER MySARIF Green THENRed = 0ChangePrice = 0IF Bullish AND Not OnMarket THENChangePrice = highENDIFENDIFENDIFIF Green THENRed = close CROSSES UNDER MySARIF Red THENGreen = 0ChangePrice = 0IF Bearish AND Not OnMarket THENChangePrice = lowENDIFENDIFENDIFIF ChangePrice <> 0 AND Not OnMarket THENIF Green AND close > ChangePrice THENBUY 1 CONTRACT AT MARKETChangePrice = 0ENDIFIF Red AND close < ChangePrice THENSELLSHORT 1 CONTRACT AT MARKETChangePrice = 0ENDIFEND IFSET TARGET pPROFIT 300SET STOP pLOSS 100graphonprice ChangePrice1 user thanked author for this post.
03/25/2022 at 2:03 PM #190477Thank You,
I can see that was focussing on the crossover too much … very elegant code!
Thank you again,
Joe
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on