Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IOrder

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

    IOrder

    I got the BreakEvenWizardExample from the forum and its great. I have one question.
    How can I use for break-even calculation the IOrder average price instead of Position.AvgPrice.
    I tried the following changes but it does not work

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>

    private IOrder Entry = null;
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Position.MarketPosition == MarketPosition.Flat)
    {

    EnterLong(DefaultQuantity, "Entry");
    IOrder Entry = EnterLong("Entry");
    Variable0 = Close[0] + BreakEvenTrigger * TickSize;
    Variable1 = Close[0] + InitialStopDistance * TickSize;
    Variable2 = 0;
    Variable3 = 0;


    }

    // Condition set 2
    if (Position.MarketPosition == MarketPosition.Long
    && Variable2 == 0)
    {
    Variable0 = Entry.AvgFillPrice + BreakEvenTrigger * TickSize;
    Variable2 = 1;
    }

    // Condition set 3
    if (Position.MarketPosition == MarketPosition.Long
    && Close[0] >= Variable0
    && Variable3 == 0)
    {
    Variable1 = Entry.AvgFillPrice;
    DrawDiamond("My diamond" + CurrentBar, false, 0, Low[0] + -3 * TickSize, Color.DarkCyan);
    Variable3 = 1;
    }

    // Condition set 4
    if (Position.MarketPosition == MarketPosition.Long)
    {
    ExitLongStop(Variable1, "Exit", "Entry");

    #2
    Hello flexi,

    Thank you for your post.

    What are you seeing from the strategy's performance that is not working or unexpected?

    Comment


      #3
      It is not calculating the stop and the breakeven in the backtesting. I am assuming that
      I am missing something regarding the IOrder.

      Comment


        #4
        Hello flexi,

        Thank you for your response.

        Please attach the .cs file for the strategy to your response so I may test it on my end. you will find the file in the following directory on your PC: (My) Documents\NinjaTrader 7\bin\Custom\Strategy.

        Comment


          #5
          this is the file.
          Basicly I wanted breakeven to be calculated by IOrder and not average position size
          Attached Files

          Comment


            #6
            Hello flexi,

            Thank you for your response.

            I will test this on my end and follow up with you when I have additional information.

            Comment


              #7
              Hello flexi,

              Thank you for your patience.

              Please try the attached strategy.
              Attached Files

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              670 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              379 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              111 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              575 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              582 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X