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 vs Strategy

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

    Indicator vs Strategy

    Hello,

    I'm trying to get familliar with the NinjaTrader platform and its indicators and strategys. I have written a stimple indicator that repaints a bar if it meets condidtions (meant to indicate a reversal).

    The problem is, the bar painting works as a strategy but not as an indicator. The problem with this is that I have to be connected to a data feed in order for the bars to be repainted. So checking past charts offline doesn't work.

    It's not the end of the world, but I'm curious why the strategy works and the indicator doesn't. Can I not repaint bars as an indicator? The only difference in the code (as far as my action goes) is in the initialize where I have overlay set to true in the indicator and that isn't in the strategy code. I tried the drawdot and plotcolors and neither of those work in the indicator as well. Thanks.

    protectedoverridevoid Initialize()
    {
    Overlay = true;
    CalculateOnBarClose =
    false;
    }

    protectedoverridevoid OnBarUpdate()
    {
    //bar down
    if( High[0] > MAX(High, DPeriod)[1] && Close[0] < Close[1] && Open[1] < Close[1])
    {
    this.BarColor = Color.Magenta;

    //DrawDot("tag1", true, 0, Low[0] - 1, Color.Red);
    }

    //bar up
    if( Low[0] < MIN(Low, UpPeriod)[1] && Close[0] > Close[1] && Open[1] > Close[1])
    {
    this.BarColor = Color.Aqua;
    //PlotColors[0][0] = Color.Aqua;
    }
    }

    #2
    Ok I got it. Sorry.

    Comment


      #3
      Hello,

      Thank you for letting us know this was resolved.

      If you would like to provide the conclusion you came to it may be helpful for others if they come across this post.

      Please let me know if I may be of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Sure. Put this as the first code in OnBarUpdate

        if (CurrentBar < DPeriod + 1 || CurrentBar < UpPeriod + 1)
        return;

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, Today, 06:53 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottWalsh, Today, 06:52 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottW, Today, 06:09 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ftsc2022, 10-25-2022, 12:03 PM
        5 responses
        256 views
        0 likes
        Last Post KeyonMatthews  
        Started by Board game geek, 10-29-2023, 12:00 PM
        14 responses
        244 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Working...
        X