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

Accessing to external Indicator and plots by names

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

    Accessing to external Indicator and plots by names

    Hello,

    They are a way for access to a plot who exist in a chart from another indicator only with the indicator name and it's plot name ?

    The idea is to make an historical data recorder indicator who record in a file or sql database plots of indicators presents in a chart.

    I'm can known indicators on chart by parsing the saved workspace xml file and retrived indicators names and plots names.

    But how acces to data of indictors in a chart with only two strings: indicator name and plot name ?

    If it's possible, i'm can avoid adding accessors in each indicator i'm want be able to record.

    Thanks
    Last edited by Twanaar; 10-16-2015, 03:57 PM.

    #2
    Hello Twanaar,

    Thank you for writing in. With just strings of the indicator name and the plot name you would likely need to use reflection to check if a given indicator contained a property by the name of the plot name so you could cast it correctly.

    Here is some general information on what is natively available to you with NinjaScript:
    Code:
    protected override void OnBarUpdate()
    {
    	foreach(Indicator i in ChartControl.Indicators) //Rotate through each indicator on the chart
    	{
                            //Example #1
    		Print(i.Name + ": " + i.Values[0][0]);
    
                            //Example #2
    		if(i.Name == "MACD") //Check if is a specific indicator
    		{
    			MACD i2 = i as MACD; //Cast the generic Indicator to that specific type
    			Print("TestMACD: " + i2.Diff[0]); //Access the plot by name
    		}
    	}
    }
    Hopefully this helps to give you a basic idea of where to begin. More information on Values[0][0] can be found in our help guide here: http://ninjatrader.com/support/helpG...ightsub=values

    Please let me know if I may be of further assistance.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Thanks, it's exactly what i'm need.

      Comment


        #4
        Synchronisation problem between indicators

        Hello,

        With your previous help, i have now a working recorder, but i’m think having a synchronization problem: how i’m can insure all others indicators have processing a OnBarUpdate before collect and record data of them with my recorder indicateur ?
        Are events for this or other way for insure the synchronisation ?
        Thanks.


        I have the same question about making a strategy script, how insure the strategie code read indicators plots when all have processed the last OnBarUpdate ?

        AlainS
        Last edited by Twanaar; 10-23-2015, 06:44 AM.

        Comment


          #5
          Hi Twanaar,

          When calling an indicator directly this will use the input series of the calling script and will be synchronized.

          For example if I call Print(MACD(12, 26, 9).Avg[0]); the print would be synced with the strategy.

          However, when you are looping through active instances as was suggested by Michael, this does not supply the input series to the indicator and thus they are not in sync.

          Basically, you would need to continuously loop and continue to look for it to be changed as I am not aware of a way to trigger the OnBarUpdate. (OnBarUpdate is triggered automatically by the backend of NinjaTrader)

          But, instead of having a script loop through other indicators, you could instead do this file writing from the indicator itself and this would cause that indicator to only write when OnBarUpdate is called.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Finaly i have a repond later about this, by forcing sync on others instances of indicator by calling Update() methods on them.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alifarahani, Today, 09:40 AM
            6 responses
            36 views
            0 likes
            Last Post alifarahani  
            Started by Waxavi, Today, 02:10 AM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by Kaledus, Today, 01:29 PM
            5 responses
            14 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by Waxavi, Today, 02:00 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by gentlebenthebear, Today, 01:30 AM
            3 responses
            17 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X