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

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
    Brandon H.NinjaTrader Customer Service

    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

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Haiasi, 04-25-2024, 06:53 PM
      2 responses
      17 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      5 views
      0 likes
      Last Post Creamers  
      Started by Segwin, 05-07-2018, 02:15 PM
      12 responses
      1,786 views
      0 likes
      Last Post Leafcutter  
      Started by poplagelu, Today, 05:00 AM
      0 responses
      3 views
      0 likes
      Last Post poplagelu  
      Started by fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,408 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Working...
      X