Newbie questions about automatic trading with ProOrder code
Forums › ProRealTime English forum › ProOrder support › Newbie questions about automatic trading with ProOrder code
- This topic has 21 replies, 5 voices, and was last updated 7 years ago by
GraHal.
-
-
07/25/2017 at 6:23 PM #41600
Hi,
I’m quite new here, but I have the following questions. I’m creating a code, but I can not figure out how to create the following piece of code:
- Every trading day I would like to know what the highest market price is between the previous day 21.00 and the current day 04.00 hours. And I would like to know what the lowest market price is between the previous day 21.00 and the current day 04.00 hours.
- Trading hours are from 06.30 hours until 21.00 hours
- I only want to trade when the 1-hour candle closes above the highest market price mentioned before or when the 1-hour candle closes under the lowest market price mentioned before.
- When the 1-hour candle closes above the highest market price, we take a long trade with a stop loss of 230 pips and a profit stop of 800 pips
- When the 1-hour candle closes below the lowest market price, we take a short trade with a stop loss of 230 pips and a profit stop of 800 pips
- We will only trade once a day. So after the first trade, the system should stop.
Thanks guys!!!
07/26/2017 at 7:48 AM #41624First question:
123456789Once myhigh=0Once mylow=0Once tradedtoday=0If time=040000 thentradedtoday=0MyHigh=Highest[7](high)MyLow=Lowest[7](low)EndifSecond question: Use “defparam flatafter/flatbefore”. Eg. “Defparam flatafter 210000”. Must be the first lines in your code.
Third question:
1234If close>myhigh and tradedtoday=0 thenBuy 1 lot at markettradedtoday=1EndifThen set your SL/TP. Does that help you on the way?
07/26/2017 at 5:16 PM #41701Thanks a lot, Wing. I created the following code, but it is not working. Would you be able to look into it, maybe you have a solution for me? Thanks in advance…
123456789101112131415161718192021222324252627282930313233343536// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.DEFPARAM FLATBEFORE = 063000// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 210100// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 1 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// check on highest and lowest priceOnce myhigh=0Once mylow=0Once tradedtoday=0If time=040000 thentradedtoday=0MyHigh=Highest[7](high)MyLow=Lowest[7](low)Endif// buy when above highest highIf close>myhigh and tradedtoday=0 AND not daysForbiddenEntry THENBuy 1 lot at markettradedtoday=1Endif// sell when below lowest lowIf close>mylow and tradedtoday=0 AND not daysForbiddenEntry THENBuy 1 lot at markettradedtoday=1Endif// Stops and targetsSET STOP pLOSS 230SET TARGET pPROFIT 80007/26/2017 at 5:31 PM #41708Hi PJ, Wing is offline, so thought I’d jump in (to keep you going 🙂 ) … is this maybe the problem?
12345// sell when below lowest lowIf close>mylow and tradedtoday=0 AND not daysForbiddenEntry THENBuy 1 lot at markettradedtoday=1EndifFrom your ‘non-code strategy’ below, it looks like it should be …
- When the 1-hour candle closes below the lowest market price, we take a short trade with a stop loss of 230 pips and a profit stop of 800 pips
12345// sellshort when below lowest lowIf close<mylow and tradedtoday=0 AND not daysForbiddenEntry THENSellShort 1 lot at markettradedtoday=1Endif07/26/2017 at 5:34 PM #4170907/26/2017 at 6:08 PM #4171107/26/2017 at 6:32 PM #41716Close cannot be superior to myHigh or inferior to myLow, you must referred to their values one bar ago, otherwise Close is myHigh or myLow and testing a value superior or inferior to itself has no sense.
12345// sell when below lowest lowIf close>mylow[1] and tradedtoday=0 AND not daysForbiddenEntry THENBuy 1 lot at markettradedtoday=1Endif12345// sellshort when below lowest lowIf close<mylow[1] and tradedtoday=0 AND not daysForbiddenEntry THENSellShort 1 lot at markettradedtoday=1Endif07/26/2017 at 7:59 PM #4172707/27/2017 at 7:11 AM #41753Hi guys,
Thanks again, but I still dont have any results. Something is wrong. I did some manual backtesting and there should be 17 trades in june 2017. You have any clues left? Thanks again for helping me out, I really appreciate it.
07/27/2017 at 7:38 AM #4175407/27/2017 at 10:59 AM #4178707/27/2017 at 11:15 AM #41791Thanks GraHal,
This is the code I use right now.
123456789101112131415161718192021222324252627282930313233343536// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.DEFPARAM FLATBEFORE = 063000// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 210000// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 1 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// check on highest and lowest priceOnce myhigh=0Once mylow=0Once tradedtoday=0If time=040000 thentradedtoday=0MyHigh=Highest[7](high)MyLow=Lowest[7](low)Endif// buy when above highest highIf close>myhigh[1] and tradedtoday=0 AND not daysForbiddenEntry THENBuy 1 lot at markettradedtoday=1Endif// sellshort when below lowest lowIf close<mylow[1] and tradedtoday=0 AND not daysForbiddenEntry THENsellshort 1 lot at markettradedtoday=1Endif// Stops and targetsSET STOP pLOSS 230SET TARGET pPROFIT 80007/27/2017 at 12:57 PM #41801You say … . I did some manual backtesting and there should be 17 trades in june 2017 …. what does manual backtest mean, how did you do it??
Aren’t you restricting potential with time= 040000 ??
Results attached since 1 Apr 13 (100,000 bars?) on DAX at 1 hour TF with time = 040000 lower curve. With time = 090000 upper curve … rest of the code same as yours above.
07/27/2017 at 1:30 PM #4180507/27/2017 at 2:01 PM #41808Your code above shows 800 profit stop, but your manual results above are based on 250 profit stop?
So is there still a problem or are you good to continue now?
If there is still a problem, is it that you want PRT backtest results to match your manual backtest results? Have you got same parameters in each scenario, including spread etc?
-
AuthorPosts
Find exclusive trading pro-tools on