Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error CS0103 and CS1061

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

    Error CS0103 and CS1061

    Good morning, I'm learning to create indicators and I'm working on one that came to my mind, but I can't get it to work, I've looked for examples on other sites and I haven't found the reason for my error. I would appreciate very much your help in instructing me about what could be the error.
    This is the code:

    region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class TPOC : Indicator
    {
    private double tpoc;
    private int tpocVolume;
    private int tickSize;
    private List<double> tpocValues;
    private Plot MyPlot;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Time Point Of Value";
    Name = "TPOC";
    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)
    {
    tpocValues = new List<double>();
    MyPlot = CreatePlot(Brushes.Blue, "TPoC");
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar == 0)
    return;

    tpoc = 0;
    tpocVolume = 0;
    Dictionary<double, int> priceCount = new Dictionary<double, int>();

    for (int i = CurrentBar == 1 ? BarsRequiredToPlot : CurrentBar; i >= 0; i--)
    {
    double price = Close[i];

    if (priceCount.ContainsKey(price))
    priceCount[price]++;
    else
    priceCount[price] = 1;
    }

    int maxCount = 0;
    double maxPrice = 0;

    foreach (KeyValuePair<double, int> kvp in priceCount)
    {
    if (kvp.Value > maxCount)
    {
    maxCount = kvp.Value;
    maxPrice = kvp.Key;
    }
    }

    tpoc = maxPrice;
    tpocValues.Add(tpoc);
    Values[0][0] = tpocValues.Last();

    MyPlot.Set(Values[0][0]);
    }
    }
    }
    Last edited by rafafernandez797; 08-21-2023, 06:08 AM.

    #2
    Hello rafafernandez797,

    Thank you for your post.

    While we do not provide hands-on debugging assistance, I would be glad to review the error messages and offer a suggestion as to how you can identify and resolve the cause. Please provide a screenshot that shows the full error messages in the "Error" column of the NinjaScript Editor.
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
    ​I look forward to your reply.

    Comment


      #3
      hello , it asks me for a url to send the image , but I will provide what the error says :
      In this line of code:
      MyPlot = CreatePlot(Brushes.Blue, "TPoC");
      I get the following error: The name 'CreatePlot' does not exist in the current context

      and the second error is the following :
      in this line of code:
      MyPlot.Set(Values[0][0]);
      the following error appears: NinjaTrader.Gui.Plot does not contain a definition of 'Set' and no extension method was found.

      thank you very much I look forward to your reply​

      Comment


        #4
        Hello rafafernandez797,

        Thank you for your reply.

        The proper method to create a plot is AddPlot(). CreatePlot() is not a valid method for NinjaTrader 8 or NinjaTrader 7. Where did you get the information to use CreatePlot()? It sounds like it may have been a suggestion from an AI tool.

        Please see the following page for more information regarding AddPlot() as well as the tips that are listed on that page:
        • https://ninjatrader.com/support/help...t8/addplot.htm
          • Tips:
            1.We suggest using the NinjaScript wizard to generate your plots.
            2.Plot objects DO NOT hold the actual script values. They simply define how the script's values are plotted on a chart.
            3.A script may calculate multiple values and therefore hold multiple plots to determine the display of each calculated value. Script values are held in the script's Values collection.
            4.If you script calls AddPlot() multiple times, then multiple Values series are added per the "three value series" example below
            5.For MultiSeries scripts, plots are synched to the primary series of the NinjaScript object.
            6.Plots will become visible once the script’s BarsRequiredToPlot value has been satisfied. By default, the value is 20.
        Please let me know if I may be of further assistance.​

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X