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

Sample Indicator not plotting

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

    Sample Indicator not plotting

    Hi, I'm can't get the sample range indicator to plot. For some reason when I open a chart it does not appear under indicators, instead it is under strategies. Here's the code
    StartHour = 8;
    StartMinute = 30;
    EndHour = 10;
    EndMinute = 30;
    AddPlot(Brushes.Green, "HighestHigh");
    AddPlot(Brushes.Red, "LowestLow");
    }
    }

    private DateTime startDateTime;
    private DateTime endDateTime;
    protected override void OnBarUpdate()
    {
    // Check to make sure the end time is not earlier than the start time
    if (EndHour < StartHour)
    return;


    //Do not calculate the high or low value when the ending time of the desired range is less than the current time of the bar being processed
    if (ToTime(EndHour,EndMinute,0) > ToTime(Time[0]))
    return;



    // If the stored date time date is not the same date as the bar time date, create a new DateTime object
    if (startDateTime.Date != Time[0].Date)
    {
    startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0);
    endDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, EndHour, EndMinute, 0);
    }

    // Calculate the number of bars ago for the start and end bars of the specified time range
    int startBarsAgo = Bars.GetBar(startDateTime);
    int endBarsAgo = Bars.GetBar(endDateTime);

    /* Now that we have the start and end bars ago values for the specified time range we can calculate the highest high for this range

    Note: We add 1 to the period range for MAX and MIN to compensate for the difference between "period" logic and "bars ago" logic.
    "Period" logic means exactly how many bars you want to check including the current bar.
    "Bars ago" logic means how many bars we are going to go backwards. The current bar is not counted because on that bar we aren't going back any bars so it would be "bars ago = 0" */
    double highestHigh = MAX(High, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];

    // Now that we have the start and end bars ago values for the specified time range we can calculate the lowest low for this range
    double lowestLow = MIN(Low, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];

    // Set the plot values
    HighestHigh[0] = highestHigh;
    LowestLow[0] = lowestLow;
    }

    region Properties
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> HighestHigh
    {
    get { return Values[0]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> LowestLow
    {
    get { return Values[1]; }
    }

    #2
    Hello Bmatarese,

    Thanks for your post.

    It seems that you are referring to the reference sample called "SampleGetHighLowByTimeRange" from the Educational Resources section of the help guide linked below. Is that correct?

    SampleGetHighLowByTimeRange: https://ninjatrader.com/support/help...est_high_o.htm

    This reference sample is an indicator reference sample, not a strategy reference sample.

    Did you manually import the reference sample? Or, did you go to Control Center > Tools > Import > NinjaScript AddOn?

    Please remove the reference sample in question using the NinjaScript Editor window.

    If you said you are seeing the script appear in the Strategies window, open a New > NinjaScript Editor window, open the Strategies folder, right-click on the file, and select 'Remove' to remove it from your platform.

    If the file is located in the Indicators window, open a New > NinjaScript Editor window, open the Indicators folder, right-click on the file, and select 'Remove' to remove it.

    After removing the file, re-download the indicator reference sample from the help guide page linked above. Then, import the recently downloaded reference sample by going to Tools > Import > NinjaScript AddOn.

    Once it is successfully imported, the indicator reference sample would appear in the Indicators window under the name 'Sample get high low by time range'.

    Please let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Great, thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Segwin, 05-07-2018, 02:15 PM
      14 responses
      1,788 views
      0 likes
      Last Post aligator  
      Started by Jimmyk, 01-26-2018, 05:19 AM
      6 responses
      837 views
      0 likes
      Last Post emuns
      by emuns
       
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      6 responses
      3,293 views
      1 like
      Last Post jgualdronc  
      Started by Touch-Ups, Today, 10:36 AM
      0 responses
      13 views
      0 likes
      Last Post Touch-Ups  
      Started by geddyisodin, 04-25-2024, 05:20 AM
      11 responses
      63 views
      0 likes
      Last Post halgo_boulder  
      Working...
      X