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

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Karado58, 11-26-2012, 02:57 PM
    8 responses
    14,828 views
    0 likes
    Last Post Option Whisperer  
    Started by Option Whisperer, Today, 09:05 AM
    0 responses
    1 view
    0 likes
    Last Post Option Whisperer  
    Started by cre8able, Yesterday, 01:16 PM
    3 responses
    11 views
    0 likes
    Last Post cre8able  
    Started by Harry, 05-02-2018, 01:54 PM
    10 responses
    3,204 views
    0 likes
    Last Post tharton3  
    Started by ChartTourist, Today, 08:22 AM
    0 responses
    6 views
    0 likes
    Last Post ChartTourist  
    Working...
    X