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 algospoke, Today, 06:40 PM
        0 responses
        9 views
        0 likes
        Last Post algospoke  
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        7 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        7 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        168 views
        0 likes
        Last Post jeronymite  
        Started by cre8able, Today, 04:22 PM
        0 responses
        9 views
        0 likes
        Last Post cre8able  
        Working...
        X