Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

codes CS0246 line 63, CS0118 lines 64 and 69, CS0234 lines 84, 89, 100, 105?

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

    codes CS0246 line 63, CS0118 lines 64 and 69, CS0234 lines 84, 89, 100, 105?

    Here is the entire code:
    1. using System;
    2. using System.Windows.Media;
    3. using NinjaTrader.NinjaScript;
    4. using NinjaTrader.NinjaScript.Indicators;
    5. using NinjaTrader.NinjaScript.DrawingTools;
    6. namespace NinjaTrader.NinjaScript.AddOns
    7. {
    8. public class RangeComparisonIndicator : Indicator
    9. {
    10. private int period;
    11. private SolidColorBrush highlightColor;
    12. protected override void OnStateChange()
    13. {
    14. if (State == State.SetDefaults)
    15. {
    16. Description = "Highlights bars with range less than the past n bars.";
    17. Name = "Range Comparison Indicator";
    18. Calculate = Calculate.OnBarClose;
    19. IsOverlay = false;
    20. DisplayInDataBox = true;
    21. DrawOnPricePanel = true;
    22. IsSuspendedWhileInactive = true;
    23. period = 5; // Change this to the desired period
    24. highlightColor = Brushes.Red; // Change this to the desired highlight color
    25. }
    26. }
    27. protected override void OnBarUpdate()
    28. {
    29. if (CurrentBar < period)
    30. return;
    31. double currentRange = High[0] - Low[0];
    32. double sumPastRange = 0;
    33. for (int i = 1; i <= period; i++)
    34. {
    35. double pastRange = High[i] - Low[i];
    36. sumPastRange += pastRange;
    37. }
    38. SolidColorBrush barHighlightColor = highlightColor; // Renamed variable
    39. if (currentRange < sumPastRange / period)
    40. BarBrush = barHighlightColor;
    41. else
    42. BarBrush = Brushes.Transparent;
    43. }
    44. }
    45. }
    46. region NinjaScript generated code. Neither change nor remove.
    47. namespace NinjaTrader.NinjaScript.Indicators
    48. {
    49. public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    50. {
    51. private RangeComparisonIndicator[] cacheRangeComparisonIndicator;
    52. public RangeComparisonIndicator RangeComparisonIndicator()
    53. {
    54. return RangeComparisonIndicator(Input);
    55. }
    56. public RangeComparisonIndicator RangeComparisonIndicator(ISeries<double> input)
    57. {
    58. if (cacheRangeComparisonIndicator != null)
    59. for (int idx = 0; idx < cacheRangeComparisonIndicator.Length; idx++)
    60. if (cacheRangeComparisonIndicator[idx] != null && cacheRangeComparisonIndicator[idx].EqualsInput(input))
    61. return cacheRangeComparisonIndicator[idx];
    62. return CacheIndicator<RangeComparisonIndicator>(new RangeComparisonIndicator(), input, ref cacheRangeComparisonIndicator);
    63. }
    64. }
    65. }
    66. namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    67. {
    68. public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    69. {
    70. public Indicators.RangeComparisonIndicator RangeComparisonIndicator()
    71. {
    72. return indicator.RangeComparisonIndicator(Input);
    73. }
    74. public Indicators.RangeComparisonIndicator RangeComparisonIndicator(ISeries<double> input )
    75. {
    76. return indicator.RangeComparisonIndicator(input);
    77. }
    78. }
    79. }
    80. namespace NinjaTrader.NinjaScript.Strategies
    81. {
    82. public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    83. {
    84. public Indicators.RangeComparisonIndicator RangeComparisonIndicator()
    85. {
    86. return indicator.RangeComparisonIndicator(Input);
    87. }
    88. public Indicators.RangeComparisonIndicator RangeComparisonIndicator(ISeries<double> input )
    89. {
    90. return indicator.RangeComparisonIndicator(input);
    91. }
    92. }
    93. }
    94. #endregion


    #2
    Hello james79,

    Thank you for your post.

    Do you have questions about errors you are receiving in the NinjaScript Editor? If so, please provide a screenshot of the error messages you are seeing with the 'Error' column expanded and fully visible.
    • 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.
    ​We look forward to being of further assistance.

    Comment


      #3
      Here is the screen shot of errors.
      Click image for larger version

Name:	image.png
Views:	98
Size:	128.2 KB
ID:	1259891

      Comment


        #4
        Hello james79,

        Thank you for your reply.

        This appears to be an indicator script, though it is included in the AddOns namespace rather than the Indicators namespace. This is shown in lines 6-8 of your script:
        Code:
        namespace NinjaTrader.NinjaScript.AddOns
        {
        public class RangeComparisonIndicator : Indicator
        Since this is an indicator, line 6 will need to be modified so the indicator is part of the Indicators namespace:
        Code:
        namespace NinjaTrader.NinjaScript.Indicators
        {
        public class RangeComparisonIndicator : Indicator
        Please let us know if we may be of further assistance.​

        Comment


          #5
          Getting the following error code:
          Click image for larger version

Name:	image.png
Views:	100
Size:	119.2 KB
ID:	1259913

          Comment


            #6
            Thank you for your help. Much appreciated.

            Comment


              #7
              Hello james79,

              Thank you for your note.

              I have merged your last two posts with this existing thread. I see you have a script called AveRangeComparisonIndicator but the class is called RangeComparisonIndicator, which is an existing script. You will need to rename the class to avoid errors. I have modified your screenshot to point this out:
              World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


              In the future, if you need to create a copy of a script, please open the script in its own tab of the NinjaScript Editor. Next, right-click the background of the script and select Save As. Create a new file name for the script and it should be copied successfully.

              Please feel free to reach out with any additional questions or concerns.

              Comment

              Latest Posts

              Collapse

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