Strategy dont take trades

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #264638 quote
    borsogge
    Participant
    Junior

    I have this code and when i backtest it, it seems to work. When i go live i doesn’t take trades. Can anyone help me with the issue?


    // ======================================================
    // RANGE BREAKOUT - PULLBACK - BREAKOUT LONG
    // ======================================================
    //
    // TIMEFRAME: 5 MINUTES
    //
    // RANGE:    09:00 - 09:30
    // ENTRY:    10:00 - 13:00
    //
    // ENTRY SEQUENCE:
    // 1. Price breaks above range high
    // 2. Price returns into the range
    // 3. Pullback is classified by depth
    // 4. Price breaks above range high again
    //
    // PULLBACK FILTER:
    //
    // ALLOWED:
    // 0-25%
    // 50-100%
    //
    // BLOCKED:
    // 25-50%
    //
    // DAILY FILTER:
    // Among the 5 latest completed daily candles:
    // - At least one must be bullish
    // - After that bullish candle, no following candle
    //  may make a lower Low than the previous candle
    //
    // 5-MIN FILTER:
    // Close must be above WMA[8640]
    //
    // STOP:
    // 10 points below range low
    //
    // TARGET:
    // 2R
    //
    // MULTIPLE TRADES PER DAY ALLOWED
    // ======================================================
    
    DEFPARAM CumulateOrders = False
    DEFPARAM Preloadbars = 10000
    
    
    // ======================================================
    // DAILY FILTER
    // ======================================================
    
    TIMEFRAME(Daily)
    
    // Bygg alltid om dailyFilter från scratch varje daglig bar
    // så att den reflekterar det senaste tillståndet
    
    df = 0
    
    // Bullish candle 1 day ago
    IF Close[1] > Open[1] THEN
    IF Low[1] >= Low[2] THEN
    df = 1
    ENDIF
    ENDIF
    
    // Bullish candle 2 days ago
    IF Close[2] > Open[2] THEN
    IF Low[1] >= Low[2] AND Low[2] >= Low[3] THEN
    df = 1
    ENDIF
    ENDIF
    
    // Bullish candle 3 days ago
    IF Close[3] > Open[3] THEN
    IF Low[1] >= Low[2] AND Low[2] >= Low[3] AND Low[3] >= Low[4] THEN
    df = 1
    ENDIF
    ENDIF
    
    // Bullish candle 4 days ago
    IF Close[4] > Open[4] THEN
    IF Low[1] >= Low[2] AND Low[2] >= Low[3] AND Low[3] >= Low[4] AND Low[4] >= Low[5] THEN
    df = 1
    ENDIF
    ENDIF
    
    // Bullish candle 5 days ago
    IF Close[5] > Open[5] THEN
    IF Low[1] >= Low[2] AND Low[2] >= Low[3] AND Low[3] >= Low[4] AND Low[4] >= Low[5] THEN
    df = 1
    ENDIF
    ENDIF
    
    dailyFilter = df
    
    
    // ======================================================
    // RETURN TO 5-MINUTE TIMEFRAME
    // ======================================================
    
    TIMEFRAME(5 minutes)
    
    
    // ======================================================
    // WMA 8640
    // ======================================================
    
    wma8640 = WeightedAverage[8640](close)
    
    
    // ======================================================
    // RESET VID NY HANDELSDAG
    // ======================================================
    
    IF Day <> Day[1] THEN
    
    rangeHigh  = 0
    rangeLow   = 0
    rangeReady  = 0
    
    firstBreak  = 0
    enteredRange = 0
    
    pullbackLow   = 0
    pullbackDepth  = 0
    pullbackPercent = 0
    
    stopsSet = 0
    
    ENDIF
    
    
    // ======================================================
    // SKAPA RANGE 09:00 - 09:30
    // ======================================================
    
    IF Time >= 090000 AND Time < 093000 THEN
    
    IF Time = 090000 THEN
    rangeHigh = High
    rangeLow = Low
    ELSE
    rangeHigh = MAX(rangeHigh, High)
    rangeLow = MIN(rangeLow, Low)
    ENDIF
    
    ENDIF
    
    
    // ======================================================
    // RANGE KLAR (inte förrän 09:30)
    // ======================================================
    
    IF Time >= 093000 AND rangeHigh > 0 THEN
    rangeReady = 1
    ENDIF
    
    
    // ======================================================
    // RANGE SIZE
    // ======================================================
    
    rangeSize = rangeHigh - rangeLow
    
    
    // ======================================================
    // STEG 1
    // FÖRSTA BROTTET ÖVER RANGE-HIGH
    // ======================================================
    
    IF rangeReady = 1 AND firstBreak = 0 THEN
    
    IF High > rangeHigh THEN
    firstBreak  = 1
    pullbackLow = High
    ENDIF
    
    ENDIF
    
    
    // ======================================================
    // STEG 2
    // PRIS KOMMER TILLBAKA IN I RANGEN
    // ======================================================
    
    IF firstBreak = 1 AND enteredRange = 0 THEN
    
    pullbackLow = MIN(pullbackLow, Low)
    
    IF Low <= rangeHigh THEN
    enteredRange = 1
    ENDIF
    
    ENDIF
    
    
    // ======================================================
    // BERÄKNA PULLBACK-DJUP
    // ======================================================
    
    IF firstBreak = 1 AND rangeSize > 0 THEN
    pullbackDepth  = rangeHigh - pullbackLow
    pullbackPercent = (pullbackDepth / rangeSize) * 100
    ENDIF
    
    
    // ======================================================
    // STEG 3
    // ANDRA BROTTET ÖVER RANGE-HIGH
    // ======================================================
    
    IF Time >= 100000 AND Time < 130000 THEN
    
    priceAboveWMA = Close > wma8640
    
    IF dailyFilter = 1 AND rangeReady = 1 AND firstBreak = 1 AND enteredRange = 1 THEN
    
    IF (pullbackPercent >= 0 AND pullbackPercent <= 25) OR (pullbackPercent >= 50 AND pullbackPercent <= 100) THEN
    
    IF High > rangeHigh AND priceAboveWMA THEN
    
    IF NOT ONMARKET THEN
    
    BUY 1 CONTRACT AT MARKET
    
    ENDIF
    
    ENDIF
    
    ENDIF
    
    ENDIF
    
    ENDIF
    
    
    // ======================================================
    // ÅTERSTÄLL SEKVENSEN NÄR POSITION ÖPPNATS
    // Görs separat när ONMARKET är bekräftat
    // ======================================================
    
    IF ONMARKET AND stopsSet = 0 THEN
    
    // Nollställ sekvensen så att nästa trade kan hittas
    firstBreak   = 0
    enteredRange  = 0
    pullbackLow   = 0
    pullbackDepth  = 0
    pullbackPercent = 0
    
    entryPrice = TradePrice
    stopPrice = rangeLow - 10
    risk    = entryPrice - stopPrice
    
    IF risk > 0 THEN
    SET STOP pLOSS risk
    SET TARGET pPROFIT (risk * 2)
    stopsSet = 1
    ENDIF
    
    ENDIF
    
    
    // ======================================================
    // RESET STOP STATUS NÄR POSITIONEN ÄR STÄNGD
    // ======================================================
    
    IF NOT ONMARKET THEN
    stopsSet = 0
    ENDIF
    
    #264639 quote
    JS
    Participant
    Master

    A strong suspect here, in my opinion, is the “WMA[8640]”…

    You are already using “DefParam PreLoadBars=10000”, but it could be that the “weighted average” requires more than 10,000 units to produce a meaningful result…

    You could try using a normal average instead and see if it works then…

    robertogozzi, Iván González and borsogge thanked this post
    #264647 quote
    borsogge
    Participant
    Junior

    Yeah maybe, i will try but i think it might be something else. More ideas than that?

    #264654 quote
    Nicolas
    Keymaster
    Legend

    Also, I suggest moving this moving average to a higher timeframe and thus changing its period to make it shorter, since I imagine that this very long period must correspond to a much shorter average of a daily timeframe?

    This will definitively rule out the possibility of a problem related to the available history.

    robertogozzi and borsogge thanked this post
    #264705 quote
    borsogge
    Participant
    Junior

    I have changed the wma to a higher time frame but the strategy still dont take orders. Any other suggestion?

    #264708 quote
    Nicolas
    Keymaster
    Legend

    What timeframe and period for the wma now?

    #264709 quote
    borsogge
    Participant
    Junior

    WeightedAverage[30], daily time frame

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

Strategy dont take trades


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
borsogge @borsogge Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by borsogge
4 hours, 1 minute ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/24/2026
Status: Active
Attachments: No files
Logo Logo
Loading...