Pivots Points – Buy and sell short strategy
Forums › ProRealTime English forum › ProOrder support › Pivots Points – Buy and sell short strategy
- This topic has 16 replies, 4 voices, and was last updated 1 year ago by LaMaille.
-
-
09/06/2023 at 4:16 PM #220441
Hello,
Just looking for an automated strategy that involves Pivots Points (Free or with a small fee).
Conditions:
Buy if PP is support
Sell if PP is resistance
TF to be determined manually.
TP to be determined manually.
Thank you
Thank you
Damien
09/08/2023 at 9:02 AM #220547Any help and code posted on this forum is ALWAYS for free.
There you go:
12345678910111213141516171819202122232425DEFPARAM CumulateOrders = FalseSL = 200 * PipSizeTP = SL * 3N = 5PP = (DHigh(1) + DLow(1) + DClose(1))/3 //PP calculation//Res1 = summation[N](close <= PP) = NRes2 = summation[N](high >= PP)Res = Res1 AND Res2//Sup1 = summation[N](close >= PP) = NSup2 = summation[N](low <= PP)Sup = Sup1 AND Sup2//IF Sup AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF Res AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//SET TARGET pPROFIT TPSET STOP pLOSS SL//GraphOnPrice PP AS "Pivot" coloured("Fuchsia",255)GraphOnPrice TradePrice AS "TradePrice" coloured("Cyan",255)4 users thanked author for this post.
09/08/2023 at 10:48 AM #22056309/08/2023 at 11:12 AM #220567Nice approach by Roberto!
Other code related to avoid take positions near pivot points: https://www.prorealcode.com/topic/prevent-entry-near-pivot-points/#post-202658
could be easily reverted to take positions on them.
2 users thanked author for this post.
10/18/2023 at 9:58 AM #222589Point Pivot Daily - NASDAQ 1 mn UT - 1030am1234567891011121314151617181920212223242526DEFPARAM CumulateOrders = FalseSL = 40TP = 10N = 5Ht = DHigh(1)Bs = DLow(1)C = DClose(1)Pivot = (Ht + Bs + C) / 3//Res1 = summation[N](close <= Pivot) = NRes2 = (high[1] >= Pivot)Res = Res1 AND Res2//Sup1 = summation[N](close >= Pivot) = NSup2 = (low[1] <= Pivot)Sup = Sup1 AND Sup2//IF Sup AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF Res AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//SET TARGET pPROFIT TPSET STOP pLOSS SLGood morning Roberto,
Thank you for this strategy.
I am scratching my head wondering why this strategy did not take a short position at 1030am this morning (NASDAQ – 1 mn UT) ?
Point pivot was a “Res” for the close, 5 previous close were below Point Pivot and high was over point pivot.
Thank you.
Damien
10/18/2023 at 10:23 AM #222591Because it was already ShortOnMarket AND condition Sup1 was false.
Using GRAPH extensively to monitor your conditions and other data will help you.
1 user thanked author for this post.
10/18/2023 at 10:57 AM #222600Thank you Roberto for your swift answer. Appreciated.
If I am not mistaken, the strategy was flat. I added the Graph as you said. I have ignored the Sup1 // …
According to the chart, the strategy should have taken postions at 9:44am & 9:54am and 10:31am? What do you think?
These types of entries are the one I am looking for. I am a dummy in coding 😉
10/18/2023 at 11:55 AM #222606Append these lines to your code:
123graphonprice Pivot coloured("Fuchsia")graph Res coloured("Red")graph Sup coloured("Green")you will see that NO condition was true and that the price was quite far from the pivot line.
10/18/2023 at 1:39 PM #222615Find it why, thank you Roberto.
1 – The code uses the previous PP (1) so of course there were no trade taken in the mentioned levels today (0). Sorry 😉
2 – But when i change the PP with (0) instead of (1) it gives a funny PP… How can i have it straight like the PRT one please?
Thank you.
Damien
10/18/2023 at 2:28 PM #222618PP Daily123456789101112Ht = DHigh(1)Bs = DLow(1)C = DClose(1)Pivot = (Ht + Bs + C) / 3Res3 = Res1 + (Ht - Bs)Res2 = Pivot + Ht - BsRes1 = (2 * Pivot) - BsSup1 = (2 * Pivot) - HtSup2 = Pivot - (Ht - Bs)Sup3 = Sup1 - (Ht - Bs)Return Res1 AS "Res1" coloured("green"), Res2 AS "Res2" coloured("green"), Res3 AS "Res3" coloured("green"), Pivot AS "Pivot" coloured("black"), Sup1 AS "Sup1" coloured("red"), Sup2 AS "Sup2" coloured("red"), Sup3 AS "Sup3" coloured("red")Strangely, the indicator PP Daily gives a straight line for the PP Pivot like the PRT PP even with the (1)… Please help. Thank you Roberto.
10/18/2023 at 3:53 PM #222620Sorry, but I can’t understand what you want to do, why are you comparing yestarday’s (1) data with today’s (0)?
Please post exactly the code you want to use and tell me when it doesn’t work according to you (on Nasdaq, 1-minute TF) ?
1 user thanked author for this post.
10/20/2023 at 1:04 PM #222687Bonjour Nicolas,J’ai envoyé une demande mercredi via la messagerie “Trading Programming Service” afin de faire construire la Ferrari des points Pivots 😉 dans votre garage. C’est possible, n’est-ce pas ?Excellente journée.DamienHello Nicolas, I sent a request on Wednesday via the “Trading Programming Service” messaging service to have the Pivot Points Ferrari built 😉 in your garage. It’s possible, isn’t it? Excellent day.
Damien
10/20/2023 at 6:12 PM #22269510/20/2023 at 6:15 PM #22269610/23/2023 at 8:56 AM #222803PP's code123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578//-------------------------------------------------------------------------// Main code : DAX OCTOBRE//-------------------------------------------------------------------------DEFPARAM CumulateOrders = TRUE // Cumulating positions deactivated//monthly values// MONTHLYmR1M = 15828R1M = 16016mR2M = 16283R2M = 16550mR3M = 16738R3M = 16926mR4M = 17381R4M = 17836PivotM = 15640mS1M = 15373S1M = 15106mS2M = 14918S2M = 14730mS3M = 14663S3M = 14196mS4M = 13741S4M = 13286//WEEKLY VALUESR4W = 16331R3W = 15791R2W = 15598R1W = 15251PivotW = 15058S1W = 14711S2W = 14518S3W = 14171S4W = 13631//TITANHigWPrev = 15683HigMPrev = 16175LowWPrev = 15188LowMPrev = 15265//ROUNDNUMBER VALUESc1 = 15000c2 = 14500c3 = 14000c4 = 15500c5 = 16000//N periodes to look backN = 5//Position taker//mR1Mr1mR1M = summation[N](close <= mR1M) = Nr2mR1M = summation[1](high >= mR1M)tlmR1M = r1mR1M AND r2mR1M//s1mR1M = summation[N](close >= mR1M) = Ns2mR1M = summation[1](low <= mR1M)tsmR1M = s1mR1M AND s2mR1M//IF tsmR1M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlmR1M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//R1Mr1R1M = summation[N](close <= R1M) = Nr2R1M = summation[1](high >= R1M)tlR1M = r1R1M AND r2R1M//s1R1M = summation[N](close >= R1M) = Ns2R1M = summation[1](low <= R1M)tsR1M = s1R1M AND s2R1M//IF tsR1M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlR1M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//mR2Mr1mR2M = summation[N](close <= mR2M) = Nr2mR2M = summation[1](high >= mR2M)tlmR2M = r1mR2M AND r2mR2M//s1mR2M = summation[N](close >= mR2M) = Ns2mR2M = summation[1](low <= mR2M)tsmR2M = s1mR2M AND s2mR2M//IF tsmR2M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlmR2M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//M2Mr1R2M = summation[N](close <= R2M) = Nr2R2M = summation[1](high >= R2M)tlR2M = r1R2M AND r2R2M//s1R2M = summation[N](close >= R2M) = Ns2R2M = summation[1](low <= R2M)tsR2M = s1R2M AND s2R2M//IF tsR2M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlR2M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//m3RMr1mR3M = summation[N](close <= mR3M) = Nr2mR3M = summation[1](high >= mR3M)tlmR3M = r1mR3M AND r2mR3M//s1mR3M = summation[N](close >= mR3M) = Ns2mR3M = summation[1](low <= mR3M)tsmR3M = s1mR3M AND s2mR3M//IF tsmR3M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlmR3M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//3RMr1R3M = summation[N](close <= R3M) = Nr2R3M = summation[1](high >= R3M)tlR3M = r1R3M AND r2R3M//s1R3M = summation[N](close >= R3M) = Ns2R3M = summation[1](low <= R3M)tsR3M = s1R3M AND s2R3M//IF tsR3M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlR3M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF////m4RMr1mR4M = summation[N](close <= mR4M) = Nr2mR4M = summation[1](high >= mR4M)tlmR4M = r1mR4M AND r2mR4M//s1mR4M = summation[N](close >= mR4M) = Ns2mR4M = summation[1](low <= mR4M)tsmR4M = s1mR4M AND s2mR4M//IF tsmR4M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlmR4M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//4RMr1R4M = summation[N](close <= R4M) = Nr2R4M = summation[1](high >= R4M)tlR4M = r1R4M AND r2R4M//s1R4M = summation[N](close >= R4M) = Ns2R4M = summation[1](low <= R4M)tsR4M = s1R4M AND s2R4M//IF tsR4M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlR4M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF////PIVOT Mr1PivotM = summation[N](close <= PivotM) = Nr2PivotM = summation[1](high >= PivotM)tlPivotM = r1PivotM AND r2PivotM//s1PivotM = summation[N](close >= PivotM) = Ns2PivotM = summation[1](low <= PivotM)tsPivotM = s1PivotM AND s2PivotM//IF tsPivotM AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlPivotM AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//mS1MVr1mS1M = summation[N](close <= mS1M) = Nr2mS1M = summation[1](high >= mS1M)tlmS1M = r1mS1M AND r2mS1M//s1mS1M = summation[N](close >= mS1M) = Ns2mS1M = summation[1](low <= mS1M)ssmS1M = s1mS1M AND s2mS1M//IF ssmS1M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlmS1M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S1MVr1S1M = summation[N](close <= S1M) = Nr2S1M = summation[1](high >= S1M)tlS1M = r1S1M AND r2S1M//s1S1M = summation[N](close >= S1M) = Ns2S1M = summation[1](low <= S1M)tsS1M = s2S1M AND s1S1M//IF tsS1M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS1M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//mS2Mr1mS2M = summation[N](close <= mS2M) = Nr2mS2M = summation[1](high >= mS2M)tlmS2M = r1mS2M AND r2mS2M//s1mS2M = summation[N](close >= mS2M) = Ns2mS2M = summation[1](low <= mS2M)tsmS2M = s1mS2M AND s2mS2M//IF tsmS2M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlmS2M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S2Mr1S2M = summation[N](close <= S2M) = Nr2S2M = summation[1](high >= S2M)tlS2M = r1S2M AND r2S2M//s1S2M = summation[N](close >= S2M) = Ns2S2M = summation[1](low <= S2M)tsS2M = s1S2M AND s2S2M//IF tsS2M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS2M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//mS3Mr1SmS3M = summation[N](close <= mS3M) = Nr2SmS3M = summation[1](high >= mS3M)tlSmS3M = r1SmS3M AND r2SmS3M//s1SmS3M = summation[N](close >= mS3M) = Ns2SmS3M = summation[1](low <= mS3M)tsSmS3M = s1SmS3M AND s2SmS3M//IF tsSmS3M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlSmS3M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S3Mr1S3M = summation[N](close <= S3M) = Nr2S3M = summation[1](high >= S3M)tlS3M = r1S3M AND r2S3M//s1S3M = summation[N](close >= S3M) = Ns2S3M = summation[1](low <= S3M)tsS3M = s1S3M AND s2S3M//IF tsS3M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS3M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//mS4MVr1SmS4M = summation[N](close <= mS4M) = Nr2SmS4M = summation[1](high >= mS4M)tlSmS4M = r1SmS4M AND r2SmS4M//s1SmS4M = summation[N](close >= mS4M) = Ns2SmS4M = summation[1](low <= mS4M)tsSmS4M = s1SmS4M AND s2SmS4M//IF tsSmS4M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlSmS4M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S4MVr1S4M = summation[N](close <= S4M) = Nr2S4M = summation[1](high >= S4M)tlS4M = r1S4M AND r2S4M//s1S4M = summation[N](close >= S4M) = Ns2S4M = summation[1](low <= S4M)tsS4M = s1S4M AND s2S4M//IF tsS4M AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS4M AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//R1Wr1R1W = summation[N](close <= R1W) = Nr2R1W = summation[1](high >= R1W)tlR1W = r1R1W AND r2R1W//s1R1W = summation[N](close >= R1W) = Ns2R1W= summation[1](low <= R1W)tsR1W = s1R1W AND s2R1W//IF tsR1W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlR1W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//R2Wr1R2W = summation[N](close <= R2W) = Nr2R2W = summation[1](high >= R2W)tlR21W = r1R2W AND r2R2W//s1R2W = summation[N](close >= R2W) = Ns2R2W= summation[1](low <= R2W)tsR21W = s1R2W AND s2R2W//IF tsR21W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlR21W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//R3Wr1R3W = summation[N](close <= R3W) = Nr2R3W = summation[1](high >= R3W)tlR3W = r1R3W AND r2R3W//s1R3W = summation[N](close >= R3W) = Ns2R3W= summation[1](low <= R3W)tsR31W = s1R3W AND s2R3W//IF tsR31W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlR3W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//R4Wr1R4W = summation[N](close <= R4W) = Nr2R4W = summation[1](high >= R4W)tlR4W = r1R4W AND r2R4W//s1R4W = summation[N](close >= R4W) = Ns2R4W= summation[1](low <= R4W)tsR41W = s1R4W AND s2R4W//IF tsR41W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlR4W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//PivotWr1PivotW = summation[N](close <= PivotW) = Nr2PivotW = summation[1](high >= PivotW)tlPivotW = r1PivotW AND r2PivotW//s1PivotW = summation[N](close >= PivotW) = Ns2PivotW= summation[1](low <= PivotW)tsPivotW = s1PivotW AND s2PivotW//IF tsPivotW AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlPivotW AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S1Wr1S1W = summation[N](close <= S1W) = Nr2S1W = summation[1](high >= S1W)tlS1W = r1S1W AND r2S1W//s1S1W = summation[N](close >= S1W) = Ns2S1W = summation[1](low <= S1W)tsS1W = s1S1W AND s2S1W//IF tsS1W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS1W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S2Wr1S2W = summation[N](close <= S2W) = Nr2S2W = summation[1](high >= S2W)tlS2W = r1S2W AND r2S2W//s1S2W = summation[N](close >= S2W) = Ns2S2W = summation[1](low <= S2W)tsS2W = s1S2W AND s2S2W//IF tsS2W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS2W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S3Wr1S3W = summation[N](close <= S3W) = Nr2S3W = summation[1](high >= S3W)tlS3W = r1S3W AND r2S3W//s1S3W = summation[N](close >= S3W) = Ns2S3W = summation[1](low <= S3W )tsS3W = s1S3W AND s2S3W//IF tsS3W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS3W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S3Wr1S4W = summation[N](close <= S4W) = Nr2S4W = summation[1](high >= S4W)tlS4W = r1S4W AND r2S4W//s1S4W = summation[N](close >= S4W) = Ns2S4W = summation[1](low <= S4W )tsS4W = s1S4W AND s2S4W//IF tsS4W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS4W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//S4Wr1S4W = summation[N](close <= S4W) = Nr2S4W = summation[1](high >= S4W)tlS4W = r1S4W AND r2S4W//s1S4W = summation[N](close >= S4W) = Ns2S4W = summation[1](low <= S4W )tsS4W = s1S4W AND s2S4W//IF tsS4W AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlS4W AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//HigWPrevr1HigWPrev = summation[N](close <= HigWPrev) = Nr2HigWPrev = summation[1](high >= HigWPrev)tlHigWPrev = r1HigWPrev AND r2HigWPrev//s1HigWPrev = summation[N](close >= HigWPrev) = Ns2HigWPrev = summation[1](low <= HigWPrev )tsHigWPrev = s1HigWPrev AND s2HigWPrev//IF tsHigWPrev AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlHigWPrev AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//HigMPrevr1HigMPrev = summation[N](close <= HigMPrev) = Nr2HigMPrev = summation[1](high >= HigMPrev)tlHigMPrev = r1HigMPrev AND r2HigMPrev//s1HigMPrev = summation[N](close >= HigMPrev) = Ns2HigMPrev = summation[1](low <= HigMPrev )tsHigMPrev = s1HigMPrev AND s2HigMPrev//IF tsHigMPrev AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlHigMPrev AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//LowWPrevr1LowWPrev = summation[N](close <= LowWPrev) = Nr2LowWPrev = summation[1](high >= LowWPrev)tlLowWPrev = r1LowWPrev AND r2LowWPrev//s1LowWPrev = summation[N](close >= LowWPrev) = Ns2LowWPrev = summation[1](low <= LowWPrev )tsLowWPrev = s1LowWPrev AND s2LowWPrev//IF tsLowWPrev AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlLowWPrev AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//LowMPrevr1LowMPrev = summation[N](close <= LowMPrev) = Nr2LowMPrev = summation[1](high >= LowMPrev)tlLowMPrev = r1LowWPrev AND r2LowMPrev//s1LowMPrev = summation[N](close >= LowMPrev) = Ns2LowMPrev = summation[1](low <= LowMPrev )tsLowMPrev = s1LowMPrev AND s2LowMPrev//IF tsLowMPrev AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlLowMPrev AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//c1r1c1 = summation[N](close <= c1) = Nr2c1 = summation[1](high >= c1)tlc1 = r1c1 AND r2c1//s1c1= summation[N](close >= c1) = Ns2Lc1 = summation[1](low <= c1)tsc1 = s1c1 AND s2Lc1//IF tsc1 AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlc1 AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//c2r1c2 = summation[N](close <= c2) = Nr2c2 = summation[1](high >= c2)tlc2 = r1c2 AND r2c2//s12c2 = summation[N](close >= c2) = Ns2Lc2 = summation[1](low <= c2)tsc2 = s12c2 AND s2Lc2//IF tsc2 AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlc2 AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//c3r1c3 = summation[N](close <= c3) = Nr2c3 = summation[1](high >= c3)tlc3 = r1c3 AND r2c3//s12c3 = summation[N](close >= c3) = Ns2Lc3 = summation[1](low <= c3)tsc3 = s12c3 AND s2Lc3//IF tsc3 AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlc3 AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//c4r1c4 = summation[N](close <= c4) = Nr2c4 = summation[1](high >= c4)tlc4 = r1c4 AND r2c4//s12c4 = summation[N](close >= c4) = Ns2Lc4 = summation[1](low <= c4)tsc4 = s12c4 AND s2Lc4//IF tsc4 AND Not LongOnMarket THENBUY 1 CONTRACT AT MARKETELSIF tlc4 AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT MARKETENDIF//TS = 7 // 30trailingstop = TS//Best 30if not onmarket thenMAXPRICE = 0priceexit = 0endifif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenSELL AT priceexit STOPendifTS = 7 // 30trailingstop = TS//Best 30if not onmarket thenMINPRICE = closepriceexit = 0endifif shortonmarket thenMINPRICE = MIN(MINPRICE,close) //saving the MFE of the current tradeif tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price levelendifendifif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendifSET STOP %LOSS 0.15SET TARGET %PROFIT 0.07Hello Roberto,
Here is the code.
Highlighted in yellow the level to Buy OR Sellshort.
No trade were taken despite: “DEFPARAM CumulateOrders = TRUE “.
Thank you for your help.
-
AuthorPosts
Find exclusive trading pro-tools on