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 geddyisodin, Yesterday, 05:20 AM
      8 responses
      51 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      10 responses
      36 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by DayTradingDEMON, Today, 09:28 AM
      4 responses
      24 views
      0 likes
      Last Post DayTradingDEMON  
      Started by George21, Today, 10:07 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by Stanfillirenfro, Today, 07:23 AM
      9 responses
      25 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X