Trading system automatically stopped
Forums › ProRealTime English forum › ProOrder support › Trading system automatically stopped
- This topic has 35 replies, 4 voices, and was last updated 4 years ago by Vonasi.
Tagged: zero divide
-
-
01/02/2020 at 11:27 AM #115742
Two of my strategies are constantly being stopped and I have a hard time finding out why. I never encountered this problem before and the only two differences from other strategies, are that I normally use 5 minutes charts and above and in these two cases I use 1 minute charts. The other difference is that I have set the “DEFPARAM CumulateOrders” to true, which I normally not use.
It toggles between two error messages, apparently randomly.
The first error message relates to the preloadbars setting:
This trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick. Please increase the number of preloaded bars with the instruction DEFPARAM in the code of your strategy (ex: DEFPARAM Preloadbars = 2000). For additional assistance, please refer to the help text of the DEFPARAM function in the trading systems programming manual.
The maximum period used in the strategy for calculations is 51 and no matter if I set it for 100, 200 or the default value 2000, it still doesn’t work. I can even delete the parameter without any change.
The second error message relates to order rejection:
One of the orders of this trading system was rejected. Due to the type of rejection, the trading system had to be stopped. To see the reason the order was rejected, open the order list, go to the”Canceled/Rejected” tab and place your mouse over the warning icon in the “Status” column.
This is incorrect, since it never comes to a point where it actually tries to open a trade and the order list is always empty.
For the Nikkei index I use DEFPARAM FLATBEFORE = 010000 and DEFPARAM FLATAFTER = 073000, but I can start the strategy at e.g. 9.30 and it is stopped a few minutes later.
I can read in another (very emotional) thread, that this kind of error is believed to reside on IG side, but how can that be the case if the strategy is stopped even before it tries to open a trade? Most likely my lack of knowledge on the interface between IG and PRT, but could someone shed light on this?
Is there a solution to this problem?
01/02/2020 at 1:15 PM #115759Have you got two very similar version of the same strategy running?
I ask as I do several versions often and I frequently get Systems stopped because it seems IG cannot handle 2 Orders from the same Account for the same Instrument on the same Timeframe at the same time etc.
1 user thanked author for this post.
01/02/2020 at 1:40 PM #115762The coding is very similar, but one runs on DOW (Wall Street) between 9.00 and 21.59 and the other one runs on Nikkei (Japan 225) between 1.00 and 7.30. So they do not overlap in time. Of course when you set the cumulateorders to true, you will eventually have 2 orders from the same account, but as I wrote, both strategies are stopped even before they try to place orders.
1 user thanked author for this post.
01/02/2020 at 2:57 PM #115768To see the reason the order was rejected, open the order list, go to the”Canceled/Rejected” tab and place your mouse over the warning icon in the “Status” column.
What error message does it show when you do above?
Ah gotcha … there is no entry to show anything??
Yeah I have had a few of these lately … no entry / no error message.
Best to restart the System and see if it gets stopped again??
1 user thanked author for this post.
01/02/2020 at 4:01 PM #11577001/02/2020 at 4:20 PM #115771Okay next best thing is to post the code on here and then the coding Wizards may spot something that is making it fail?
Also I would run the code on my Platform and see if I can spot a fix by trying a few things.
1 user thanked author for this post.
01/03/2020 at 2:05 PM #11583301/06/2020 at 8:19 AM #115990Hi Nicolas and GraHal
I spend the weekend trying to find errors in the code, but it became a “needle-in-a-haystack” exercise. I would appreciate if you would take a look at it and see if you can spot any errors.
By the way: the code works fine in backtesting.
Thanks
JASS
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144//**********************************************************************************// Title: A107 Pullback Rev JPN 1M v04// Chart: JAPAN225 / NIKKEI 1M// Note: Exploiting one bar pullbacks in steep trending market//**********************************************************************************DEFPARAM CumulateOrders = TrueDEFPARAM PreLoadBars = 100DEFPARAM FLATBEFORE = 010000DEFPARAM FLATAFTER = 073000//**********************************************************************************// Variables//**********************************************************************************PositionSize = 1tp = 138 // Target profitsl = 28 // Stop lossEMAp1 = 34EMAp2 = 29EMAp4 = 41SMAp2 = 40SP = 1 // Stochastic Periodv10 = 10 // Stochastic lower linev90 = 94 // Stochastic upper lineemadiff = 1.95 // EMA difference to ensure steep trendMOMp = 51 // Momentum periodMOMLv = 40 // Momentum long valueMOMSv = -100 // Momentum short valuePBLp = 25 // Power bar long periodPBSp = 25 // Power bar short periodPBLv = 12 // Power bar long valuePBSv = 33 // Power bar short valueLBL = 20 // Large bar longLBS = 15 // Large bar shortCOSH = 4 // Count of shares//**********************************************************************************// Indicators and Math//**********************************************************************************// StochasticC = CloseHH = Highest[SP](high)LL = Lowest[SP](low)K = ((C-LL)/(HH-LL))*100// EMAc01 = exponentialaverage[EMAp1](close)// Momentumc03 = momentum[MOMp](close)// SMAc04 = average[SMAp2](close)// Power bar long - no powerbar for the last PBLp number of periods before entryPBL = close - openIF highest[PBLp](PBL) < PBLv THENc13 = 1elsec13 = 0ENDIF// Power bar short - no powerbar for the last PBSp number of periods before entryPBS = open - closeIF highest[PBSp](PBS) < PBSv THENc33 = 1elsec33 = 0ENDIFc05 = abs(c01[0]-c01[1]) > emadiffc06 = exponentialaverage[EMAp2](((2*close)+open)/3)c07 = exponentialaverage[EMAp4](((2*close)+open)/3)//**********************************************************************************// Entry/exit conditions//**********************************************************************************// Enter long conditionsc10 = c01[1] > c01[2]c11 = countoflongshares < COSHc12 = c03 > MOMLvc14 = K[0] < v10// Exit long conditionsc20 = c04[0] < c04[1]c21 = close[0]-open[0] > LBLc22 = c06[0] < c06[1]// Enter short conditionsc30 = c01[1] < c01[2]c31 = countofshortshares < COSHc32 = c03 < MOMSvc34 = K[0] > v90// Exit short conditionsc40 = c04[0] > c04[1]c41 = open[0]-close[0] > LBSc42 = c07[0] > c07[1]//**********************************************************************************// Enter Long//**********************************************************************************if c05 and c10 and c11 and c12 and c13 = 1 and c14 thenbuy PositionSize contract at marketendif//**********************************************************************************// Exit Long//**********************************************************************************if longonmarket and (c20 or c21 or c22) thensell at marketendif//**********************************************************************************// Enter Short//**********************************************************************************if c05 and c30 and c31 and c32 and c33 = 1 and c34 thensellshort PositionSize contract at marketendif//**********************************************************************************// Exit Short//**********************************************************************************if shortonmarket and (c40 or c41 or c42) thenexitshort at marketendif//**********************************************************************************// Stops and Targets//**********************************************************************************set stop ploss slset target pprofit tp01/06/2020 at 8:58 AM #11599301/06/2020 at 11:59 AM #116025Timezone is Denmark (UTC +1) Yes?
So I am deducting 1 hour from times in the code to get to UK time (UTC +0)?
Why don’t you use below as Line 8 ?
1DEFPARAM PreLoadBars = 10000 //(not 100 as you used??)I’ve set it going on my Platform so I take I will have to wait until it tries to take a Trade (every few days) then I may get a rejection?
1 user thanked author for this post.
01/06/2020 at 12:06 PM #11602701/06/2020 at 12:08 PM #11602801/06/2020 at 12:25 PM #116031It really doesn’t matter if I preload 100 or more bars, since my maximum period for calculations is 51.
Well as you are getting the … insufficient preload bars error message … it is worth trying more preload bars.
Anyway I’ve set my preloads bars = 10000 so we shall see what we get.
Btw if you leave it off altogether then the default for preload bars is 2000.
1 user thanked author for this post.
01/06/2020 at 12:31 PM #116034Hey we don’t have to wait days … I’ve been rejected already … see attached.
So the reject is when the code is read not when a trade is attempted?? is this what you have been getting also??
Makes it easier to fault find anyway as it keeps the momentum up as we can keep onto it etc.
I’ve got 2 versions running now … one with Cumulative = True one with False …
1 user thanked author for this post.
01/06/2020 at 12:41 PM #116037Both versions rejected!
Weird as it is not every minute … I had to wait several minutes for the reject and yet the Timeframe is 1 min so the code would be read every minute (or should be!?).
No Reject listed in the Orders List so I cant see the exact time of Reject!
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on