trading stopped due to defparam Preloadbars = 10000 issue

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #220385 quote
    jjduga
    Participant
    New

    Hello everyone.

    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 advance

    DPO-code.itf
    #220395 quote
    GraHal
    Participant
    Master

    Try putting the code for the Indicator in the strategy (and so not calling the Indicator).

    Let us know how you get on.

    jjduga thanked this post
    #220398 quote
    GraHal
    Participant
    Master

    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.

    jjduga thanked this post
    #220403 quote
    robertogozzi
    Moderator
    Master

    The issue lies in these two lines:

    c5 = (indicator7 > indicator8[120])
    c6 = (indicator9 > indicator10[98])

    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):

    DEFPARAM Preloadbars = 10000
    // Definition of code parameters
    DEFPARAM 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" time
    DEFPARAM FLATAFTER = 213000
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    IF BarIndex > 55000 THEN
    noEntryAfterTime = 210000
    timeEnterAfter = time < noEntryAfterTime
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    IF Not OnMarket THEN
    BreakEven0 = 0
    ELSIF LongOnMarket THEN
    IF (close - Tradeprice) >= (1 * pipsize) THEN
    BreakEven0 = TradePrice - 2 * pipsize
    ENDIF
    IF BreakEven0 THEN
    SELL AT BreakEven0 STOP
    ENDIF
    ENDIF
    
    IF Not OnMarket THEN
    BreakEven4 = 0
    ELSIF LongOnMarket THEN
    IF (close - Tradeprice) >= (2 * pipsize) THEN
    BreakEven4 = TradePrice + 1 * pipsize
    ENDIF
    IF BreakEven4 THEN
    SELL AT BreakEven4 STOP
    ENDIF
    ENDIF
    
    IF Not OnMarket THEN
    BreakEven1 = 0
    ELSIF LongOnMarket THEN
    IF (close - Tradeprice) >= (4 * pipsize) THEN
    BreakEven1 = TradePrice + 3 * pipsize
    ENDIF
    IF BreakEven1 THEN
    SELL AT BreakEven1 STOP
    ENDIF
    ENDIF
    
    IF Not OnMarket THEN
    BreakEven2 = 0
    ELSIF LongOnMarket THEN
    IF (close - Tradeprice) >= (6 * pipsize) THEN
    BreakEven2 = TradePrice + 5 * pipsize
    ENDIF
    IF BreakEven2 THEN
    SELL AT BreakEven2 STOP
    ENDIF
    ENDIF
    
    IF Not OnMarket THEN
    BreakEven3 = 0
    ELSIF LongOnMarket THEN
    IF (close - Tradeprice) >= (9 * pipsize) THEN
    BreakEven3 = TradePrice + 7 * pipsize
    ENDIF
    IF BreakEven3 THEN
    SELL AT BreakEven3 STOP
    ENDIF
    ENDIF
    
    // Conditions to enter long positions
    indicator1, ignored = CALL "DPO-Detrended Price Oscillator"[30, 1, 1](close)
    userindic1, ignored = CALL "DPO-Detrended Price Oscillator"[30, 1, 1](close)
    indicator2 = DEMA[12](userindic1)
    c1 = (indicator1 CROSSES OVER indicator2)
    indicator3 = ExponentialAverage[25](MoneyFlowIndex[14])
    indicator4 = ExponentialAverage[3](MoneyFlowIndex[14])
    c2 = (indicator3 >= indicator4)
    indicator5 = MoneyFlowIndex[14]
    c3 = (indicator5 > 30)
    indicator6 = CALL "Choppiness index"[25](close)
    c4 = (indicator6 <= 70)
    indicator7 = ExponentialAverage[240](close)
    indicator8 = ExponentialAverage[240](close)
    c5 = (indicator7 > indicator8[120])
    indicator9 = ExponentialAverage[240](close)
    indicator10 = ExponentialAverage[240](close)
    c6 = (indicator9 > indicator10[98])
    indicator11 = TEMA[540](close)
    c7 = (close >= indicator11)
    
    IF (c1 AND c2 AND c3 AND c4 AND c5 AND c6 AND c7) AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator12 = DEMA[5](MoneyFlowIndex[14])
    indicator13 = DEMA[30](MoneyFlowIndex[14])
    c8 = (indicator12 CROSSES UNDER indicator13)
    
    IF c8 THEN
    SELL AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 5
    SET TARGET pPROFIT 12
    ENDIF

    The main issue is when you launch it in autotrading… it’ll wait quite many days before the trading starts!

    GraHal and jjduga thanked this post
    #220465 quote
    jjduga
    Participant
    New

    I Tried this but it posted me to this forum. My PRT help centre is managed by IG. Not sure if it is the same for everyone.

    In any case I am more than happy to tap into the forum’s knowledge. Many thanks

    #220466 quote
    jjduga
    Participant
    New

    Grazie Roberto

    I will give this a go. Thanks to GraHal too.

    I will keep you posted. Won’t be able to give it a go until the weekend due to work though. But thanks both

    GraHal and robertogozzi thanked this post
    #221179 quote
    jjduga
    Participant
    New

    The issue is now resolved after following Roberto’s advise.

    robertogozzi thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

trading stopped due to defparam Preloadbars = 10000 issue


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
jjduga @jjduga Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by jjduga
2 years, 5 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 09/05/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...