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/06/2020 at 12:47 PM #11603801/06/2020 at 12:54 PM #11604001/06/2020 at 1:04 PM #116045
I might be speaking too soon
Still no Rejection after 16 mins so SP = 1 looks like the problem?
I’ll keep monitoring and report back.
1 user thanked author for this post.
01/06/2020 at 1:48 PM #11605201/06/2020 at 3:31 PM #116064I’ll like to help but I do not see anything in the code that would suggest this behavior. But please test these, in the same order:
- restrain the whole code to a time condition: if time>=010000 and time<073000 then …. YOUR CODE …. endif
- use a period of more than just 1 period for the calculation of the stochastic (variable SP)
- Did you try on a 5-minutes timeframe? (I know it is not the desired TF, but ..)
1 user thanked author for this post.
01/06/2020 at 6:44 PM #116084SP = 2 on 1 min TF stopped again but it took about 3 hours this time (1 hour last time).
SP = 1 on 5 min TF got stopped, but it took about 3 hours.
SP =10 on 1 min TF is still running after 3 hours.
1 user thanked author for this post.
01/06/2020 at 7:32 PM #116086Thanks GraHal for your big effort here, I really appreciate it!
I have replaced the stochastic with one line of code, since I only need an intrabar view on the close vs. high and low. The code now looks like this:
K = ((close-low)/(high-low))*100
Very close to stochastic, but now I don’t have to worry about the highest/lowest in relation to one bar only.
The strategy still stops though.
Then I have followed suggestion from Nicolas and “wrapped” all code in an “if time>=010000 and time<073000 then” statement, though after the defparam lines, since they need to come before anything else in any code as far as I remember. I suppose I will have to wait and see till tomorrow morning if this has an influence.
I will revert.
01/06/2020 at 8:51 PM #11608701/07/2020 at 11:44 AM #116117All versions stopped except SP = 10.
In backtest SP = 10 makes zero / 0 Profit (due to zero Trades over 100k bars).
Why is the SP = 10 System the only System (out of our trials) that does not get stopped??
No entries for any stoppages under Rejected / Cancelled in the Orders List.
Stopped error message is attached. All my versions stopped have DEFPARAM PreLoadbars = 10000.
Point to Note:
Stoppages occur outside of trading hours (see numerous evidence in comments above) so it is not when a System tries to execute a trade that the System is stopped.
1 user thanked author for this post.
01/07/2020 at 12:06 PM #116119JASS and I have tried numerous versions, so for reference … below is the only code version that has NOT been stopped.
The version below has been running since 14:37 yesterday 6 Jan 20.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150//-------------------------------------------------------------------------// Main code : A107 Pullback Rev JPN 1M v04//-------------------------------------------------------------------------//https://www.prorealcode.com/topic/trading-system-automatically-stopped/#post-115990//**********************************************************************************// Title: A107 Pullback Rev JPN 1M v04// Chart: JAPAN225 / NIKKEI 1M// Note: Exploiting one bar pullbacks in steep trending market//**********************************************************************************DEFPARAM CumulateOrders = TrueDEFPARAM PreLoadBars = 10000DEFPARAM FLATBEFORE = 000000DEFPARAM FLATAFTER = 063000//**********************************************************************************// Variables//**********************************************************************************PositionSize = 1tp = 138 // Target profitsl = 28 // Stop lossEMAp1 = 34EMAp2 = 29EMAp4 = 41SMAp2 = 40SP = 10 // 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 tp//GRAPH ((C-LL)/(HH-LL))*1001 user thanked author for this post.
01/07/2020 at 4:03 PM #116147Ok, so my conclusion goes for the stochastic period, that must be superior to 1. If there is no bar (or “phantom bar”), the 1 period calculation leads to a division by zero at line 50.
You could also try this version of the calculation, it should also work with a 1-period:
1K = ((C-LL)/max(pointsize,(HH-LL)))*10001/07/2020 at 4:43 PM #116151JASS got rid of the stochastic and it was still stopped, but maybe he still ended up with a divide by zero error (if no bar or phantom bar) with his amended code. See his post here …
https://www.prorealcode.com/topic/trading-system-automatically-stopped/page/2/#post-116086
I will try your code Nicolas thank you.
1 user thanked author for this post.
01/07/2020 at 7:21 PM #116163Over 2.5 hours … so far so good using Nicolas code!
The no bar / phantom bar causing a divide by zero error would account for the Rejection / Stop being random … due to a no bar occurrence being random!
1 user thanked author for this post.
01/07/2020 at 8:32 PM #11616601/08/2020 at 8:57 AM #116178 -
AuthorPosts
Find exclusive trading pro-tools on