Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnStateChange problems compiling

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

    OnStateChange problems compiling

    I found a indicator that on the OnStateChange in this part:
    if (base.get_State() == 1)

    When I compile the indicator it says that cannot explicitly call operator
    And I searched in the documentation and there I found that know we have to use just State, but
    what would be the other option of == 1, cause in the documentation it doesn't say which function
    returns a number

    #2
    Hello Niels,

    Thank you for your reply.

    base.get_State doesn't look like something that would be supported, can you give a larger code sample of your whole OnStateChange() method?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      if (base.get_State() == 1)
      {
      code
      return;
      }
      if (base.get_State() != 7)
      {
      if (base.get_State() == 8)
      {
      foreach (Account all in Account.get_All())
      {
      all.remove_ExecutionUpdate(new EventHandler<ExecutionEventArgs>(this.AccountExecu tionUpdated));
      }
      this.UpdateLastActivity();
      }
      return;
      }​

      Comment


        #4
        Where says base.get_Sate() == 1 in that if has the next code
        base.set_Description("Save your trading");
        base.set_Name("SIT");
        base.set_Calculate(0);
        base.set_IsOverlay(false);
        base.set_DisplayInDataBox(true);
        base.set_DrawOnPricePanel(true);
        base.set_DrawHorizontalGridLines(true);
        base.set_DrawVerticalGridLines(true);
        base.set_PaintPriceMarkers(true);
        base.set_ScaleJustification(1);
        base.set_IsSuspendedWhileInactive(true);
        return;

        I don't know if that code is from an older version, what I can change in each if to be able to compile the script​

        Comment


          #5
          Hello Niels,

          Thank you for your reply.

          This code does not look human written and it's getting the State as an Enum. This wouldn't be valid - you would need to use the actual properties.

          I would take a look at our help guide on OnStateChange for the correct properties you would need as well as the various states:



          Thanks in advance; I look forward to assisting you further.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            and how can I know which property put instead of the number?

            Comment


              #7
              Niels3200 You will find the most effective way to determine what is needed to make the indicator work is to actually provide the entire indicator code here, if you are prepared to do that. That will give the NinjaTrader Support Team and other knowledgeable contributors an opportunity to understand the situation and give you the best advice.

              Thanks.
              Multi-Dimensional Managed Trading
              jeronymite
              NinjaTrader Ecosystem Vendor - Mizpah Software

              Comment


                #8
                jeronymite yeah here you have all the section of OnStateChange(), according with the documentation I could guess that the OnStateChange() has 8 different parameters, oh well the State have it. And I wanna believe using the examples, that for example the number 1 could be replaced by the first parameter SetDefault, and so on. So the number 7 could be RealTime. What do you think?
                This is an indicator to save each trade to an .txt file


                protected override void OnStateChange()
                {
                if (base.get_State() == 1)
                {
                base.set_Description("Save your trades.");
                base.set_Name("STI");
                base.set_Calculate(0);
                base.set_IsOverlay(false);
                base.set_DisplayInDataBox(true);
                base.set_DrawOnPricePanel(true);
                base.set_DrawHorizontalGridLines(true);
                base.set_DrawVerticalGridLines(true);
                base.set_PaintPriceMarkers(true);
                base.set_ScaleJustification(1);
                base.set_IsSuspendedWhileInactive(true);
                this.AutomationToken = string.Empty;
                return;
                }
                if (base.get_State() != 7)
                {
                if (base.get_State() == 8)
                {
                foreach (Account all in Account.get_All())
                {
                all.remove_ExecutionUpdate(new EventHandler<ExecutionEventArgs>(this.AccountExecu tionUpdated));
                }
                this.UpdateLastActivity();
                }
                return;
                }
                this.REQUESTS = new RequestController();
                this.RegisteredTrades = new List<string>();
                foreach (Account account in Account.get_All())
                {
                account.add_ExecutionUpdate(new EventHandler<ExecutionEventArgs>(this.AccountExecu tionUpdated));
                }
                this.RetrieveRegisterTrades();
                Task.Run(() => this.ReviewLatestTrades());
                Task.Run(() => this.ReviewHistoricTrades());
                this.UpdateLastActivity();
                }​

                Comment


                  #9
                  Hello Niels3200,

                  Thank you for your reply.

                  This code wouldn't be valid or supported. I would suggest looking at existing indicators in the NinjaScript Editor window, such as the SMA indicator, for a basic example of proper indicator structure - you would instead need to create the indicator using the format demonstrated in the built in indicators.

                  Please let us know if we may be of further assistance to you.
                  Kate W.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  166 responses
                  2,234 views
                  0 likes
                  Last Post sidlercom80  
                  Started by thread, Yesterday, 11:58 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post thread
                  by thread
                   
                  Started by jclose, Yesterday, 09:37 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post jclose
                  by jclose
                   
                  Started by WeyldFalcon, 08-07-2020, 06:13 AM
                  10 responses
                  1,414 views
                  0 likes
                  Last Post Traderontheroad  
                  Started by firefoxforum12, Yesterday, 08:53 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post firefoxforum12  
                  Working...
                  X