Stratergy is closing on first close
Forums › ProRealTime English forum › ProOrder support › Stratergy is closing on first close
- This topic has 14 replies, 3 voices, and was last updated 1 year ago by Niklas87.
-
-
08/24/2023 at 8:04 AM #219606
I have a new version off a stratergy that works good on back testing, but when i run it live i says that one idicator cant be loaded and i shuld increse preloadbars to 10000. My longest counting idicator is an Average500 and doing this wont help.
What can be the reason?
Whats been added since previus versions is adding this code:
ENTRYBAR = BarIndex – TRADEINDEX[0]
LP75ATENTRY = LP75[ENTRYBAR]
HP75ATENTRY = HP75[ENTRYBAR]
LP500ATENTRY = LP500[ENTRYBAR]
HP500ATENTRY = HP500[ENTRYBAR]
HP*/LP* is respective versions off this:
HP75 = (HIGHEST[HP2](CLOSE)-LOWEST[HP2](CLOSE)) + LOWEST[HP2](CLOSE)
08/24/2023 at 8:13 AM #219607i shuld increse preloadbars to 10000
You should try above first as it is easy to try as a fix.
08/24/2023 at 8:32 AM #219608I tryed but it makes no difference and still gives the same error.
The trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick. You can avoid this in the future by changing the number of preloaded bars with the instruction DEFPARAM (ex: DEFPARAM Preloadbars = 10000).
2-3 seconds before the first bar is about to close it quits. But when back testing everythings works like normal.
08/24/2023 at 8:41 AM #219609I think you would need to post your full code for anybody to add any meaningful suggestions to help.
I’ve had a few recently of the same Reported Error as you are seeing and which turned out to be nothing to do with ‘not enough historical’ bars etc. See the link below …
https://www.prorealcode.com/topic/long-time-to-run-system-code-causes-rejection/#post-216815
08/24/2023 at 8:57 AM #219611ENTRYBAR = BarIndex – TRADEINDEX[0], on the first bar (with 10000 preloaded bars), will evaluate to 10000 – 0 = 10000.
Try using DEFPARAM PreLoadBars = 0.
1 user thanked author for this post.
08/24/2023 at 9:53 AM #219651ENTRYBAR = BarIndex – TRADEINDEX[0], on the first bar (with 10000 preloaded bars), will evaluate to 10000 – 0 = 10000.
Try using DEFPARAM PreLoadBars = 0.
Tryed this now but still dont work.
clerad upp the code a bitt, but same error.
ENTRYBARlong = BarIndex – TRADEINDEX
ENTRYBARshort = BarIndex – TRADEINDEX
LP75ATlong = LP75[ENTRYBARlong]
HP75ATlong = HP75[ENTRYBARlong]
LP75ATshort = LP75[ENTRYBARshort]
HP75ATshort = HP75[ENTRYBARshort]
LP500ATlong = LP500[ENTRYBARlong]
HP500ATlong = HP500[ENTRYBARlong]
LP500ATshort = LP500[ENTRYBARshort]
HP500ATshort = HP500[ENTRYBARshort]
I think you would need to post your full code for anybody to add any meaningful suggestions to help.
I’ve had a few recently of the same Reported Error as you are seeing and which turned out to be nothing to do with ‘not enough historical’ bars etc. See the link below …
https://www.prorealcode.com/topic/long-time-to-run-system-code-causes-rejection/#post-216815
Read that tread but dident find any solution?
Thanks for the quick help 🙂
08/24/2023 at 10:31 AM #219714Sorry for mispelling TRADEINDEX, it always requires parentheses, not brackets, such as graph TRADEINDEX(0).
In case of (0), it can be omitted.
08/24/2023 at 10:38 AM #219719Another source of error could be the timeframes involved.
If you are calculating the Average500 on a 1-hour timeframe, but your default TF is 1-minute, then it will need 500*60-minute preloaded bars, which yields 30K bars, thus exceeding the max preloaded bars limit. Of cource that tally will even be greater if you calculate the indicator on a greater TF (even a 30-minute TF should exceed the limit, as 500*30 minutes = 15K).
Try reducing 500 one step at a time to reach an acceptable limit.
08/24/2023 at 10:49 AM #219721Tryed it with Tradeindex – barindex too, no () or []. Same error in live traiding.
Im on one time frame only, its all in the 10min graf.
Just tryed it with preloadbars=0 and same error.
My standard from before was preloadbars=1000.
The purpuse off the code is to use the value off LP75 (lowest close off past 75 bars) at entry off a long position as a exit, and other things.. It works as intenden in backtesting.
I sent an error repport and email to PRT support, but will keep trying.
08/24/2023 at 11:05 AM #21972208/24/2023 at 11:15 AM #219725Will try it later (cant gett on my computer at the moment)
Must be something on the backend that stopps it on live when i asign variable to a variabel instead of a specific bar.
Its the only things thats differnet from before.
Earlyer versions that dont have this works and is running live now.
I have an IG account btw.
08/24/2023 at 2:40 PM #219742Try adding below directly under your Defparam’s.
123If NOT Longonmarket ThenBuy at MarketEndifAs a test, just try it to see if the Rejection / System stoppages cease?
Same result when i try to force buy, crasches before it places an order.
Havent learn how to work with arrays, have anyone tryed that to gett around this problem?
Im out off ideas so will wait for what the support team says.
08/24/2023 at 4:22 PM #219749Post their answer, whenever you get one. It could help.
08/25/2023 at 8:09 PM #219790Found a solution to my problem.
ENTRYBARlong = BarsSince(LongTriggered[1])
ENTRYBARshort = BarsSince(ShortTriggered[1])
Instead off Barindex – Tradeindex i use BarsSince and then gott a new error message:
The trading system was stopped because the program used a negative or zero offset (ex: close[-10]) during the evaluation of the last candlestick. You can add protections to your code to prevent negative or zero offsets then backtest the system to check the correction.
So i added this code so ENTRYBARlong/short wont be zero:
IF ENTRYBARlong < 1 THEN
ENTRYBARlong = 1
ENDIFIF ENTRYBARshort < 1 THEN
ENTRYBARshort = 1
ENDIFOnly tested the stratergy in a 1min graf for 2 bars so see if its runing, so dont know longer term yet. But it seems to have fixed the problem.
2 users thanked author for this post.
09/04/2023 at 9:16 AM #220293Gott this reply from the support them, so inline with the sulution i found.
Thank you for your feedback. Here is the reply of our Coding team regarding what might have been the issue: they assume it comes from those two lines:
ENTRYBARlong = BarIndex – TRADEINDEX
ENTRYBARshort = BarIndex – TRADEINDEXat the beginning of the computations since there haven’t been any trades yet, so tradeindex=0 and entrybarlong=entrybarshort=barindex.
If the following instructions calculations’ fail on the first candle of the history, this could explain why the strategy got interrupted.1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on