Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

doubt in AvgFillPrice..????

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

    doubt in AvgFillPrice..????

    hi i have one doubt
    #region Variables
    private IOrder entryOrder = null;

    protected override void OnBarUpdate()
    {
    .....
    ...
    ....

    if( entryOrder == null && c <= b)

    {
    entryOrder = EnterLong();

    Print("a=" + entryOrder.AvgFillPrice);

    }

    everything flows correctly and executes but

    for a= entryOrder.AvgFillPrice as i mention in print commd .. its not printing the value just printing 0 y its not printing the price value

    #2
    Are you running the strategy in CaclualteOnBarClose false or true?

    There may be a bit of a delay in getting the AvgFillPrice after your entry order is executed depending on when OBU() is called.

    With that known, you may want to start checking for this variable in the OnExecution() event handler which will be updated every time there is an execution detected:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Are you running the strategy in CaclualteOnBarClose false or true?
      yes im using CaclualteOnBarClose true

      protected override void OnExecution(IExecution execution)
      i didnt add this part in my program shld i have to add this

      Comment


        #4
        Originally posted by DealI View Post
        hi i have one doubt
        #region Variables
        private IOrder entryOrder = null;

        protected override void OnBarUpdate()
        {
        .....
        ...
        ....

        if( entryOrder == null && c <= b)

        {
        entryOrder = EnterLong();

        Print("a=" + entryOrder.AvgFillPrice);

        }

        everything flows correctly and executes but

        for a= entryOrder.AvgFillPrice as i mention in print commd .. its not printing the value just printing 0 y its not printing the price value
        At the time that the Print statement is executed, immediately after the entry, the order is unlikely to have been filled, so the AvgFillPrice would be zero.

        You probably want to check this when you have a position, so check for that first.

        Code:
        if (Position.MarketPosition != MarketPosition.Flat)
        {
        //do stuff here;
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ScottWalsh, Today, 04:29 PM
        0 responses
        4 views
        0 likes
        Last Post ScottWalsh  
        Started by rtwave, 04-12-2024, 09:30 AM
        2 responses
        21 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by tsantospinto, 04-12-2024, 07:04 PM
        5 responses
        69 views
        0 likes
        Last Post tsantospinto  
        Started by cre8able, Today, 03:20 PM
        0 responses
        7 views
        0 likes
        Last Post cre8able  
        Started by Fran888, 02-16-2024, 10:48 AM
        3 responses
        49 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Working...
        X