Pivot points
Forums › ProRealTime English forum › ProOrder support › Pivot points
- This topic has 9 replies, 3 voices, and was last updated 6 years ago by
jayvee.
-
-
12/05/2019 at 4:44 PM #114271
Festive greetings everyone. Can someone help please. Have been backtesting daily pivot points – a simple system; buy when close crosses over r1 or r2 and short when close crosses under s1 or s2. What I’m finding is that there are a number of trades that are coming up that don’t fit this criteria – for example a short trade is recorded even though it hasnt crossed s1 or s2 (in fact hasnt crossed anything!). I’m not sure what I’m doing wrong. Any suggestions?
123456789101112131415//support level 2indicator1 = (DHigh(1) + DLow(1) + DClose(1))/3-(DHigh(1)-DLow(1))c1 = (close CROSSES OVER indicator1)//support level 1indicator2 = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DHigh(1)c2 = (close CROSSES OVER indicator2)//resistance level 2indicator3 = (DHigh(1) + DLow(1) + DClose(1))/3+(DHigh(1)-DLow(1))c3 = (close CROSSES UNDER indicator3)//resistance level 1indicator4 = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DLow(1)c4 = (close CROSSES UNDER indicator4)12/05/2019 at 5:21 PM #114276It depends on how conditions are used when placing the order and at which point, in the strategy, they are used.
If you post your code we might be of some help.
12/06/2019 at 11:34 AM #114322Much obliged Roberto. I’m still playing around with the code. I thought it maybe just something do with how I’m calculating the pivot points. looks like the issue occurs on Mondays. Code still in development:
12345678910111213141516171819202122232425262728293031323334// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = (DHigh(1) + DLow(1) + DClose(1))/3-(DHigh(1)-DLow(1))c1 = (close CROSSES OVER indicator1)IF c1 THENBUY 1 PERPOINT AT MARKETENDIF// Conditions to exit long positionsindicator2 = 2*((DHigh(1) + DLow(1) + DClose(1))/3) – DLow(1)c2 = (close CROSSES OVER indicator2)IF c2 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator3 = (DHigh(1) + DLow(1) + DClose(1))/3+(DHigh(1)-DLow(1))c3 = (close CROSSES UNDER indicator3)IF c3 THENSELLSHORT 1 PERPOINT AT MARKETENDIF// Conditions to exit short positionsindicator4 = 2*((DHigh(1) + DLow(1) + DClose(1))/3) – DHigh(1)c4 = (close CROSSES UNDER indicator4)IF c4 THENEXITSHORT AT MARKETENDIF12/06/2019 at 12:16 PM #114328I tried only LONG trades first, and it’s all good. As you can see from the attached pic, on the setup candle (where the mouse is sitting) there was a crossover compared to the previous candle, though it’s almost vertical and not horizontal. All other LONG trades confirm this correct behaviour.
I suggest that you add GRAPH to monitor variables candle by candle, as in my code (slightly modified to enter LONGs only):
1234567891011121314151617181920212223242526272829303132333435363738// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = (DHigh(1) + DLow(1) + DClose(1))/3-(DHigh(1)-DLow(1))c1 = (close CROSSES OVER indicator1)IF c1 THENBUY 1 PERPOINT AT MARKETENDIF// Conditions to exit long positionsindicator2 = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DLow(1)c2 = (close CROSSES OVER indicator2)IF c2 THENSELL AT MARKETENDIF// Conditions to enter short positions//indicator3 = (DHigh(1) + DLow(1) + DClose(1))/3+(DHigh(1)-DLow(1))//c3 = (close CROSSES UNDER indicator3)////IF c3 THEN//SELLSHORT 1 PERPOINT AT MARKET//ENDIF////// Conditions to exit short positions//indicator4 = 2*((DHigh(1) + DLow(1) + DClose(1))/3) - DHigh(1)//c4 = (close CROSSES UNDER indicator4)////IF c4 THEN//EXITSHORT AT MARKET//ENDIFgraph c1graph c2//graph c3//graph c4it works fine for SHORT trades, as well.
12/06/2019 at 3:08 PM #114348Thanks Roberto, I’m still a bit confused about what you mean by ‘here was a crossover compared to the previous candle, though it’s almost vertical and not horizontal’ – apologies I’m still a beginner at this. Using your code above (long only) I tested against EURUSD and had some unexpected trades – seems Mondays only or midnight time. I think its do with the timing based on previous day/week that causes some sort of shift in the resistance/support levels maybe??? – I’m not sure really. See attached screenshots
12/06/2019 at 3:23 PM #114351Yes, but if you do not plot pivots on your chart I can’t see if there is a crossover or not.
Look at my previous pic, there is a bearish candle where the mouse is sitting, then there is another bearish candle on its left. THAT is a bullish crossover!
The previous candle closed BELOW the pivot line, the following candle (where the mouse is sitting) closed ABOVE (despite il looks like on the right side) ABOVE the pivot line!
12/06/2019 at 3:30 PM #114352On Monday daily pivot lines will be calculated on the Sunday candle data. You need to ignore Sunday candles and use Friday data if it is a Monday and either include Sunday data with Monday data of ignore Sunday data if it is a Tuesday to get meaningful pivot lines. There is some code somewhere on this forum that does it or I have some code I wrote on one of my accounts – finding it might take a while though as I have not looked at pivot lines for years!
12/06/2019 at 5:48 PM #114358Here is some code that calculates R1, S1 and the central pivot and fixes the Sunday problem. On a Sunday and Monday it uses Friday data to calculate the lines. On Tuesday it uses Sunday and Monday combined to calculate the lines.
1234567891011121314151617181920212223242526272829//Pivot Lines with Sunday Fixb1=DHigh(1)b2=DHigh(2)c1=DLow(1)c2=DLow(2)d1=DClose(1)d2=DClose(2)IF OpenDayOfWeek = 1 THENb1=b2c1=c2d1=d2endifif OpenDayOfWeek = 2 thenb1 = max(b1,b2)c1 = min(c1,c2)ENDIFH1 = b1//HighL1 = c1//LowC = d1//ClosePivot = (H1 + L1 + C) / 3R1 = 2*((H1 + L1 + C) / 3)- L1S1 = 2*((H1 + L1 + C) / 3)- H1return Pivot style(dottedline,1) as "Point Pivot", R1 as "R1", S1 as "S1"12/06/2019 at 5:53 PM #114359ah thank you both, splendid. Vonasi, do you know where I could find the code? I would really appreciate it. I could only find this? – https://www.prorealcode.com/reply/70436/
12/06/2019 at 6:14 PM #114360 -
AuthorPosts
