Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DashStyleHelper and Stroke Compilation Errors in NinjaScript

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

    DashStyleHelper and Stroke Compilation Errors in NinjaScript

    I am experiencing compilation errors when trying to use DashStyleHelper and Stroke from NinjaTrader.NinjaScript.DrawingTools in my custom NinjaScript strategy.​

    Error Messages:
    1. The name 'DashStyleHelper' does not exist in the current context.
    2. The type or namespace name 'Stroke' does not exist in the namespace 'NinjaTrader.NinjaScript.DrawingTools'.

    Ninjascript code:
    "
    private void DrawTrendlineIfPossible(List<double> trendPoints, string tagPrefix, System.Windows.Media.Brush brush)
    {
    if (trendPoints.Count >= 2)
    {
    NinjaTrader.NinjaScript.DrawingTools.Stroke lineStroke = new NinjaTrader.NinjaScript.DrawingTools.Stroke(brush, DashStyles.Solid, 2);
    Draw.Line(this, tagPrefix + CurrentBar, false, CurrentBar - trendPoints.Count + 2, trendPoints[trendPoints.Count - 2], CurrentBar, trendPoints[trendPoints.Count - 1], lineStroke);
    }
    }
    "

    Previous Attempts to Resolve:
    • Tried using SharpDX for rendering, using DashStyles.Solid, and adjusting namespaces.
    • Checked NinjaTrader documentation, including Draw.RegressionChannel() and the Stroke class, which still mention DashStyleHelper, but the current version of NinjaTrader does not recognize it.
    Questions:
    1. Has DashStyleHelper been deprecated or replaced in NinjaTrader version 8.1.3.1?
    2. Are there any additional namespaces or assembly references required to use Stroke from DrawingTools?
    3. Could you provide an example of how to properly draw a trendline using a stroke with a solid style in the latest NinjaTrader version?

    Goal of the Code: The goal is to draw dynamic trendlines on charts and create alerts when price touches the trendlines. This feature is essential for my strategy, and I need compatibility with current NinjaTrader classes and methods.

    #2
    Hello Arameki,

    Welcome to the NinjaTrader forums!

    I would suspect you have deleted the default using statements at the top of the script or you have not created the script using the NinjaScript Editor which populates the necessary default using statements.

    I recommend you create a new script using the NinjaScript Editor, then copy and paste the default using statements at the top of the script to the top of your custom script.

    Moving forward, create the script using the NinjaScript Editor and do not remove the default using statements.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the advice regarding using the default "using" statements. I followed your suggestion and recreated the script using the NinjaScript Editor to ensure the proper namespaces were included. I can confirm that after adding the default "using" directives, the compilation errors for missing namespaces were resolved successfully.

      However, I am still facing challenges when trying to create trendlines with alerts. Specifically, I am trying to draw dynamic trendlines that can be alerted upon touches or breaks as part of a trading strategy. The strategy compiles and runs on the chart, but the trendlines are simply not appearing on the chart.

      Here is what I have done so far:
      1. I've used DashStyleHelper and the Stroke class for rendering the trendlines.
      2. I utilized the Draw.Line method with arguments such as Time, price points, and styling elements.
      3. Additionally, I have tried to simplify the implementation by creating trendlines that respond to significant touches or points on the chart.

      Despite the steps above, I'm not seeing the trendlines appear as expected, nor are the alerts triggering on trendline touches.

      I would greatly appreciate if you could provide any insight on the following:
      1. Verification of Trendline Drawing Logic: Could you help confirm if the Draw.Line logic is correct for dynamically generating and rendering trendlines based on bar data?
      2. DashStyleHelper Usage: Am I using the correct approach to assign styles to the trendlines (e.g., DashStyleHelper.Solid)?
      3. Visibility or Configuration Settings: Could there be a configuration or parameter I am missing that might be preventing the trendlines from displaying on the chart?

      The goal is to create dynamic trendlines that are both visible on the chart and trigger appropriate alerts when touched. Any advice or sample code that demonstrates a working example of dynamic trendline creation in the latest version of NinjaTrader would be highly valuable.

      Thank you for your assistance!

      Comment


        #4
        Hello Arameki,

        To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that triggers the action.
        The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.
        The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

        Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

        I am happy to assist you with analyzing the output from the output window.

        Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

        Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


        Let me know the date and time the behavior occurred or when you are expecting the behavior to occur.

        Please let me know if I may further assist with analyzing the output or if you need any assistance creating a print.


        "Verification of Trendline Drawing Logic: Could you help confirm if the Draw.Line logic is correct for dynamically generating and rendering trendlines based on bar data?"

        The code that sets the variables used for the Draw.Line() call were not provided. I wouldn't be able to verify what values are being used.
        Also, it's a custom method, and the code that calls the method was not provided. I wouldn't be able to verify what method this is being called from.
        I can say ​Draw.Line() is used to draw a line.

        "DashStyleHelper Usage: Am I using the correct approach to assign styles to the trendlines (e.g., DashStyleHelper.Solid)?"

        I'm not seeing you are using DashStyleHelper in the code. I only see a stroke object using DashStyles.

        Draw.Line() does not have an overload that accepts a stroke.


        "Visibility or Configuration Settings: Could there be a configuration or parameter I am missing that might be preventing the trendlines from displaying on the chart?"

        There is an IsVisible setting that can be enabled disabled in the Indicators window.


        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        50 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X