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

cannot apply indexing using method groups

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

  • NinjaTrader_Kate
    replied
    Hello gravdigaz6,

    Thank you for your reply.

    I would recommend first checking whether you see any errors regarding the indicator on the Log tab of the Control Center. If there are, what is the full text of the error?

    If there are no obvious errors, the next thing I would suggest adding prints to see what the values returned are from the DeltaCandles indicator. Adding prints to your script that will show in the NinjaScript Output window, with information on what the variables you're using for your conditions are on a particular bar, can be helpful.

    This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.

    https://ninjatrader.com/support/foru...ns-not-working

    If you run into issues like you're seeing here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess what is different between the two.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • gravdigaz6
    replied
    Originally posted by NinjaTrader_Kate View Post
    Hello gravdigaz6,

    Thank you for your reply.

    The 2 @@ signs before the file name mean that you have excluded the file from compilation rather than fix the compilation errors as instructed. You will need to include the file in compilation by right clicking on the name in the NinjaScript Editor's right hand pane and unchecking "Exclude from Compilation". You will then need to address any compilation errors by fixing the issue in the code.

    Thanks in advance; I look forward to assisting you further.


    THANK YOU! I managed to compile the indicator and there are no errors either in the log or in ninjacript editor.

    however when there is a divergence between the delta and the candle the background does not change color.

    Do you see what is wrong in my code? that will explain this.

    attached the screenshot




    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class DeltaDiv : Indicator
    {
    protected override void OnStateChange()
    {

    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "DeltaDiv";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    if (Close[0] > Open[0])
    {
    if(DeltaCandles()[0] >0)
    BackBrush = Brushes.Green;
    }
    else if(Close[0]< Open[0])
    {
    if(DeltaCandles()[0] <0)

    BackBrush = Brushes.Green;
    }
    }
    }
    }

    #region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private DeltaDiv[] cacheDeltaDiv;
    public DeltaDiv DeltaDiv()
    {
    return DeltaDiv(Input);
    }

    public DeltaDiv DeltaDiv(ISeries<double> input)
    {
    if (cacheDeltaDiv != null)
    for (int idx = 0; idx < cacheDeltaDiv.Length; idx++)
    if (cacheDeltaDiv[idx] != null && cacheDeltaDiv[idx].EqualsInput(input))
    return cacheDeltaDiv[idx];
    return CacheIndicator<DeltaDiv>(new DeltaDiv(), input, ref cacheDeltaDiv);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.DeltaDiv DeltaDiv()
    {
    return indicator.DeltaDiv(Input);
    }

    public Indicators.DeltaDiv DeltaDiv(ISeries<double> input )
    {
    return indicator.DeltaDiv(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.DeltaDiv DeltaDiv()
    {
    return indicator.DeltaDiv(Input);
    }

    public Indicators.DeltaDiv DeltaDiv(ISeries<double> input )
    {
    return indicator.DeltaDiv(input);
    }
    }
    }

    #endregion

    Attached Files

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello gravdigaz6,

    Thank you for your reply.

    The 2 @@ signs before the file name mean that you have excluded the file from compilation rather than fix the compilation errors as instructed. You will need to include the file in compilation by right clicking on the name in the NinjaScript Editor's right hand pane and unchecking "Exclude from Compilation". You will then need to address any compilation errors by fixing the issue in the code.

    Thanks in advance; I look forward to assisting you further.

    Leave a comment:


  • gravdigaz6
    replied

    Leave a comment:


  • gravdigaz6
    replied
    Originally posted by NinjaTrader_Kate View Post
    Hello gravdigaz6,

    Thank you for your reply.

    That's the NinjaScript Editor window in your screenshot - that will show you compile errors, but not errors when it tries to run the indicator. Runtime errors will appear in the Log tab of the Control Center - the main NinjaTrader window. Do you see an error regarding the indicator in your log tab in this window? If so, what is the full text of the error?

    Thanks in advance; I look forward to assisting you further.


    I also looked at the log tab of the control center and there is no error concerning the indicator
    Attached Files

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello gravdigaz6,

    Thank you for your reply.

    That's the NinjaScript Editor window in your screenshot - that will show you compile errors, but not errors when it tries to run the indicator. Runtime errors will appear in the Log tab of the Control Center - the main NinjaTrader window. Do you see an error regarding the indicator in your log tab in this window? If so, what is the full text of the error?

    Thanks in advance; I look forward to assisting you further.

    Leave a comment:


  • gravdigaz6
    replied
    Originally posted by NinjaTrader_Kate View Post
    Hello gravdigaz6,

    Thank you for your reply.

    Generally if it compiles but doesn't show up, there will be an error regarding the indicator in the Log tab of the Control Center. Do you see an error regarding the indicator in your log? If so, what is the full text of the error?

    Thanks in advance; I look forward to assisting you further.

    after compiling there are no error messages
    Attached Files

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello gravdigaz6,

    Thank you for your reply.

    Generally if it compiles but doesn't show up, there will be an error regarding the indicator in the Log tab of the Control Center. Do you see an error regarding the indicator in your log? If so, what is the full text of the error?

    Thanks in advance; I look forward to assisting you further.

    Leave a comment:


  • gravdigaz6
    replied
    Originally posted by NinjaTrader_Kate View Post
    Hello gravdigaz6,

    Thank you for your reply.

    You simply need to replace all references to DeltaCandles[0] with DeltaCandles()[0].

    Please let us know if we may be of further assistance to you.


    I have no more errors but when I restart nt8 I can't find it in the indicators when I want to add it to a chart.
    however I see it in the indicators folder of nt8.
    Below the capture.
    Attached Files

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello gravdigaz6,

    Thank you for your reply.

    You simply need to replace all references to DeltaCandles[0] with DeltaCandles()[0].

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • gravdigaz6
    replied
    Originally posted by NinjaTrader_Kate View Post
    Hello gravdigaz6,

    Thank you for your reply.

    That indicator only needs an input series, which, if not specified, will default to the primary data series for the chart. So it would be:

    DeltaCandles()[0] //the empty parenthesis tell the system to use the indicator method, the [0] specifies the indicator value for the most recent bar

    Please let us know if we may be of further assistance to you.

    ok but what should I insert in the code below and where to insert it?
    can you show me exactly where to insert it?



    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class DeltaDiv : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "DeltaDiv";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    if (Close[0] > Open[0])
    {
    if(DeltaCandles[0] >0) the error is on this line with DeltaCandles which is an indicator I also use when I create sound alerts
    BackBrush = Brushes.Green;
    }
    else if(Close[0]< Open[0])
    {
    if(DeltaCandles[0] <0) the error is on this line with DeltaCandles which is an indicator I also use when I create sound alerts

    BackBrush = Brushes.Green;
    }
    }
    }
    }

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello gravdigaz6,

    Thank you for your reply.

    That indicator only needs an input series, which, if not specified, will default to the primary data series for the chart. So it would be:

    DeltaCandles()[0] //the empty parenthesis tell the system to use the indicator method, the [0] specifies the indicator value for the most recent bar

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • gravdigaz6
    replied
    Originally posted by NinjaTrader_Kate View Post
    Hello gravdigaz6,

    Thank you for your note.

    Indicators would need to be called like a method with parenthesis after the indicator name. Some indicators will require parameters inside the parenthesis - you should see intellisense popups telling you what if anything it's expecting to get as parameters when it's called.

    So, should be something like:

    DeltaCandles(any parameters necessary go here, separated by commas)[0] //would get the most recent bar's value of that indicator.

    Please let us know if we may be of further assistance to you.


    I am a real beginner and when I try to compile this code I get this message in orange on the 2 lines concerned: cannot apply indexing using method groups and that's it.
    what should I add to this code?

    here is the screenshot
    Attached Files

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello gravdigaz6,

    Thank you for your note.

    Indicators would need to be called like a method with parenthesis after the indicator name. Some indicators will require parameters inside the parenthesis - you should see intellisense popups telling you what if anything it's expecting to get as parameters when it's called.

    So, should be something like:

    DeltaCandles(any parameters necessary go here, separated by commas)[0] //would get the most recent bar's value of that indicator.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • gravdigaz6
    started a topic cannot apply indexing using method groups

    cannot apply indexing using method groups

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class DeltaDiv : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "DeltaDiv";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    if (Close[0] > Open[0])
    {
    if(DeltaCandles[0] >0) the error is on this line with DeltaCandles which is an indicator I also use when I create sound alerts
    BackBrush = Brushes.Green;
    }
    else if(Close[0]< Open[0])
    {
    if(DeltaCandles[0] <0) the error is on this line with DeltaCandles which is an indicator I also use when I create sound alerts

    BackBrush = Brushes.Green;
    }
    }
    }
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by Rapine Heihei, Today, 08:19 PM
1 response
6 views
0 likes
Last Post NinjaTrader_Manfred  
Started by Rapine Heihei, Today, 08:25 PM
0 responses
5 views
0 likes
Last Post Rapine Heihei  
Started by f.saeidi, Today, 08:01 PM
1 response
4 views
0 likes
Last Post NinjaTrader_Manfred  
Started by Rapine Heihei, Today, 07:51 PM
0 responses
6 views
0 likes
Last Post Rapine Heihei  
Started by frslvr, 04-11-2024, 07:26 AM
5 responses
98 views
1 like
Last Post caryc123  
Working...
X