Strategy dont take trades

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #264638 quote
    borsoggeborsogge
    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
    JSJS
    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
    borsoggeborsogge
    Participant
    Junior

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

    #264654 quote
    NicolasNicolas
    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
    borsoggeborsogge
    Participant
    Junior

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

    #264708 quote
    NicolasNicolas
    Keymaster
    Legend

    What timeframe and period for the wma now?

    #264709 quote
    borsoggeborsogge
    Participant
    Junior

    WeightedAverage[30], daily time frame

    #264721 quote
    NicolasNicolas
    Keymaster
    Legend

    I made several backtests, and the strategy doesn’t trade a lot, did you compare backtest VS live trading? What order for what instrument should have been opened recently? Thank you.

    #264732 quote
    borsoggeborsogge
    Participant
    Junior

    You have a point there. Since I switched to a higher time frame, the strategy hasn’t taken any new positions when I backtest it. I’ll simply have to wait until I see the backtest take a new position.

    #264733 quote
    NicolasNicolas
    Keymaster
    Legend

    Okay, that explains everything then 😉 Let’s see if new live orders will open in the coming days in that case.

    #264738 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Your system, modified as follows, backtested on DAX with IG, 5-minute timeframe, 50K units, opened 26 trades as from the attached pic:

    TIMEFRAME(Weekly)
    // ======================================================
    // WMA 24     //formerly 8640
    // ======================================================
    
    
    wma8640 = WeightedAverage[24](close)
    
    TIMEFRAME(5 minutes)
    

    I just launched it live (demo account). I will let you know as it opens a trade.



    x-2.jpg x-2.jpg
    #264933 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Finally it took a trade this morning at 10:05:00 on DAX – Germany 40 Cash (5€), 5-minute timeframe.

    It’s the first trade entered since August 28th.



    Iván González thanked this post
    x.jpg x.jpg
    #264934 quote
    borsoggeborsogge
    Participant
    Junior

    It didn´t take a trade for me??

    Wonder why?

    #264944 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Sorry, but I can’t figure out why.

    Which instrument and timeframe did you run it on?


    #264970 quote
    NicolasNicolas
    Keymaster
    Legend

    Did you compare a backtest vs a live trading system through ProOrder?

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Strategy dont take trades


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
borsogge @borsogge Participant
Summary

This topic contains 15 replies,
has 4 voices, and was last updated by borsoggeborsogge
1 month, 1 week ago.

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