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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        65 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        149 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        99 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X