• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

attaching indicators in code

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

    attaching indicators in code

    Hi

    Not sure if this question should be here or in coding...

    I have created a strategy that uses the following code;

    Strategy name : 'Elliot3rdWaveStratV1001

    else if (State == State.DataLoaded)
    {
    // Charts the indicator to the chart
    AddChartIndicator( Elliot3rdWaveV1006(20,5,10000,20,0,1,0,0));
    }

    This creates no problem in my NT8 setup or on another colleagues NT8.

    But when we run this on my bosses NT8 then he gets the following error;
    Strategy 'Elliot3rdWaveStratV1001': Error on calling 'OnStateChange' method: 'AddChartIndicator' cannot be called from this state. Please see the Help Guide article on 'AddChartIndicator' for more information.

    any help appreciated
    Cheers

    #2
    Hello fishbed,

    Thank you for the post.

    I am reviewing your inquiry and will be back with a reply shortly.

    I look forward to assisting further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello fishbed,

      Thank you for your patience.

      This error is due to the indicator calling AddDataSeries(); When we dynamically call a BarsPeriod in State.Configure the data may not have loaded yet and thus the BarsPeriod has not information and fails to call.

      To fix this, pass your own variables for the BarsPeriodType and period. For the BarsPeriodType I would recommend an enum to select the PeriodType and then use the switch and case in the indicator to determine the call to AddDataSeries().

      If questions come up please let me know.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Hi Chris

        Thanks for this.

        However, I am not sure what you mean by this.

        I am not calling AddDataSeries(); from anywhere, is this automatically done when the strategy is loaded and "forces" the indicator to call the AddDataSeries() method? I use this method in other scripts when trying to work in multiple timeframes.

        In my strategy I iniate a call in ")State == State.DataLoaded)" for the indicator the strategy should use and this is what your documents say.

        I need to understand why it is doing what it is doing else I think I will run into this problem again and again. Are you able to provide any sort of example that may clarify this for me.

        Also why would this work on 2 other setups, surely it should be correct or not?

        Thanks

        Comment


          #5
          Hello fishbed,

          Thank you for the follow-up.

          You are adding the indicator correctly, you are also correct in that the indicator you are trying to add is the one calling AddDataSeries().

          If you are able to look at the code for Elliot3rdWaveV1006, please let me know what is happening in State.DataLoaded in the OnStateChange() method.

          I will also need to see the log and trace files for the machine it is not working on.

          Please send the log and trace folders to*platformsupport[at]ninjatrader[dot]com.*
          You can do this by going to the Control Center-> Help-> Mail to Platform Support.
          Please reference the following in the email body:*ATTN CHRISL <paste the forum link here>*

          I look forward to your reply.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Hi Chris

            With regards your question

            "If you are able to look at the code for Elliot3rdWaveV1006, please let me know what is happening in State.DataLoaded in the OnStateChange() method."

            I have no code in this area.

            Will send the log / trace files over later....

            Thanks

            Comment


              #7
              Hello fishbed,

              Under Control Center>Help>About, what version of NT is your bosses computer running?

              I look forward to the log and trace files.
              Alan P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by saeed, Today, 10:20 AM
              3 responses
              12 views
              0 likes
              Last Post koganam
              by koganam
               
              Started by priceisking, Yesterday, 07:44 PM
              1 response
              23 views
              0 likes
              Last Post NinjaTrader_Kate  
              Started by aligator, Today, 02:05 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by rexsole, Today, 11:27 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by alfonso, Today, 10:21 AM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Kate  
              Working...
              X