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

Issue with running strategy in analyzer

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

    Issue with running strategy in analyzer

    Hi I have a strategy that i can run in market replay, however its not running in strategy analyzer. Upon opening VS i noticed there is this error to how i call BOP indicator. Could this be the issue? It seems right to me..
    private BOP bopMaster,

    BOPMPeriod = 14;

    in dataloaded
    bopMaster = BOP(BOPMPeriod);

    Click image for larger version

Name:	image.png
Views:	62
Size:	274.5 KB
ID:	1255743

    #2
    Hello, thanks for writing in. Does this code compile in the NinjaScript Editor? Visual Studio does not need to compile this code, the only thing that needs to compile is the NinjaScript editor in order for the scrip to work. When you run the script in the Analyzer, do you get any errors in the Log tab of the Control Center?
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi yes this code compiles and runs and i can even run in it market replay.
      When i hit RUN button in analyzer i get this error
      Strategy 'NameOfTheStrategy': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

      however this strategy is not the same one i am trying to run. Previously I copied pasted boilerplate code from that strategy to this one.. And there is no where "NameOfTheStrategy" in the strategy code i am tryinig to run.

      Comment


        #4
        I am sorry i had State != State.Realtime in my code

        How can i create a logic if bool ShowHistoricalTrades is selected then i can see historical trades, if not then no.

        if(ShowHistoricalTrades)
        {
        State = State.Realtime
        }
        if (State != State.Realtime) //Only trades realtime. Ignores historical trades.
        {
        return;
        }​

        Comment


          #5
          Hi, the State can not be assigned with the = operator. That would be written as

          if(!ShowHistorical && State == State.Historical)
          return;
          else
          {
          //run the strategy code here.
          }
          Chris L.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Taddypole, 04-26-2024, 02:47 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Eduardo  
          Started by futtrader, 04-21-2024, 01:50 AM
          6 responses
          58 views
          0 likes
          Last Post futtrader  
          Started by sgordet, Today, 11:48 AM
          0 responses
          4 views
          0 likes
          Last Post sgordet
          by sgordet
           
          Started by Trader146, Today, 11:41 AM
          0 responses
          5 views
          0 likes
          Last Post Trader146  
          Started by jpapa, 04-23-2024, 07:22 AM
          2 responses
          19 views
          0 likes
          Last Post rene69851  
          Working...
          X