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 mattdowns1234, Today, 06:57 PM
      0 responses
      5 views
      0 likes
      Last Post mattdowns1234  
      Started by dgee949, Today, 06:26 PM
      0 responses
      9 views
      0 likes
      Last Post dgee949
      by dgee949
       
      Started by dgee949, Today, 05:58 PM
      0 responses
      11 views
      0 likes
      Last Post dgee949
      by dgee949
       
      Started by thepcmd, Today, 05:14 PM
      0 responses
      24 views
      0 likes
      Last Post thepcmd
      by thepcmd
       
      Started by xmess777, Today, 04:58 PM
      0 responses
      17 views
      0 likes
      Last Post xmess777  
      Working...
      X