Pivot Point Intraday trading strategy
Forums › ProRealTime English forum › ProOrder support › Pivot Point Intraday trading strategy
- This topic has 9 replies, 3 voices, and was last updated 7 years ago by Jessar.
Tagged: pivot points
-
-
08/21/2017 at 9:46 AM #44270
Hello,
I want to create a backtesting code for intraday Pivot Points. I used the indicator which Nicolas posted here:
https://www.prorealcode.com/prorealtime-indicators/pivot-points-intraday/
The code works, except for the stop loss and target profit. I want to buy or sell a contract at R1 / S1 and want to set the target at R2/S2. Stop Loss should be the Pivot Point.
I use the code for Forex.
Any help would be greatly appreciated 🙂
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108defparam cumulate orders = falsedefparam flatbefore = 090000if dayofweek=1 then //Mondaydaytrading=1endifif dayofweek=2 then // Tuesdaydaytrading=1endifif dayofweek=3 then // Wednesdaydaytrading=1endifif dayofweek=4 then //Thursdaydaytrading=1endifif dayofweek=5 then // Fridaydaytrading=1endif// timemyStartHour = 7myStartMinute = 00myEndHour = 8myEndMinute = 55// timestart = (myStartHour * 10000) + (myStartMinute * 100)ende = (myEndHour * 10000) + (myEndMinute * 100)If (Day > Day[1]) ThenmyLow = LowmyHigh = HighmyClose = ClosecountB = 0countS = 0currentdate=dateEndifIf (Time >= start) ThenmyClose = CloseIf High > myHigh ThenmyHigh = HighElsemyHigh = myHigh[1]EndifIf (Time > ende) ThenmyHigh = myHigh[1]myClose = myClose[1]EndifIf Low < myLow ThenmyLow = LowElsemyLow = myLow[1]EndifIf (Time > ende) ThenmyLow = myLow[1]EndifEndifIf Time = ende Then //// PP-CalculationPP = (myHigh + myLow + myClose) / 3R1 = 2 * PP - myLowR22 = PP + (myHigh-myLow)//R3 = 2*(PP-myLow)+myHigh//R4 = 3*(PP-myLow)+myHighS1 = 2 * PP - myHighS2 = PP - (myHigh-mylow)//S3 = myLow-(2*(myHigh-PP))//S4 = myLow-(3*(myHigh-PP))Endifif longonmarket and positionprice<>lastpriceB thencountB = countB+1countS = countS+1lastpriceB = positionpriceendifif shortonmarket and positionprice<>lastpriceS thencountS = countS+1countB = countB+1lastpriceS = positionpriceendifif date=currentdate and time<=220000 and daytrading=1 thenif not longonmarket and countB=0 and close<R1 thenbuy 1 share at R1 stopset stop loss ppset target profit R22endifif not shortonmarket and countS=0 and close>S1 thensellshort 1 share at S1 stopset stop loss ppset target profit S2endifendif08/24/2017 at 11:12 AM #4452108/24/2017 at 12:21 PM #44525Try it this way:
123456789101112131415if not longonmarket and countB=0 and close<R1 thenbuy 1 share at R1 stopendifif not shortonmarket and countS=0 and close>S1 thensellshort 1 share at S1 stopendifif longonmarket thensell at pp stopsell at R22 limitelsif shortonmarket thenexitshort at pp stopexitshort at S2 limitendif08/25/2017 at 8:37 AM #44603Thanks a lot, that already works better!
But still, the “sell at R22 limit” and “exitshort at S2 limit” is not working correctly.
Maybe it is calculating the R22 and S2 from the moment the system buys or sells a share? Is there anything I can do that it calculates R22 and S2 at the given time above?
08/25/2017 at 9:36 AM #4460508/25/2017 at 9:42 AM #4460808/25/2017 at 6:28 PM #4464808/26/2017 at 4:07 AM #4465808/26/2017 at 11:48 AM #4466408/26/2017 at 11:50 AM #44666 -
AuthorPosts
Find exclusive trading pro-tools on