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

Acces another TimeFrame (1minute) without opening it

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

    Acces another TimeFrame (1minute) without opening it

    Hi again!

    One simple question:

    Is it possible to acces the data from TimeFrame from current Instrument, without opening it in the same chart?

    My idea:
    I'm in a chart, i.e. at 60 minute TF.
    With a DrawingTool I select 2 points of this chart.
    Having selected them, I can know their Time
    With this Time, can I know wich bar possition it is in another TimeFrame (in this case I want it in 1 Minute)?

    As I'm with a DrawingTool I don't want to open a 1 minute chart on this window.....

    Thx!



    #2
    Hello arston,

    Thanks for your post.

    From a DrawingTool, the attached data series can be found using GetAttachedToChartBars(). This ChartBars could be used with the ChartControl.GetXByValue() method to get an X coordinate and then you can use ChartBars.GetBarIdxByX() with another ChartBars to get the bar index on that other data series.

    To find another ChartBars on the chart, you will want to loop through the ChartObjects collection and find your ChartBars. For example:

    Code:
    Chart chartWindow = Window.GetWindow(chartControl.Parent) as Chart;
    foreach (NinjaTrader.Gui.Chart.ChartPanel panel in chartWindow.ActiveChartControl.ChartPanels)
    {
        foreach (Gui.NinjaScript.IChartObject thisObject in panel.ChartObjects)
        {
            if (thisObject is ChartBars)
            {
                ChartBars myFoundChartBars = thisObject as ChartBars;
                if (myFoundChartBars.Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Minute 
                    && myFoundChartBars.Bars.BarsPeriod.Value == 1)
                    Print("1 Minute Data Series found");
            }
        }
    }
    ChartBars.GetBarIdxByX() - https://ninjatrader.com/support/help...tbaridxbyx.htm

    ChartControl.GetXByBarIndex() - https://ninjatrader.com/support/help...bybarindex.htm

    GetAttachedToChartBars() - https://ninjatrader.com/support/help...ochartbars.htm

    ChartBars - https://ninjatrader.com/support/help.../chartbars.htm

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim,

      Thanks,

      But the question is: on my chart (or window), do I need to have the 1 minute TF bar chart?, or can I only have one chart (i.e. 60 minute) and from this only bar chart on the window, I can access the 1 minute bar data series (Information)?

      Because I don't want to have the 1 minute series open......

      Thx,

      Comment


        #4
        Hello arston,

        Thanks for clarifying.

        The bars data will have to exist somewhere. You could make a BarsRequest from the Drawing Tool to make the data available if it is not already, or you could find it on the chart like in post #2.

        Keep in mind, BarsRequests are asynchronous. After making a BarsRequest, your script will continue while the bars being requested will be processed on another thread. Further notes and example code for a BarsRequest is included in the documentation page below.

        BarsRequest - https://ninjatrader.com/support/help...arsrequest.htm

        Please let us know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        21 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X