Automated trading backtested code not working on live
Forums › ProRealTime English forum › ProOrder support › Automated trading backtested code not working on live
- This topic has 9 replies, 5 voices, and was last updated 3 years ago by robertogozzi.
-
-
12/23/2020 at 5:17 AM #154940
Hi Guys,
I’m new to coding in Prorealtime. I hope someone can help me with this.
- I have done some code for automated trading and backtested it.
- It works perfect in the backtest but when I execute this for autotrading on live, it does not work.
- But when I backtest the same code that wasn’t working on the live for those days in point 2 above, it works fine a couple of days later on backtesting.
- I suspect it may have been something to do with timezone? I don’t know.
- I’m in Australia so all my time zone are set to Australia/Sydney desktop time
- I’m trading US market indices
Any help would be great. Please see the code below.
What Am I doing wrong?
Automated trading backtested code not working on live12345678910111213141516171819202122// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 023000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 080000timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0IF MyRules AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENBUY 10 CONTRACT AT MARKETENDIFSET TARGET pPROFIT 100SET STOP TRAILING 5012/23/2020 at 8:22 AM #154942This is likely to have nothing to do with your issues, but as you used “p” with PROFIT you should use it with TRAILING as well.
What does “it does not work”?
What errors or wrong trades are reported?
1 user thanked author for this post.
12/23/2020 at 8:37 AM #154944What maximum size of trade have you set? If this is under the minimum size for the instrument that you are trying to trade then no trades will be opened.
Does the size you are trying to open meet the minimum size for that market?
12/23/2020 at 10:02 AM #15495012/24/2020 at 1:03 AM #155063I’m not getting any errors. The code simple does not execute any trades in live.. although the code works fine in backtested for the same period.
I’m using it in NASDAQ indicies US Tech 100 ($1) market.
- The minimum size for this market is 0.5.
- Although the code says BUY 10 contract, I set a minimum contract to buy as 2 when you start the autotrading. Do I need to have the same quanty in the code and when you start ? (Please see the screenshot)
- I do have enough margin in the account to be able to execute 10 contracts.
I will try using the “p” with TRAINING.
12/24/2020 at 1:33 AM #155068What maximum size of trade have you set? If this is under the minimum size for the instrument that you are trying to trade then no trades will be opened.
Does the size you are trying to open meet the minimum size for that market?
Thank you for your reply. My code says 10 contract but I put 2 in maximum size.. ? Do I need to put 10 or more in the maximum size when I start the program?
12/24/2020 at 8:23 AM #15509112/24/2020 at 11:00 AM #155104The Max Position box that you have to fill in before running a strategy live is quite simply a safety level that you set. It is useful if you have accumulating positions and want to set a limit to how many are allowed to be open at any one time. If your strategy only ever has one position open of a size of 0.5 then set it to 0.5.
The setting is there to stop out of control strategies from emptying your bank account.
1 user thanked author for this post.
12/24/2020 at 1:59 PM #155126The Max Position box that you have to fill in before running a strategy live is quite simply a safety level that you set. It is useful if you have accumulating positions and want to set a limit to how many are allowed to be open at any one time. If your strategy only ever has one position open of a size of 0.5 then set it to 0.5.
The setting is there to stop out of control strategies from emptying your bank account.
Thank you so much for your help.
Thanks to everyone for your input. Thank you.
12/24/2020 at 6:58 PM #155165I changed trading hours to reflect CET (Utc+1) and it just opened a trade with 10 contracts at 18:30 (Utc+1), entry price 12697.5.
-
AuthorPosts
Find exclusive trading pro-tools on