Trade from Pivot-R-S points
Forums › ProRealTime English forum › ProOrder support › Trade from Pivot-R-S points
- This topic has 16 replies, 4 voices, and was last updated 6 years ago by Marco Tampellini.
-
-
02/18/2018 at 11:08 PM #63069
Good Evening,
i posted similar question on italian forum, we are working on it but still didn’t work correctly.
Here what i would like to do, for backtest.
Let’s consider for example Spot Eur/Usd, and TF weekly. As in the picture attached.
I would like to set this code:
At the begin of the week, it starts 2 pending orders, with related Stop Loss and Target Price.
1st) Pending Long, from S1 with target Pivot, and SL on S2
2nd) Pending Short, from R1, with target Pivot and SL on R2
additional instructions:
1) I would like to make sure that ONLY ONE order is executed per week, so that if the Long enters first, the Short one is cancelled, and same thing on the contrary.
2) At the end of the period (in this case week), if the order entered is still active (therefore it has not reached either the stop loss or the target price), I would like it to be closed.…
In this case i considered wS1 – wS2 – wR1 -wR2 – wP, but i would like it works correctly even if i set dS1 – dS2 , so orders would be closed withing a day, and so on.
Here i post a code that im trying to improve thanks to other users support, but still doesn’t work correctly.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate// Pivot GiornalieriONCE dP = UndefinedONCE dR1 = UndefinedONCE dS1 = UndefinedONCE dR2 = UndefinedONCE dS2 = UndefinedONCE dR3 = UndefinedONCE dS3 = Undefined// Pivot SetgtimanaliONCE wP = UndefinedONCE wR1 = UndefinedONCE wS1 = UndefinedONCE wR2 = UndefinedONCE wS2 = UndefinedONCE wR3 = UndefinedONCE wS3 = Undefined// Pivoy MensiliONCE mP = UndefinedONCE mR1 = UndefinedONCE mS1 = UndefinedONCE mR2 = UndefinedONCE mS2 = UndefinedONCE mR3 = UndefinedONCE mS3 = UndefinedIF OnMarket THENSELL AT MARKETEXITSHORT AT MARKETENDIFdP, dR1, dS1, dR2, dS2, dR3, dS3, wP, wR1, wS1, wR2, wS2, wR3, wS3, mP, mR1, mS1, mR2, mS2, mR3, mS3 = CALL "Pivots D-W-M"BUY 1 CONTRACT AT dR1 STOPSELLSHORT 1 CONTRACT AT dS1 STOPSET TARGET PROFIT dR2 - dR1SET STOP LOSS dS1// dummy lines to avoid errors being reported by ProOrder because some variables are not used// linee inutili e superflue, messe solo per evitare che ProOrder segnali che alcune variabili non sono utilizzatex = dP + dR1 + dS1 + dR2 + dS2 + dR3 + dS3 + wP + wR1 + wS1 + wR2 + wS2 + wR3 + wS3 + mP + mR1 + mS1 + mR2 + mS2 + mR3 + mS3IF x < 0 thenbuy at marketendifThanks to anyone who can help 🙂
02/18/2018 at 11:55 PM #63074Do not duplicate topics in different languages, because this will spread info from different members over multiple topics making it difficult to keep track of them, thus making it less interesting.
Choose a language with which you feel more at ease and stick to it, please. Thank you.
02/19/2018 at 1:37 AM #63081Sorry, i didn’t know. So, let’s keep it here, there could be more users interested/able to help us with it.
Thanks
02/19/2018 at 1:23 PM #6314402/19/2018 at 1:58 PM #63156You don’t need the dummy lines at the end if instead of avoiding the error message, you correct the error, by using in line 34 the keywork “ignored” for each variable not used afterwards: (untested, but should work if I spotted the correct 3 variables used)
1ignored, dR1, dS1, dR2, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored = CALL "Pivots D-W-M"02/19/2018 at 2:03 PM #63158I’m going to try it! 🙂
02/19/2018 at 2:25 PM #63162Well, the result is profitable 😀 but not what I wanted to achieve,
also corrected like this, it makes orders within the same week while I would like it to enter a maximum of 1 order only: if it intercepts wR1 first, it opens the short order, and cancels the pending long (with its stop and target). If, on the other hand, it first intercepts wS1, it should open the long order and cancel the pending short with its stop loss and target.
We would thus have a maximum of one order per week.Limit case is when wS1 or wR1 are intercepted, it starts the order but then the price doesn’t reach TP or SL. In this case i would like it to close all the orders at the end of the week.
Any idea how to proceed? 🙁
02/19/2018 at 2:37 PM #63163Just in case, even if I might be charged of stating the obvious, the line I suggested for line 34 is if only dR1 DR2 dS1 are used as per lines 36 through 40, having considered all the rest lines 44 through 49 as dummy. If you need to use more than just dR1 dR2 and dS1 from the “call”, the modification needs to be adapted by *not* replacing by “ignored” the relevant other variables used, and furthermore by picking them in the right order within the list of “ignored” (another source of frequent bug when using a “call” with a long list of returned variables most of them being ignored)
02/19/2018 at 3:12 PM #63168Thanks for your help,
i feel so stupid, i can’t make it work 😀
Let’s say i want to use onlw weekly pivot lines: so wP, wS1 wS2 wR1 and wR2. Same as in the pic attached.
i modified the code like this:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate// Pivot GiornalieriONCE dP = UndefinedONCE dR1 = UndefinedONCE dS1 = UndefinedONCE dR2 = UndefinedONCE dS2 = UndefinedONCE dR3 = UndefinedONCE dS3 = Undefined// Pivot SetgtimanaliONCE wP = UndefinedONCE wR1 = UndefinedONCE wS1 = UndefinedONCE wR2 = UndefinedONCE wS2 = UndefinedONCE wR3 = UndefinedONCE wS3 = Undefined// Pivoy MensiliONCE mP = UndefinedONCE mR1 = UndefinedONCE mS1 = UndefinedONCE mR2 = UndefinedONCE mS2 = UndefinedONCE mR3 = UndefinedONCE mS3 = UndefinedIF OnMarket THENSELL AT MARKETEXITSHORT AT MARKETENDIFignored, ignored, ignored, ignored, ignored, ignored, ignored, wP, wR1, wS1, wR2, wS2, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored, ignored = CALL "Pivots D-W-M"// entrata LONGBUY 1 CONTRACT AT wS1 STOP //ordine pendente su Resistenza 1 giornalieraSELL AT wS2 STOP //SL su Supporto 2SELL AT wP LIMIT //TP su pivot// entrata SHORTSELLSHORT 1 CONTRACT AT wR1 STOP //ordine pendente su Supporto 1 giornalieroEXITSHORT AT wR2 STOP //SL su Resistenza 2EXITSHORT AT wP LIMIT //TP su pivot// dummy lines to avoid errors being reported by ProOrder because some variables may not be usedx = dP + dR1 + dS1 + dR2 + dS2 + dR3 + dS3 + wP + wR1 + wS1 + wR2 + wS2 + wR3 + wS3 + mP + mR1 + mS1 + mR2 + mS2 + mR3 + mS3but it’s not working, it starts many order inside the same week. how would you change it?
02/19/2018 at 3:23 PM #63173Well, the result is profitable 😀 but not what I wanted to achieve, also corrected like this, it makes orders within the same week while I would like it to enter a maximum of 1 order only: if it intercepts wR1 first, it opens the short order, and cancels the pending long (with its stop and target). If, on the other hand, it first intercepts wS1, it should open the long order and cancel the pending short with its stop loss and target. We would thus have a maximum of one order per week. Limit case is when wS1 or wR1 are intercepted, it starts the order but then the price doesn’t reach TP or SL. In this case i would like it to close all the orders at the end of the week. Any idea how to proceed? 🙁
All strategies are executed when each candle is closed, so on a 1-week chart all pending orders will be cancelled at the end of the week, NOT before! If a week is too much to wait you’ll have to switch to a lower TF, as of this version of PRT!
02/19/2018 at 3:27 PM #63174The way you call the indicator and the number of variables used won’t change the behaviour of your strategy, you may also delete lines 3-28, to make your strategy shorter, but it won’t affect the output.
02/19/2018 at 3:36 PM #63177Ok thanks, i understood about the fact it will delete pending orders at the end of the week. And it could be ok, but in this way i should only have max of 2 orders in a week (1 pending short and 1 pending long, eventually deleted at the end of the week), but actually the output is that i get more orders in the same week, almost each 4h candele :/
02/19/2018 at 4:09 PM #63185Ok it’s working now, just the fact that it doesn’t consider the candle during it’s progress it gives me different results from my excel analysis. I hope they fix this :/
02/19/2018 at 4:18 PM #63186I just pasted your code but I can’t get any trade, on which instrument and TF are you testing this strategy?
Also, I think lines 37-38 for LONGs and 42-43 for SHORTS shouldn’t have the same variable for the pending orders.
02/19/2018 at 4:35 PM #63188I backtested it on Eur Usd weekly!
-
AuthorPosts
Find exclusive trading pro-tools on