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

Indicator trigger event in a Strategy

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

    Indicator trigger event in a Strategy

    Hello,

    Is it possible for an Indicator to trigger an event in a Strategy, and to pass data along with the trigger?

    Any samples?

    It appears the TriggerCustomEvent is used just within the same instance of one object.

    Thank you.

    #2
    Turtle Trader, have you seen the reference sample titled: Exposing indicator values? Normally one would pass data along from an indicator to a strategy, but it would probably work the other way too. That reference sample is for indicator -> strategy, but you'll have to modify it to go from strategy -> indicator.

    I've covered the indicator -> strategy code in another thread that you can look over if you'd like.
    AustinNinjaTrader Customer Service

    Comment


      #3
      polling vs. event driven strategy

      Hi Austin,

      Thanks, I'll look at your suggestions.

      I found the discussion in a couple of other threads



      and there was another I cannot locate again.

      I used to do a little Windows programming and really got to like to object model of creating self defined user objects with exposed events that could be triggered from another object.

      What I have in mind is the Indicator to push the signal into the Strategy via a trigger-event and pass it data, instead of the Strategy constantly polling the Indicator on each OnOrderUpdate.

      My impression is that Ninja doesn't offer this, but that probably it could be done with C# and some knowledge of the Ninja object model.

      Is this correct?

      Thank you.

      Comment


        #4
        Turtle Trader, you can pass data from an indicator to a strategy continuously without an issue. The sample I posted in my first response goes over that.

        As for triggering an event in the strategy from an indicator, you are correct that since NinjaTrader is based on C#, you could whip something together if you have the time and experience.

        What kind of event are you trying to "capture" and send along to a strategy? Would it be possible for you to integrate the indicator into the strategy to completely bypass the need for a trigger/events?
        AustinNinjaTrader Customer Service

        Comment


          #5
          reply

          Hello Austin,

          (I thought I had posted this but then it didn't show up...so here is a summary).

          This is a visual scalping application that looks for patterns in fast moving markets. Because it is looking for visual patterns (not plots) I need drawings on the chart so I can verify what it is doing.

          The drawing and the pattern algorithm were not working as expected in the strategy. When I moved it to an indicator it worked as I planned.

          So, the indicator is producing the trade signal and needs to pass the signal to the strategy. Logically the indicator should be triggering the strategy to place orders, and not the strategy polling the indicator on each tick. The logical "event" is the trade signal and not a tick.

          This strategy is not intended to run unattended. The idea is that the user can observe the the pattern identifications used in the algorithm, as well as the.trade management (both on the chart (chartrader)).

          At this moment, the strategy submits an ATM, later it will have integrated trade management. With Chartrader the execution of the ATM is visible.

          It is better for me as the coder to have the drawing and the trigger code in the indicator and not in the strategy, and surely not to have it in both places.

          Withing the constraints, I should be able to have the strategy poll the indicator on each tick for the presence of the trade signal.

          However, it is possible that the polling may activate the code in the strategy one tick late. Not sure yet, but I believe that is what will happen.

          Thanks.

          Comment


            #6
            Turtle Trader,

            When you poll the indicator from the strategy you are polling the indicator state on the same tick of data you are processing during the strategy's OnBarUpdate(). This means you are not polling it one tick too late or anything like that. You will get the signal right as it comes to you.

            This works just like polling other indicators like SMA. From a strategy, you poll SMA. The SMA processes the same tick the strategy was processing and then you get results as to whether your condition was true or false. Then you can trade based on those results.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              reply

              OK, will get a chance to test it soon. Thank you.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by FrazMann, Today, 11:21 AM
              0 responses
              3 views
              0 likes
              Last Post FrazMann  
              Started by geddyisodin, Yesterday, 05:20 AM
              8 responses
              51 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cmtjoancolmenero, Yesterday, 03:58 PM
              10 responses
              36 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by DayTradingDEMON, Today, 09:28 AM
              4 responses
              24 views
              0 likes
              Last Post DayTradingDEMON  
              Started by George21, Today, 10:07 AM
              1 response
              19 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Working...
              X