trading stopped due to defparam Preloadbars = 10000 issue
09/05/2023 at 10:56 PM #220385
My code has been working fine on Demo and also yesterday on live trading. I am trying to run it on the 5 min US500 on IG platform in the UK. From today (5.9.2023) it has been stopping when used for live trading by giving the infamous ” insufficient historical data loaded to calculate at least one indicator … try DEFPARAM preloadbars = 10000″.
I have been instructing the “DEFPARAM preloadbars = 10000” from the offset as I have run into this issue before. I am using several indicators in my code and the one with the longest period is a TEMA (540).
I am using PRT v10.3
Thanks in advance09/06/2023 at 9:28 AM #22039509/06/2023 at 9:37 AM #220398
Alternatively submit a Technical Report direct to PRT using Help > Help Center > I’m having a Technical Problem. (Help > etc on the PRT Platform).
Best is to submit Report as above and continue yourself also re NO Call Indicators etc.09/06/2023 at 9:53 AM #220403
The issue lies in these two lines:12c5 = (indicator7 > indicator8)c6 = (indicator9 > indicator10)
because ProOrder has to multiply 240 periods (Ema) by 120 or 98.
Since an EMA requires roughly twice its periods (in this case about 450 periods) for its calculations, the two multiplications return results well exceeding 10k.
Try reducing those two lookback values or try using an IF…ENDIF to make sure trading starts AFTER 55K bars (maybe a bit less, it’s just a matter of trying different values):123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109DEFPARAM Preloadbars = 10000// 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 = 010000// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 213000// Prevents the system from placing new orders to enter the market or increase position size after the specified timeIF BarIndex > 55000 THENnoEntryAfterTime = 210000timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0IF Not OnMarket THENBreakEven0 = 0ELSIF LongOnMarket THENIF (close - Tradeprice) >= (1 * pipsize) THENBreakEven0 = TradePrice - 2 * pipsizeENDIFIF BreakEven0 THENSELL AT BreakEven0 STOPENDIFENDIFIF Not OnMarket THENBreakEven4 = 0ELSIF LongOnMarket THENIF (close - Tradeprice) >= (2 * pipsize) THENBreakEven4 = TradePrice + 1 * pipsizeENDIFIF BreakEven4 THENSELL AT BreakEven4 STOPENDIFENDIFIF Not OnMarket THENBreakEven1 = 0ELSIF LongOnMarket THENIF (close - Tradeprice) >= (4 * pipsize) THENBreakEven1 = TradePrice + 3 * pipsizeENDIFIF BreakEven1 THENSELL AT BreakEven1 STOPENDIFENDIFIF Not OnMarket THENBreakEven2 = 0ELSIF LongOnMarket THENIF (close - Tradeprice) >= (6 * pipsize) THENBreakEven2 = TradePrice + 5 * pipsizeENDIFIF BreakEven2 THENSELL AT BreakEven2 STOPENDIFENDIFIF Not OnMarket THENBreakEven3 = 0ELSIF LongOnMarket THENIF (close - Tradeprice) >= (9 * pipsize) THENBreakEven3 = TradePrice + 7 * pipsizeENDIFIF BreakEven3 THENSELL AT BreakEven3 STOPENDIFENDIF// Conditions to enter long positionsindicator1, ignored = CALL "DPO-Detrended Price Oscillator"[30, 1, 1](close)userindic1, ignored = CALL "DPO-Detrended Price Oscillator"[30, 1, 1](close)indicator2 = DEMA(userindic1)c1 = (indicator1 CROSSES OVER indicator2)indicator3 = ExponentialAverage(MoneyFlowIndex)indicator4 = ExponentialAverage(MoneyFlowIndex)c2 = (indicator3 >= indicator4)indicator5 = MoneyFlowIndexc3 = (indicator5 > 30)indicator6 = CALL "Choppiness index"(close)c4 = (indicator6 <= 70)indicator7 = ExponentialAverage(close)indicator8 = ExponentialAverage(close)c5 = (indicator7 > indicator8)indicator9 = ExponentialAverage(close)indicator10 = ExponentialAverage(close)c6 = (indicator9 > indicator10)indicator11 = TEMA(close)c7 = (close >= indicator11)IF (c1 AND c2 AND c3 AND c4 AND c5 AND c6 AND c7) AND timeEnterAfter AND not daysForbiddenEntry THENBUY 1 PERPOINT AT MARKETENDIF// Conditions to exit long positionsindicator12 = DEMA(MoneyFlowIndex)indicator13 = DEMA(MoneyFlowIndex)c8 = (indicator12 CROSSES UNDER indicator13)IF c8 THENSELL AT MARKETENDIF// Stops and targetsSET STOP pLOSS 5SET TARGET pPROFIT 12ENDIF
The main issue is when you launch it in autotrading… it’ll wait quite many days before the trading starts!09/06/2023 at 7:57 PM #22046509/06/2023 at 7:59 PM #22046609/17/2023 at 9:49 PM #221179