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

Plotting Draw.ArrowUp() w/ Historical Data

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

    Plotting Draw.ArrowUp() w/ Historical Data

    I am trying to create an indicator that plots an up arrow below the bar if Low[0] < Low[1] && Close[0] > Low[1]. I have the indicator working, however it is only plotting the last instance where the above conditions are met. I would like it to plot all instances in the past where such conditions are met. Appreciate any help from those who know what I need to do to accomplish my goal. Thanks!!

    Below is what I have so far
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "MyCustomIndicator1";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    if (CurrentBar > 0)
    {
    if (Low[0] < Low[1] && Close[0] > Low[1])
    {
    Draw.ArrowUp(this,"", true, 0, Low[0] - TickSize,Brushes.Green);
    }
    }
    }

    #2
    I found the answer searching through other posts about plotting indicators. For those who find similar problems with custom script only plotting latest occurrence, you must add "+ CurrentBar" to the string tag argument.

    example : Draw.Dot(this, "dotTag" + CurrentBar, true, ...)

    hope somebody finds this helpful!

    Comment


      #3
      Thank you for the update, robertmaierle!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      53 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      32 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      5 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      19 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      6 views
      0 likes
      Last Post cre8able  
      Working...
      X