Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

using indicator within strategy

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

    using indicator within strategy

    Hi,
    I have an indicator I wrote that works fine. I add it to a strategy (via OnStateChange in the Configure) but when I run a back test in the strategy analyzer it seems like the indicator's OnBarUpdate never gets called. I tried adding the indicator both with and without AddChartIndicator. I know it's not getting called as I added both Print and Log statements to the OnBarUpdate of the indicator and nothing shows up.
    Is there some secret sauce I need to sprinkle on it?

    While I'm at it, I'd like to be able to fire an event from my indicator that can be consumed by my strat. Is this possible?
    Thanks ... Ed

    #2
    Look in the trace file for an error message.

    Comment


      #3
      Hello,

      As Sledge said, the Log as well as Trace are good starting points to finding what is happening or to see if any errors are occurring, you can also check the New -> NinjaScript Output Window for errors.

      Have you also tried using a standard indicator to check the states you are using? I.E. reference the SMA in place of your custom indicator.

      If that works but yours does not, this would help narrow what is happening and would likely be in the indicator its self.

      Alternatively posting a sample that demonstrates the problem would also be helpful.

      Regarding the Event, are you asking about a C# event where you have an event and event handler, or are you just asking how to read signals from an Indicator in a Strategy?

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        I'll check the log and trace files and get back to you. As for the event, I was thinking about raising a c# event. But if there is a better way, I'm all ears.
        Thanks ... Ed

        Comment


          #5
          Hello,

          For events, the general approach is to have an Indicator that Checks for some condition, upon that condition becoming true, plot the results. An example is simply plotting 0 for false and 1 for true.

          In a strategy, you would then utilize the Indicator and read its plot value, if 0 nothing has happened, otherwise if its 1 the signal has occurred so the strategy can do something.

          I have not yet tried using a C# event in NinjaScript, I would assume this may be possible but would be un-necessary based how it would be used in this case, unless of course you have other reasons for needing that specifically.

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Haiasi, 04-25-2024, 06:53 PM
          2 responses
          16 views
          0 likes
          Last Post Massinisa  
          Started by Creamers, Today, 05:32 AM
          0 responses
          1 view
          0 likes
          Last Post Creamers  
          Started by Segwin, 05-07-2018, 02:15 PM
          12 responses
          1,785 views
          0 likes
          Last Post Leafcutter  
          Started by poplagelu, Today, 05:00 AM
          0 responses
          3 views
          0 likes
          Last Post poplagelu  
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,407 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Working...
          X