Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Level II indicator help

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

    Level II indicator help

    I do not code, I collaborated with ChatGPT to write the below, we're getting one last error it seems unless someone spots another issue
    MarketDepthPrinter1.cs The type or namespace name 'MarketDepthEventArgs' could not be found (are you missing a using directive or an assembly reference?) CS0246 28 47

    Can anyone help me fix this? I have gpt+ which can browse the internet actively and we couldn't find the solution to this

    using System;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.NinjaScript.Strategies;

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class LimitOrderLine : Strategy
    {
    private double threshold;
    private int lineThickness;

    [NinjaScriptProperty]
    public double Threshold
    {
    get { return threshold; }
    set { threshold = value; }
    }

    [NinjaScriptProperty]
    public int LineThickness
    {
    get { return lineThickness; }
    set { lineThickness = value; }
    }

    protected override void OnMarketDepth(MarketDepthEventArgs marketDepthUpdate)
    {
    if (marketDepthUpdate.MarketDataType == MarketDataType.Last)
    return;

    double bidSize = marketDepthUpdate.MarketDepth.Bid[0].Size;
    double askSize = marketDepthUpdate.MarketDepth.Ask[0].Size;

    if (bidSize >= threshold || askSize >= threshold)
    {
    double priceLevel = (bidSize >= threshold) ? marketDepthUpdate.MarketDepth.Bid[0].Price : marketDepthUpdate.MarketDepth.Ask[0].Price;
    Draw.Line(this, "ThresholdLine" + CurrentBar, false, 0, priceLevel, -1, priceLevel, Brushes.Blue, lineThickness);
    }
    }
    }
    }

    #2
    Hello imjustkaze,

    While we cannot assist with AI generated code I can suggest using the help guide for learning about NinjaScript resources. After creating a new indicator you can implement OnMarketData by using the syntax shown in the help guide. I have included our current disclaimer about chatgpt below.




    From our experience at this time, ChatGpt is not adequate to generate valid compilable NinjaScripts that function as the user has intentioned. We often find that the generated code will call non-existent properties and methods, use improper classes or inheritance, and may have incorrect logic. We highly encourage that you create a new NinjaScript yourself using the NinjaScript Editor.

    While It would not be within our support model to correct these scripts at user request, we would be happy to provide insight for any direct specific inquiries you may have if you would like to create this script yourself. Our support is able to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    553 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    100 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    543 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    546 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X