Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to obtain Time in Force setting from Chart Trader

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

    How to obtain Time in Force setting from Chart Trader

    From NinjaScript I can use ChartControl to read most parameters from Chart Trader thus:

    account = ChartControl.OwnerChart.ChartTrader.Account;
    instrument = ChartControl.OwnerChart.ChartTrader.Instrument;
    size = ChartControl.OwnerChart.ChartTrader.Quantity;

    However, there is no comparable definition for Time in Force. I'm able to identify the ChartTraderControlTIFComboBox but nothing I've done here works to read the parameter. And in any case, what I need is the TIF enumerator, not the name text. Any suggestions?

    #2
    Hello jvanelli,

    Thank you for your post.

    ChartTraderControlTIFSelector could be used to get the Time in Force field. The code to accomplish this would look something like this.

    else if (State == State.Historical)
    {
    ChartControl.Dispatcher.InvokeAsync(new Action(() => {
    TifSelector tif = Window.GetWindow(ChartControl.OwnerChart).FindFirs t("ChartTraderControlTIFSelector") as TifSelector;
    Print(tif.GtdDate);
    }));
    }

    I have also attached an example strategy that demonstrates printing the TIF to a NinjaScript Output window (New > NinjaScript Output). When we set the TIF field in Chart Trader to GTD and enable the strategy, we get a print for the TIF date and time.

    Please let us know if we may assist further.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks Brandon. Turns out I was pretty close, but posted my query in the wrong location (should have been Indicator Development). In any case, your suggestion got me across the line. What I needed to make this work with my indicator was to include the NinjaTrader.Gui.Tools namespace, cast TIF as TimeInForce, and then within ... InvokeAsync(new Action):

      NinjaTrader.Gui.Tools.TifSelector tifSelector = Window.GetWindow(ChartControl.OwnerChart).FindFirs t("ChartTraderControlTIFSelector") as TifSelector;
      TIF = tifSelector.SelectedTif;

      Works perfectly.

      Comment


        #4
        Hi Brandon,
        On a related note, how to obtain current bid/ask price from chart trader ?
        thanks

        Comment


          #5
          Ask and bid updates can be reliably obtained from OnMarketData().

          Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          547 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          323 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          99 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          543 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          545 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X