Announcement

Collapse
No announcement yet.

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:	97
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?

    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.
          }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          47 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          23 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          33 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          51 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          42 views
          0 likes
          Last Post CarlTrading  
          Working...
          X