ProOrder Strategy Suddenly Stopped Working This Week

Forums ProRealTime English forum ProOrder support ProOrder Strategy Suddenly Stopped Working This Week

Viewing 6 posts - 1 through 6 (of 6 total)
  • #248577

    Hi everyone,

    I'm hoping for some help with a very strange issue. I have a time-based automated strategy in ProOrder that was running perfectly last week. However, as of this Monday, it has completely stopped executing any trades.

    The issue is not a simple error in the code, because even an extremely simple test code, designed to place just one trade at a specific time, also fails to execute. This suggests a more fundamental problem.

    Here is the **minimal test code** that fails to work:

    // Minimal Test Code
    // I set the TargetTime to a few minutes in the future for testing.
    TargetTime = 140000 // e.g., Set to 2:00 PM

    ONCE TradeAttempted = 0

    IF Time >= TargetTime AND TradeAttempted = 0 THEN
    BUY 0.1 CONTRACT AT MARKET
    TradeAttempted = 1
    ENDIF

    For complete context, here is the original, more complex strategy that **was working correctly last week** but now also fails.

    // ProOrder automated trading – USDJPY
    // Time-based entry management
    // Pair: USDJPY
    // Timezone: JST (Japan Standard Time)

    // ===== Main Settings =====
    DEFPARAM CumulateOrders = False // Do not cumulate positions (Important)
    DEFPARAM PreLoadBars = 0 // Minimize pre-loaded bars
    DEFPARAM FlatBefore = 060000 // Flatten before market open
    DEFPARAM FlatAfter = 235900 // Flatten after market close

    // ===== Common Settings =====
    USDJPYEntryTimeWindow = 10 // Entry time window (seconds)
    USDJPYTotalEntries = 13 // Total number of entries

    // ===== Debug Mode =====
    USDJPYDebugMode = 0 // Set to 1 for detailed logs

    // ===== USDJPY Entry Table (in chronological order) =====
    // IMPORTANT: Must be set in chronological order.
    // Times are set in JST.

    // — Entry 1: 08:55:00 BUY —
    USDJPYEntryTime1 = 085500
    USDJPYExitTime1 = 085800
    USDJPYDirection1 = 1 // 1=BUY, -1=SELL
    USDJPYLot1 = 0.1
    USDJPYTP1 = 0 // pips
    USDJPYSL1 = 15 // pips

    // — Entry 2: 09:10:00 BUY —
    USDJPYEntryTime2 = 091000
    USDJPYExitTime2 = 091100
    USDJPYDirection2 = 1
    USDJPYLot2 = 0.1
    USDJPYTP2 = 0
    USDJPYSL2 = 15

    // … (Entries 3 through 12 omitted for brevity) …

    // — Entry 13: 18:53:00 BUY —
    USDJPYEntryTime13 = 185300
    USDJPYExitTime13 = 185800
    USDJPYDirection13 = 1
    USDJPYLot13 = 0.1
    USDJPYTP13 = 0
    USDJPYSL13 = 15

    // ===== State Management =====
    ONCE USDJPYNextEntryIndex = 1 // Index for the next entry to execute
    ONCE USDJPYActiveEntry = 0 // Currently active entry number
    ONCE USDJPYDailyReset = 0 // Daily reset flag
    ONCE USDJPYPositionClosed = 0 // Position closed flag

    // ===== Monitor for Next Entry (only if NOT ONMARKET) =====
    IF NOT ONMARKET THEN
    // Post-close processing
    IF USDJPYPositionClosed = 1 THEN
    USDJPYActiveEntry = 0
    USDJPYPositionClosed = 0
    ENDIF

    // Check for the next entry
    IF USDJPYNextEntryIndex <= USDJPYTotalEntries THEN
    USDJPYCheckEntryTime = 0
    USDJPYCheckDirection = 0
    USDJPYCheckLot = 0

    // Set variables based on entry index
    IF USDJPYNextEntryIndex = 1 THEN
    USDJPYCheckEntryTime = USDJPYEntryTime1
    USDJPYCheckDirection = USDJPYDirection1
    USDJPYCheckLot = USDJPYLot1
    // (ELSIF for entries 2-12 omitted for brevity)
    ELSIF USDJPYNextEntryIndex = 13 THEN
    USDJPYCheckEntryTime = USDJPYEntryTime13
    USDJPYCheckDirection = USDJPYDirection13
    USDJPYCheckLot = USDJPYLot13
    ENDIF

    // Entry time check and execution
    // NOTE: This was failing with both CurrentTime and Time variables.
    IF USDJPYCheckEntryTime > 0 AND CurrentTime >= USDJPYCheckEntryTime AND CurrentTime <= USDJPYCheckEntryTime + USDJPYEntryTimeWindow THEN
    IF USDJPYCheckDirection = 1 THEN
    BUY USDJPYCheckLot CONTRACT AT MARKET
    ELSIF USDJPYCheckDirection = -1 THEN
    SELLSHORT USDJPYCheckLot CONTRACT AT MARKET
    ENDIF
    USDJPYActiveEntry = USDJPYNextEntryIndex
    USDJPYNextEntryIndex = USDJPYNextEntryIndex + 1
    ENDIF

    // Skip if time has passed
    IF USDJPYCheckEntryTime > 0 AND CurrentTime > USDJPYCheckEntryTime + USDJPYEntryTimeWindow THEN
    USDJPYNextEntryIndex = USDJPYNextEntryIndex + 1
    ENDIF
    ENDIF
    ENDIF

    // ===== Position Management =====
    IF ONMARKET AND USDJPYActiveEntry > 0 THEN
    // Get settings for the active entry
    USDJPYMyTP = 0
    USDJPYMySL = 0
    USDJPYMyExitTime = 0

    IF USDJPYActiveEntry = 1 THEN
    USDJPYMyTP = USDJPYTP1
    USDJPYMySL = USDJPYSL1
    USDJPYMyExitTime = USDJPYExitTime1
    // (ELSIF for entries 2-12 omitted for brevity)
    ELSIF USDJPYActiveEntry = 13 THEN
    USDJPYMyTP = USDJPYTP13
    USDJPYMySL = USDJPYSL13
    USDJPYMyExitTime = USDJPYExitTime13
    ENDIF

    // Set TP/SL
    IF USDJPYMyTP > 0 THEN
    SET TARGET PROFIT USDJPYMyTP * PointSize
    ENDIF
    IF USDJPYMySL > 0 THEN
    SET STOP LOSS USDJPYMySL * PointSize
    ENDIF

    // Close by time
    IF CurrentTime >= USDJPYMyExitTime THEN
    IF LONGONMARKET THEN
    SELL AT MARKET
    ENDIF
    IF SHORTONMARKET THEN
    EXITSHORT AT MARKET
    ENDIF
    USDJPYPositionClosed = 1
    ENDIF
    ENDIF

    // ===== Daily Reset =====
    // Reset at 00:00 server time
    IF Hour = 0 AND Minute = 0 AND USDJPYDailyReset = 0 THEN
    USDJPYNextEntryIndex = 1
    USDJPYActiveEntry = 0
    USDJPYPositionClosed = 0
    USDJPYDailyReset = 1
    ENDIF

    // Clear reset flag after 00:01
    IF Hour > 0 OR Minute > 0 THEN
    USDJPYDailyReset = 0
    ENDIF

    The main question remains: why would both a complex, previously-working strategy AND a minimal test strategy suddenly stop working this week?

    Has anyone else experienced this? Any ideas or known platform issues would be greatly appreciated.

     

    #248610

    I was able to resolve this issue myself.
    Changed CurrentTime to use Hour,Minutes.
    Other than that, I don’t know what the problem was, but I am surprised that it suddenly works.
    Thank you very much.

    // ===== ProOrder =====
    // pair: EURUSD
    // Generated: 2025/7/1 19:14:15
    DEFPARAM CumulateOrders = True // Allow multiple positions

    // ===== Entry Table Settings (Hour:Minute only) =====
    // — Entry 1: 18:23 Buy —
    EntryHour1 = 18
    EntryMinute1 = 23
    ExitHour1 = 18
    ExitMinute1 = 24
    Direction1 = 1 // 1=Buy, -1=Sell
    Lot1 = 1
    TP1 = 0 // pips (0=disabled)
    SL1 = 15 // pips

    // ===== Position Management =====
    ONCE Entry1Done = 0

    // ===== Entry 1 =====
    IF Hour = EntryHour1 AND Minute = EntryMinute1 AND Entry1Done = 0 THEN
    IF Direction1 = 1 THEN
    BUY Lot1 CONTRACT AT MARKET
    ELSIF Direction1 = -1 THEN
    SELLSHORT Lot1 CONTRACT AT MARKET
    ENDIF
    // Set Stop Loss in pips
    SET STOP pLOSS SL1
    IF TP1 > 0 THEN
    // Set Take Profit in pips
    SET TARGET pPROFIT TP1
    ENDIF
    Entry1Done = 1
    ENDIF

    // Time-based exit for Entry 1
    IF Hour = ExitHour1 AND Minute = ExitMinute1 AND Entry1Done = 1 THEN
    IF Direction1 = 1 AND LONGONMARKET THEN
    SELL Lot1 CONTRACT AT MARKET
    ELSIF Direction1 = -1 AND SHORTONMARKET THEN
    EXITSHORT Lot1 CONTRACT AT MARKET
    ENDIF
    ENDIF

    // ===== Daily Reset =====
    IF Hour = 0 AND Minute = 0 THEN
    Entry1Done = 0
    ENDIF

    // ===== Position Information Display =====
    totalPositions = COUNTOFPOSITION

    2 users thanked author for this post.
    #248611

    This works fine on a 1-hour TF (DAX):

    as to the other code, pleas append this line to your code:

    you will notice that USDJPYCheckLot is set to 0.1 only from 000000 to 080000 (0am through 8am), but your code won’t enter trades before 060000 (6am).

    Moreover, are you sure 0.1 contracts is allowed for the instrument you are trading?

     

     

     

    2 users thanked author for this post.
    #248612

    BUY 0.1 CONTRACT AT MARKET

    Maybe it is now working because you ceased using above (0.1 Contract) and are now using Lot1 = 1 ?

    What Instrument allows 0.1 Contract?

    EDIT / PS
    Has seems mine and Roberto posts crossed.

    2 users thanked author for this post.
    #248613

    Hi robertogozzi

    Wow, thank you for the fantastic help! Your analysis was spot on.

    I graphed the variable as you said, and you were totally right about the timing issue. But the real ‘aha!’ moment was your question about the contract size. I checked, and you were right, the minimum is 1, not 0.1. That was the root of the problem.

    Seriously, thank you. You’ve saved me a ton of time and frustration. It’s all working now!

    1 user thanked author for this post.
    #248614

    Hi GraHal,

    That was a fantastic catch, thank you so much! You were 100% right, the ‘0.1 Contract’ was an error.

    And yes, you’re right about 0.1 lots being common elsewhere. As you suspected, this particular instrument was the exception and needs a minimum of 1.

    Thanks again for the sharp eye, it was a huge help!

    1 user thanked author for this post.
Viewing 6 posts - 1 through 6 (of 6 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login