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

Indicator Plotting Problem

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

    Indicator Plotting Problem

    Let me try this again. I didn't explain my problem clearly in an earlier post.

    I created an indicator and there is a signal, an upper line at .85 - Red; a zero line at 0 - White; and a Lower line at -.85 - Lime. Here is a code snippet:
    Code:
                   
                    AddLine(Brushes.Red, .85, "Upper");                
                    AddLine(Brushes.White, 0, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZeroLine);
                    AddLine(Brushes.Lime, -.85, "Lower");    
    
                    AddPlot(Brushes.Cyan, "EBSW");

    When the indicator actually plots, instead of the Red line being drawn at .85, it is drawn at the zeroline "0" place. The white zeroline is drawn at ".85". This is shown in the attached picture. Why are the Red and White lines reversed from what the code is intending? Thanks
    Attached Files
    Last edited by dmking; 02-04-2019, 09:33 AM.

    #2
    Code:
                    AddLine(Brushes.Red, .85, "Upper");                
                    AddLine(Brushes.White, 0, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZeroLine);
                    AddLine(Brushes.Lime, -.85, "Lower");    
    
                    AddPlot(Brushes.Cyan, "EBSW");

    Comment


      #3
      Hello dmking,

      Thanks for your post.

      I would expect the lines to be at the levels/colors specified in the code. However, since this code is typically set in State.SetDefaults, changes to these lines will not take place with a reload of NinjaScripts I.E. pressing F5 on the chart. The indicator will have to be removed and added again to see changes to this code.

      Could you confirm that after removing the indicator from the chart and then re-adding it, you are not seeing the lines drawn at the specified levels/colors that you have in the code?

      I look forward to being of further assistance.
      JimNinjaTrader Customer Service

      Comment


        #4
        Thanks for the response Jim. Indeed, when I remove the indicator and add it back in, it is still drawn with the Red and White lines reversed as shown in the picture. Maybe I'm doing something wrong here's the surrounding code:

        [/CODE]
        protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        {
        Description = @"This is a indicator ";
        Name = "Test Indicator";
        Calculate = Calculate.OnBarClose;
        IsOverlay = false;
        DisplayInDataBox = true;
        DrawOnPricePanel = true;
        DrawHorizontalGridLines = true;
        DrawVerticalGridLines = true;
        PaintPriceMarkers = true;
        ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;

        AddLine(Brushes.Red, .85, "Upper");
        AddLine(Brushes.White, 0, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZe roLine);
        AddLine(Brushes.Lime, -.85, "Lower");

        AddPlot(Brushes.Cyan, "EBSW");

        }
        else if (State == State.Configure)
        {
        [CODE]

        Comment


          #5
          Hello dmking,

          When I test the code, the levels are where I expect them to be. The issue may be that the assembly is not fully compiled when the Indicators window is open, so older instances of the code would be used.

          Demo - https://drive.google.com/file/d/16-_...w?usp=drivesdk

          I have included an export so you can import and test on your end. Please let me know if you see any issues with the provided export and please be sure to let us know which version of the platform you are using if you are seeing issues with this script. The current version is Release 17 and can be downloaded below.

          Download - https://ninjatrader.com/PlatformDirect

          I look forward to being of further assistance.
          Attached Files
          JimNinjaTrader Customer Service

          Comment


            #6
            Hey Jim,

            I imported your test case and it worked fine.

            I uninstalled the indicator and reinstalled it still has the lines reversed.

            I'm running version 16 and will update after market aclose.

            This is weird!

            PS, OK so I created another "fresh" version of the indicator with a different name and cut and pasted the code in. It works the way I intended, so I'm not sure what the problem was with the original version.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            148 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Started by mattbsea, Today, 05:44 PM
            0 responses
            5 views
            0 likes
            Last Post mattbsea  
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            33 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            5 views
            0 likes
            Last Post tkaboris  
            Started by GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,282 views
            0 likes
            Last Post Leafcutter  
            Working...
            X