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

Calling an Indicator that uses OnMarketData from within another indicator

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

    Calling an Indicator that uses OnMarketData from within another indicator

    Hi,
    Background:

    I am aware of how to call an indicator from within another indicator. e.g.

    ---------------------------
    public class Sim22_DeltaV3 : Indicator
    {
    private Sim22.Gapless.Sim22_EmaGaplessV2 emaGapless;
    .
    .
    .

    if (State == State.Configure)
    {
    emaGapless = Sim22_EmaGaplessV2(Values[1], PeriodEma, DeltaGaplessEmaType);
    .
    .
    .
    Values[0][0] = emaGapless[0]; = emaGapless[0];
    ------------------------

    My question is is this not supposed to work when the called indicator uses OnMarketData and would require TickReplay to be enabled , even though TickReplay is enabled on the chart. Another point is that the called indicator used Lists to store OnMarketData values like an OrderBook list.

    I am trying to achieve a divergence indicator with RSI(for example), where the price is compared to the indicator value and noted.

    If calling the indicator is not right way, I am also open to have a public variable(or similar) which stores the called indicator value and can be accessed by calling indicator in realtime.

    I hope I am making sense.

    Thanks,

    SDG


    #2
    Hello SuperDriveGuy,

    From what is provided I really couldn't provide an expectation of what should/should not work as this is a custom script. I can say that calling a secondary indicator in a simple test does invoke the OnMarketData in historical for the hosted script.

    You do need to program the host and hosted scripts for TickReplay, have you followed the steps in the help guide for Calling a Tick Replay indicator from another Indicator or Strategy? There is a sample in the following page which shows the required syntax, you absolutely need to store the indicator as a variable from State.DataLoaded. Beyond that, it would be up to the hosted indicator if it will work in that situation. I can suggest making a more simple test with two dummy indicators and Prints to confirm you are calling it correctly, then retry that with the custom indicator.




    A hosting indicator or strategy must be aware of the requirement to run through another indicator's historical Tick Replay data before it reaches State.Historical. To achieve desired results, you either need to store the reference in State.DataLoaded or (for a strategy) you can call AddChartIndicator().



    I look forward to being of further assistance.


    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse.

      I will try your suggestion and strip down the logic to bare bones and report back.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      27 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 04-23-2024, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      193 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,235 views
      0 likes
      Last Post xiinteractive  
      Working...
      X