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 burtoninlondon, Today, 12:38 AM
          0 responses
          10 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          14 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          14 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,983 views
          3 likes
          Last Post jhudas88  
          Working...
          X