Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

My Series prints wrong values

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

    My Series prints wrong values

    My Lows are not printing correctly. I am following an example of bool script from ninjatrader to store series of llPriceLevel. Currently it prits but prints wrong values as seen in screenshot. llPriceLevel should print level of LL on screenshot, which is 15222 but it prints 15210....

    private Series<double> llPriceLevel;

    llPriceLevel = new Series<double>(this);

    Condition

    if(fr_dw) {
    if (bLbl) {
    if (Low[Period] <= dDw)
    {
    if(ShowMarketStructure){
    // Values[27][0] = Low[Period];
    // Values[29][0] = CurrentBar-Period;
    llPriceLevel[0] = Low[Period];
    llDrawnBar = CurrentBar-Period;

    Draw.Text(this,"swLL" + CurrentBar, false, "LL", Period, Low[Period] - delta, 5, SellClr, myFont, TextAlignment.Center, null, null, 1);
    }
    }
    else
    if(ShowMarketStructure){
    Draw.Text(this,"swHL" + CurrentBar, false, "HL", Period, Low[Period] - delta, 5, SellClr, myFont, TextAlignment.Center, null, null, 1);
    }
    }
    dDw = Low[Period];

    dtDw = Time[Period];
    bDw = true;
    }​

    public Series<double> LLPriceLevel
    {
    // We need to call the Update() method to ensure our exposed variable is in up-to-date.
    // get { Update(); return llPriceLevel; }
    get { return llPriceLevel; }
    }​

    My prints:
    Print("llPriceLevel[0]:"+llPriceLevel[0] + " " + CurrentBar);
    Print("llPriceLevel[1]:"+llPriceLevel[1] + " " + CurrentBar);​
    Click image for larger version

Name:	image.png
Views:	92
Size:	216.7 KB
ID:	1277751

    #2
    Hello tkaboris,

    A Public Series will automatically update when used in a host script and you don't have to call Update in the getter. Using Update is only for non-series object types, to cause the series to update so that the non-series property has its value updated.
    https://ninjatrader.com/support/help...nt8/update.htm

    The private series is not needed.

    public Series<double> LLPriceLevel
    {​ get; set; }

    That said, the drawing object is being drawn at Low[Period] - delta.

    Use LLPriceLevel[0] instead of you want the drawing object at that price.

    Draw.Text(this,"swLL" + CurrentBar, false, "LL", Period, LLPriceLevel[0], 5, SellClr, myFont, TextAlignment.Center, null, null, 1);

    Or set LLPriceLevel[0] to Low[Period] - delta if you want the series to have that price.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea,

      the indicator plots correctly so i dont need to modify draw object. Its the prints that are not printing right values what is being dispalyed .
      I dont understand what lines should i remove from my script to follow private series not needed. If i remove any of the lines there are compilation errors.

      Comment


        #4
        Hello tkaboris,

        If you want the series to have the same price as the price at which the text is drawn then use the same value.

        Attached is the code added to a test script to show what I mean.
        tkaborisTest_NT8.zip

        And a video showing the values are the same.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you it worked. But i wanted to use series in order to get access to curren and previous LLPriceLevels, thats why i thought to keep private series. Currently it only prints first value and second stays 0 even after second LL is drawn on the chart....

          Print(string.Format("{0} | Period: {1}, LLPriceLevel[0]: {2}", Time[0], Period, LLPriceLevel[0]));
          Print(string.Format("{0} | Period: {1}, LLPriceLevel[1]: {2}", Time[0], Period, LLPriceLevel[1]));​

          Comment


            #6
            Hello tkaboris,

            You don't need both a private and public series for the same series. If you don't want to share the series with a host, then use private. If you want to share the series with a host use public.

            If you want the value from 1 bar ago on the series, then there needs to be 1 more bar before the print is evaluated.

            Attached is the same example modified to check that CurrentBar is greater than Period + 1, and then prints the value from LLPriceLevel[1].
            tkaborisTest_NT8.zip
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            52 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            130 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            70 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            44 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            48 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X