Automated FTSE 5 MINUTE with PSAR indicator

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #204258 quote
    maleczek
    Participant
    Junior

    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 = 160000

    daysForbiddenEntry = 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
    ENDIF

    IF 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
    ENDIF

    IF dealtime AND NOT ONMARKET THEN

    IF gchange AND (HIGH >= loft) THEN
    BUY contractsize CONTRACT AT MARKET
    ENDIF

    IF rchange AND (LOW =< dell) THEN
    SELLSHORT contractsize CONTRACT AT MARKET
    ENDIF

    SET target $profit 40
    SET stop ploss 80
    ENDIF

    GRAPH 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.

    FTSE-SAR-and-Bar-strategy.jpg FTSE-SAR-and-Bar-strategy.jpg
    #204291 quote
    maleczek
    Participant
    Junior

    Dear 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

    #204307 quote
    GraHal
    Participant
    Master

    I 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.

    BreakOut – SAR – Index – 15m – (DJIA-DAX-PXI)

    #204311 quote
    maleczek
    Participant
    Junior

    Thank 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

    GraHal thanked this post
    #204331 quote
    GraHal
    Participant
    Master

    I 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’?

    #204333 quote
    maleczek
    Participant
    Junior

    Apologies 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,

    #204335 quote
    GraHal
    Participant
    Master

    Yes 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.

    #204336 quote
    maleczek
    Participant
    Junior

    Thank you GraHal,

    #204337 quote
    GraHal
    Participant
    Master

    There is also a audible Alert that can be set and even can give a spoken message (import own wav file) .

    I use the built in sounder loads … can be very useful if making coffee / shower / toilet  🙂

    #204398 quote
    JS
    Participant
    Senior

    Hi @maleczek

    Here is an earlier attempt to convert the SAR indicator into a trading system…

    Maybe you can do something with it…

    DefParam CumulateOrders = False
    
    increment = 0.02
    initial = 0.02
    limite = 0.2
     
    IF BARINDEX < 2 THEN
    Lparabolic = LOW
    islong = 1
    af = limite
    hp = HIGH
    lp = LOW
    ELSE
    IF islong THEN
    Lparabolic = Lparabolic + af * (hp - Lparabolic)
    Lparabolic = MIN(Lparabolic, LOW[1])
    Lparabolic = MIN(Lparabolic, LOW[2])
    ELSE
    Sparabolic=Sparabolic + af * (lp - Sparabolic)
    Sparabolic=MAX(Sparabolic, HIGH[1])
    Sparabolic=MAX(Sparabolic, HIGH[2])
    ENDIF
         
    reverse = 0
         
    IF islong THEN
    IF LOW < Lparabolic and Close < Open THEN
    SellShort at (Low - 1 * pointsize) STOP
    Set Target pProfit 10
    Set Stop pLoss 20
    islong = 0
    reverse = 1
    Sparabolic = hp
    lp = LOW
    af = initial
    ENDIF
    ELSE
    IF HIGH > Sparabolic and Close >= Open THEN
    Buy at (High + 1 * pointsize) STOP
    Set Target pProfit 10
    Set Stop pLoss 20
    islong = 1
    reverse =1
    Lparabolic = lp
    hp = HIGH
    af = initial
    ENDIF
    ENDIF
         
    IF NOT reverse THEN
    IF islong THEN
    IF HIGH > hp THEN
    hp = HIGH
    af = af + increment
    af = MIN (af,limite)
    ENDIF
    ELSE
    IF LOW < lp THEN
    lp = LOW
    af = af + increment
    af = MIN (af,limite)
    ENDIF
    ENDIF
    ENDIF
         
    ENDIF
    
    GraHal thanked this post
    #204403 quote
    robertogozzi
    Moderator
    Master
    @maleczek Post 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 🙂
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Automated FTSE 5 MINUTE with PSAR indicator


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
maleczek @maleczek Participant
Summary

This topic contains 10 replies,
has 4 voices, and was last updated by robertogozzi
3 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/16/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...