Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit on 5 minute bar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Exit on 5 minute bar

    Hi,

    I'm trying to exit only in 5 Minute bars in my strategy but i'm getting fill every 1 minute.
    this is my code :

    I added int the initialize : Add(PeriodType.Minute,iBarPeriod);

    OnBarUpdate :

    if (BarsInProgress != 0)
    return;

    if (m_Position == 0)
    {
    if (Closes[1][0] > Opens[1][0])
    {
    openPrc = Instrument.MasterInstrument.Round2TickSize(Closes[1][0]);
    entryOrder = EnterLongLimit(iQty,openPrc,"EnL");
    }

    }
    else if (m_Position > 0)
    {
    trgPrc = Closes[1][0];
    trgPrcMode = CalculationMode.Price;
    SetProfitTarget(trgPrcMode,trgPrc);

    }

    #2
    Hi Igalml,

    Thank you for your post.

    It looks like your primary data series is the 1 minute and you are submitting the profit target to the Close price of the 5 minute which when the 1 minute closes will be the same and exit out of your entry order then the EnterLongLimit will get resubmitted.

    You will need to rework the logic for the SetProfitTarget or set a different price level.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      ty 4 ur reply,

      How can i change the logic of the profittarget?

      Comment


        #4
        I found the solution,
        Ty.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        646 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        367 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        570 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X