Using PSAR crossover in short timeframes e.g. 10 minutes
Forums › ProRealTime English forum › ProOrder support › Using PSAR crossover in short timeframes e.g. 10 minutes
- This topic has 11 replies, 4 voices, and was last updated 2 years ago by druby.
-
-
07/30/2022 at 5:46 PM #198153
Hello,
I have PRT Complete with IG Index and have completed the first training course. I have tried 50 plus ways to make what seems straightforward happen . . . and failed!
I’m sorry if on reading this you think well that’s so obvious, but I am as Nicolas puts it, now “dreaming programming code” and I need a solution 🙂
So here goes:-
Short timeframe (i.e. 10 minutes) and I am looking for the PSAR to change red to green or vice versa.
New bar with the new PSAR and if the bar matches the colour of the PSAR then I set a value of HIGH + 2 or LOW – 2 for the next bar to enter the market.
If no post change bars meet the criteria (HIGH + 2 or LOW – 2) then the cycle starts again on the next PSAR change.
If a bar equals or exceed the HIGH + 2 or LOW – 2 then a BUY or SELLSHORT is set up with target of 30 and stop of 60.
If nothing matches or the PSAR and first bar don’t match then all is reset for the next change of the PSAR.
If the trade is activated but the target or stop is not met then the trade is closed at the open price of the next PSAR change.
I hope that makes sense, any ideas are really welcome as I am just short of making a truth table and trying each by trial and error … which would be silly, I know?
Thank you in anticipation,
07/30/2022 at 6:00 PM #198155A kind man may be along to help re coding of above, but until then, did you see this PSAR TS in the Library?
https://www.prorealcode.com/prorealtime-trading-strategies/dax-parabolic-system/
It may help to ‘cut your teeth‘ on? 🙂
1 user thanked author for this post.
07/30/2022 at 7:47 PM #198159Coloured Parabolic SAR123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566increment = 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 THENislong = 0reverse = 1Sparabolic = hplp = LOWaf = initialENDIFELSEIF HIGH > Sparabolic THENislong = 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)ENDIFENDIFENDIFENDIFIf isLong thenDRAWPOINT(barindex, Lparabolic, 2) Coloured(0,255,0)EndIfIf NOT isLong thenDRAWPOINT(barindex,Sparabolic,2) Coloured(255,0,0)EndIfReturnHi @maleczek
To start with the “coloured” parabolic SAR…
07/31/2022 at 9:51 AM #198176Thank you GraHal,
I had seen the library code you pointed me to and it operates in the first/second bar but I want to set the High or the Low in the first bar of the same colour as the PSAR and then open a BUY or SELLSHORT at MARKET in the following bars – if indeed one of the bars does in fact exceed the HIGH + 2 or come in under the LOW -2 and then wait till it hits TARGET or STOP before the next PSAR change … if it doesn’t hit TARGET then it is closed at OPEN when the PSAR changes.
I have struggled with the logic of time based as opposed to event/procedural coding …
Thanks again,
1 user thanked author for this post.
07/31/2022 at 8:36 PM #198257Hi @maleczek,
First attempt…
Parabolic SAR TS123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566DefParam 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 - 2 * pointsize) STOPSet Target pProfit 30Set Stop pLoss 60islong = 0reverse = 1Sparabolic = hplp = LOWaf = initialENDIFELSEIF HIGH > Sparabolic and Close >= Open THENBuy at (High - 2 * pointsize) STOPSet Target pProfit 30Set Stop pLoss 60islong = 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)ENDIFENDIFENDIFENDIF07/31/2022 at 10:04 PM #198260Just to clarify your spec..
Let’s say that when the PSAR changes, that this is the first bar, bar 1.
At the beginning of bar 2, a check can be made to see if there was a change at bar 1.
On change on bar 1, the PSAR of bar 2 is calculated as normally.
At the beginning of bar 3, a check can be made to see if bar 2, PSAR and candle colors match.
If they match, offset bar 2 (HIGH–> green PSAR, or LOW–> red PSAR) before calculating bar 3 PSAR.
Does this look correct so far. I’m stopping here because I don’t understand, ‘ If no post’.
‘If no post change bars meet the criteria (HIGH + 2 or LOW – 2) then the cycle starts again on the next PSAR change.’
I’ve modified The code from JS to identify the 2nd bar candle/PSAR color match, identified with a ‘S’, see pick.
08/01/2022 at 11:47 AM #198274Thank you JS and apologies for the delay in replying … my work gets in the way.
I was ready to give up on Probuilder but on seeing your code get 95% success in such a short time – I realise that I have a lot to learn!!!
The only ‘5% bit’ that didn’t work was when the HIGH of 32,634.3 of the bar before tha ‘A’ trade (in attached slide) which opened at 32,632.3 instead of 32,636.3 i.e. HIGH + 2 – hope that makes sense?
Otherwise, it works!!!!
Thank you again.
1 user thanked author for this post.
08/01/2022 at 12:04 PM #198277Hi druby, Thank you for your reply.
I have just replied to JS who has ‘conjured up’ some amazing code that seems to almost solve the problem …
from your response, can I say again that the goal was to clour match the bar and PSAR in the first bar and if matched Green then bar 2 needs to reach HIGH + 2 to open a BUY position. If the first bar matches RED for both bar and PSAR then the sec ond bar needs to be LOW -2 to open a SELLSHORT position. If the TARGET of 30 or the STOP 0f 60 is not activated then the trade is closed at the change of PSAR. If the above ‘bar 1’ two conditions are not met i.e. RED PSAR and GREEN BAR or GREEN PSAR and RED BAR then no position is opened.
Hope that makes sense?
08/01/2022 at 1:09 PM #198280Hi… thanks for your reply, just processing your comments.
I’m sure you noticed this, but the ‘A’ trade you mentioned in reply to JS, which didn’t enter +2 above the previous high as required, actually opened -2 below the previous high. As best I can see that was the same for D and G.
I’m assuming that your code is modified to get the results you want but not yet 100%. Thought this may be a sign on what’s happening, a -2 instead of a +2 if you follow.
If i’m way off the mark just ignore.
08/01/2022 at 1:57 PM #19828608/01/2022 at 4:57 PM #19829808/01/2022 at 5:59 PM #198305Just thought JS my ‘well done JS’ comment could be taken more than one way.
For clarity sake , I was impressed how you provided and then modified the code to provide a solution. I, was still scratching my head!
All the best.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on