Automated FTSE 5 MINUTE with PSAR indicator
Forums › ProRealTime English forum › ProOrder support › Automated FTSE 5 MINUTE with PSAR indicator
- This topic has 10 replies, 4 voices, and was last updated 2 years ago by robertogozzi.
-
-
11/16/2022 at 2:34 PM #204258
Hello All,
I have asked the forum a couple of questions over the years I have been using IG Index PRT and have always been met with helpfulness and creativity.
I now find myself with a strategy that works really well but requires sitting in front of the computer screen waiting for the dozen or so triggers each day as attempts to use alert services, including PRT’s own alerts didn’t pick up each trigger.
The strategy is based on the FTSE 5 minute chart and I have written and rewritten the code over 150 times and am questioning my own logic ability.
The simple strategy lends itself to automation but try as I might PRT doesn’t do what I thought it might and I can’t find documentation that explains why this happens.
With a FTSE 5 minute bar chart showing price and the PSAR indicator (see attached) starting at 08.00 GMT through to market close I am looking for the PSAR to cross over or cross under to signal the start of the strategy.
With the SAR going from red to green I am looking for the next bar to be green (updated on close) that is with close being higher than open.
With the SAR going from green to red The next bar needs to be red i.e. with the open price being higher than the close (likewise update on close).
The two other possibilities of green SAR and red bar as well as red SAR and green first bar on change do not qualify and the strategy will not start and we wait for the next SAR crossover.
Given that I get a RED SAR and RED BAR or a GREEN SAR and GREEN BAR the next step is to note threshold levels.
If the GREEN SAR has A GREEN BAR then the value of HIGH + 1 for that bar is noted – called it ‘loft’.
If the RED SAR has a RED BAR as then the value of LOW – 1 for that bar is noted – which I have called ‘dell’.
If subsequent bars do not exceed loft for GREEN/GREEN first bar or dell for a RED/RED first bar then nothing is done till next crossover and SAR/BAR.
If the loft value is met then a BUY is triggered with a TARGET of 10 and a STOP of 20.
If the dell value is met then a SELLSHORT is triggered with a TARGET of 10 and a STOP of 20.If the TARGET is not met then the BUY or SELLSHORT trade is closed at the next crossover.
So far straightforward – but BUY/SELLSHORT/EXIT etc. happen in the next bar by which time I am looking to open a new SAR/BAR loft or dell value.
Using TIMEFRAME I looked for SAR crossover in 5 minute TF and setting loft/dell in 5 minute Uupdate On Close and then using 20 second or less TF for BUY/SELL or EXIT.
I can’t make it work !!!!!!!Here’s a recent iteration of my code:
//FTSE SAR XOVER 5 min 20221110 1330
DEFPARAM CUMULATEORDERS = FALSE
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 160000daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0 // OR exchange holidays here once working
dealtime = (time>=140000 AND time=<200000) AND not daysforbiddenEntry
contractsize = 1//##################################################################
TIMEFRAME(3 minutes) // ##### 3-minutes bar OPEN #####
//##################################################################IF dealtime THEN
change = 0
gchange = 0
rchange = 0
mysar = SAR[0.02,0.02,0.2]
greensar = close > mySAR
redsar = close < mySAR
gchange = redsar[1] AND greensar
rchange = greensar[1] AND redsar
change = (redsar[1] AND greensar) OR (greensar[1] AND redsar)
ENDIF//##################################################################
TIMEFRAME(3 minutes,updateonclose) // ##### 3-minutes bar UOC #####
//##################################################################IF dealtime THEN
IF gchange AND NOT ONMARKET AND open >= close THEN
loft = HIGH + 4
ENDIFIF rchange AND NOT ONMARKET AND open =< close THEN
dell = LOW – 4
ENDIF
ENDIF//##################################################################
TIMEFRAME(default) // #### timeframe to place order quickly e.g. 20 sec #####
//##################################################################IF dealtime AND change AND ONMARKET THEN
SELL AT MARKET
EXITSHORT AT MARKET
ENDIFIF dealtime AND NOT ONMARKET THEN
IF gchange AND (HIGH >= loft) THEN
BUY contractsize CONTRACT AT MARKET
ENDIFIF rchange AND (LOW =< dell) THEN
SELLSHORT contractsize CONTRACT AT MARKET
ENDIFSET target $profit 40
SET stop ploss 80
ENDIFGRAPH gchange coloured(0,255,0)
GRAPH rchange coloured(255,0,0)
GRAPH change coloured(0,0,255)Any ideas please … I feel I should be able to do it but “I can’t see the wood for the trees” as the saying says.
11/16/2022 at 7:12 PM #204291Dear All,
I am so sorry, I entered crazy values.
“loft” should be HIGH + 1 (NOT +4 as shown)
“dell” should be LOW – 1 (NOT – 4 as shown)
Target should be 10 (NOT 40)
STOP should be 20 (NOT 80)
Apologies again but in my defense I’m just about getting over a bout of Covid.
Thank you
11/17/2022 at 9:23 AM #204307I can’t make it work !!!!!!!
What does ‘make it work’ mean … take trades or make profit?
I spent 20 mins or so on it last night and it takes trades, but almost all trades are losses.
I tried a few tweaks and optimising etc but still it was no go.
I then stripped out lots of ‘restrictions’ in the code and got it to take profitable trades, but with an unworkable equity curve.
My conclusion is that the basic strategy is flawed and you will save yourself a lot of time and frustration by archiving your code at this point. You can always come back to it later.
Choose one of the several PSAR based strategies in the Library and continue your efforts on a System that shows a profit and see if you can improve / make more profit / less drawdown etc.
Here is one that at a very quick first glance is similar to yours using Highs / Lows etc.
https://www.prorealcode.com/prorealtime-trading-strategies/breakout-sar-index-15m-djia-dax-pxi/
11/17/2022 at 10:50 AM #204311Thank you GraHal,
What I meant by “make it work” was make it work as if I was following the instructions but I will have a look at how others have addressed PSAR crossover trading and come back to it.
Thank you again
1 user thanked author for this post.
11/17/2022 at 2:15 PM #204331I was following the instructions
If you have instructions from another source then it might be best to post these ‘other instructions’ to see if anybody can code the strategy direct from that ‘other source of information’?
11/17/2022 at 2:26 PM #204333Apologies for any confusion, the ‘instructions’ I was referring to were those at the beginning of my first post.
So, if not automatic trading is there a way to set up my chart to alert me when the PSAR crosses over or crosses under as that would give me time to get to the screen and checkthe criteria manually and manually place trades?
That would free me from staring at the screen to spot a PSAR change.
Thank you again,
11/17/2022 at 2:50 PM #204335Yes use the email associated with the inbuilt PRT Alert function.
Only works if you use / send to the email address associated with the Account.
Also PRT has to be running (else Alert is not emailed).
You can even get the inbuilt Alert function to open an associated trade for you.
11/17/2022 at 2:52 PM #20433611/17/2022 at 2:57 PM #20433711/18/2022 at 5:15 PM #204398Hi @maleczek
Here is an earlier attempt to convert the SAR indicator into a trading system…
Maybe you can do something with it…
SAR System123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566DefParam CumulateOrders = Falseincrement = 0.02initial = 0.02limite = 0.2IF BARINDEX < 2 THENLparabolic = LOWislong = 1af = limitehp = HIGHlp = LOWELSEIF islong THENLparabolic = Lparabolic + af * (hp - Lparabolic)Lparabolic = MIN(Lparabolic, LOW[1])Lparabolic = MIN(Lparabolic, LOW[2])ELSESparabolic=Sparabolic + af * (lp - Sparabolic)Sparabolic=MAX(Sparabolic, HIGH[1])Sparabolic=MAX(Sparabolic, HIGH[2])ENDIFreverse = 0IF islong THENIF LOW < Lparabolic and Close < Open THENSellShort at (Low - 1 * pointsize) STOPSet Target pProfit 10Set Stop pLoss 20islong = 0reverse = 1Sparabolic = hplp = LOWaf = initialENDIFELSEIF HIGH > Sparabolic and Close >= Open THENBuy at (High + 1 * pointsize) STOPSet Target pProfit 10Set Stop pLoss 20islong = 1reverse =1Lparabolic = lphp = HIGHaf = initialENDIFENDIFIF NOT reverse THENIF islong THENIF HIGH > hp THENhp = HIGHaf = af + incrementaf = MIN (af,limite)ENDIFELSEIF LOW < lp THENlp = LOWaf = af + incrementaf = MIN (af,limite)ENDIFENDIFENDIFENDIF1 user thanked author for this post.
11/18/2022 at 7:11 PM #204403Post your topic in the correct forum:
_ ProRealTime Platform Support: platform related issues.
_ ProOrder: strategy topics.
_ ProBuilder: indicator topics.
_ ProScreener: screener topics
_ General Discussion: any other topic.
_ Welcome New Members: for new forum members to introduce themselves.I moced it from the ProBuilder support.
Thank you 🙂
-
AuthorPosts
Find exclusive trading pro-tools on