• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate() not called

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

  • koganam
    replied
    Originally posted by rkm2011 View Post
    Hi Joydeep,
    In reply to your suggestion:
    if you increase 53 to 60, do you see "'for indicator 'RKMEvalCTP' on bar 60: Object".... ?
    what about 600?
    The error is still there, it just move to bar 60 and 600 instead of 53.

    Also, in this experiment:
    temp = _UpDown1.IsLongZoneArr[0];
    The error is still there.

    In the process of creating the toy code to send you, I found out about the culprit of the error.
    I appreciate if you could give me the explanation.
    The arrays (dataseries) are created in the Initialize() method as follows. Notice that the
    'IsLongZone' the the 4th calls to new.
    protected override void Initialize()
    {
    Avg = new DataSeries(this);
    Value = new DataSeries(this);
    Diff = new DataSeries(this);
    IsLongZone = new DataSeries(this);
    fastEma = new DataSeries(this);
    slowEma = new DataSeries(this);
    DC_Down = new DataSeries(this);
    DC_Up = new DataSeries(this);
    }

    I have access function
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries IsLongZoneArr
    {
    get { return Values[3]; }
    }

    Notice that the index 3 in Values.

    Now if I moved the new for IsLongZone to be the first one and I change the access function to
    Values[0], THE ERROR WENT AWAY!!!! Everything seems to work now (after moving the
    new of IsLongZone).

    Why is that?

    Thanks,
    Robert.
    Which pretty much completely explains your problem. You created DataSeries, then correctly exposed them. However, you tried to populate the DataSeries from the NT (reserved word) Values collection which are only created if Plots are defined. You need to differentiate between Plots and user-defined DataSeries, and how to populate them.

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello rkm2011,
    Values refer to the Plot values which will be plotted on the charts. In your code you dont have any plot values, only Data Series.

    DataSeries objects held by this collection are added by calling the Add() method.
    http://www.ninjatrader.com/support/h...tml?values.htm

    Object reference not set to an instance of an object.

    The above error indicates that you have not initialized an object.

    Leave a comment:


  • sledge
    replied
    Originally posted by rkm2011 View Post
    Hi Joydeep,
    In reply to your suggestion:
    if you increase 53 to 60, do you see "'for indicator 'RKMEvalCTP' on bar 60: Object".... ?
    what about 600?
    The error is still there, it just move to bar 60 and 600 instead of 53.

    Also, in this experiment:
    temp = _UpDown1.IsLongZoneArr[0];
    The error is still there.

    In the process of creating the toy code to send you, I found out about the culprit of the error.
    I appreciate if you could give me the explanation.
    The arrays (dataseries) are created in the Initialize() method as follows. Notice that the
    'IsLongZone' the the 4th calls to new.
    protected override void Initialize()
    {
    Avg = new DataSeries(this);
    Value = new DataSeries(this);
    Diff = new DataSeries(this);
    IsLongZone = new DataSeries(this);
    fastEma = new DataSeries(this);
    slowEma = new DataSeries(this);
    DC_Down = new DataSeries(this);
    DC_Up = new DataSeries(this);
    }

    I have access function
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries IsLongZoneArr
    {
    get { return Values[3]; }
    }

    Notice that the index 3 in Values.

    Now if I moved the new for IsLongZone to be the first one and I change the access function to
    Values[0], THE ERROR WENT AWAY!!!! Everything seems to work now (after moving the
    new of IsLongZone).

    Why is that?

    Thanks,
    Robert.
    Put in strategy OnBarUpdate first statement

    if ( CurrentBar < 4) { return; }

    or

    if ( CurrentBar < BarsRequired) { return; }

    Leave a comment:


  • rkm2011
    replied
    Hi Joydeep,
    In reply to your suggestion:
    if you increase 53 to 60, do you see "'for indicator 'RKMEvalCTP' on bar 60: Object".... ?
    what about 600?
    The error is still there, it just move to bar 60 and 600 instead of 53.

    Also, in this experiment:
    temp = _UpDown1.IsLongZoneArr[0];
    The error is still there.

    In the process of creating the toy code to send you, I found out about the culprit of the error.
    I appreciate if you could give me the explanation.
    The arrays (dataseries) are created in the Initialize() method as follows. Notice that the
    'IsLongZone' the the 4th calls to new.
    protected override void Initialize()
    {
    Avg = new DataSeries(this);
    Value = new DataSeries(this);
    Diff = new DataSeries(this);
    IsLongZone = new DataSeries(this);
    fastEma = new DataSeries(this);
    slowEma = new DataSeries(this);
    DC_Down = new DataSeries(this);
    DC_Up = new DataSeries(this);
    }

    I have access function
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries IsLongZoneArr
    {
    get { return Values[3]; }
    }

    Notice that the index 3 in Values.

    Now if I moved the new for IsLongZone to be the first one and I change the access function to
    Values[0], THE ERROR WENT AWAY!!!! Everything seems to work now (after moving the
    new of IsLongZone).

    Why is that?

    Thanks,
    Robert.

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello rkm2011,
    To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

    Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

    I look forward to assisting you further.

    *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.

    Leave a comment:


  • koganam
    replied
    Originally posted by rkm2011 View Post
    Hi Koganam,
    Here is the declaration:
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class RKMEvalCTP : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    int pctKSmooth = 3;
    int pctDSmooth = 3;
    int barsUsedInCalc = 5;
    int kWidth = 2;
    Color kColor = Color.Blue;
    int dWidth = 2;
    Color dColor = Color.Transparent;
    double StochThresH = 77.0;
    double StochThresL = 24.0;
    int CCIPeriod = 4;
    double StochOBThres = 78;
    double StochOSThres = 22;
    int MACDFast = 9;
    int MACDSlow = 26;
    int MACDSmooth = 6;
    RKMDCStoch _Stoch1;
    CCI _CCI1;
    RKMDCUpDown2 _UpDown1;
    RKMKRB _KRB1;
    Hm. That looks correctly declared as a class variable.

    Try this for starters, so we can help isolate the issue. Change
    Code:
    temp = _UpDown1.IsLongZoneArr[1];
    to
    Code:
    temp = _UpDown1.IsLongZoneArr[0];
    Does it behave itself now?

    Leave a comment:


  • rkm2011
    replied
    Hi Koganam,
    Here is the declaration:
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class RKMEvalCTP : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    int pctKSmooth = 3;
    int pctDSmooth = 3;
    int barsUsedInCalc = 5;
    int kWidth = 2;
    Color kColor = Color.Blue;
    int dWidth = 2;
    Color dColor = Color.Transparent;
    double StochThresH = 77.0;
    double StochThresL = 24.0;
    int CCIPeriod = 4;
    double StochOBThres = 78;
    double StochOSThres = 22;
    int MACDFast = 9;
    int MACDSlow = 26;
    int MACDSmooth = 6;
    RKMDCStoch _Stoch1;
    CCI _CCI1;
    RKMDCUpDown2 _UpDown1;
    RKMKRB _KRB1;

    Leave a comment:


  • sledge
    replied
    Originally posted by rkm2011 View Post
    Hi,
    I have a custom indicator that instantiate (or embed) a few other custom/system indicators
    as follows:
    protected override void OnStartUp()
    {
    Print("Inside OnStartUp");
    _UpDown1 = RKMDCUpDown2(Color.Blue, Color.Red, MACDFast, MACDSlow, MACDSmooth);
    _Stoch1 = RKMDCStoch(barsUsedInCalc, dColor, dWidth, kColor, kWidth, pctDSmooth, pctKSmooth);
    _CCI1 = CCI(Typical, CCIPeriod);
    _KRB1 = RKMKRB();
    Print("Exiting OnStartUp");
    }

    I put some Print() statements in the OnBarUpdate() of the instantiated indicators and found that it is never called. The OnBarUpdate() is called in the top level indicator (the
    instantiating indicator). Here is the code snippet for the OnBarUpdate() of the top level:
    protected override void OnBarUpdate()
    {
    Print(" RKMEvalCTP OnBarUpdate Time: " + Time[0]);

    if (CurrentBar < 53)
    return;
    EvalCond();
    }

    I see the print statement above is executed for 53 times and then I got the following error when trying to access a DataSeries in the lower level indicator:
    Error on calling 'OnBarUpdate' method for indicator 'RKMEvalCTP' on bar 53: Object reference not set to an instance of an object.
    temp = _UpDown1.IsLongZoneArr[1];

    Thanks.
    if you increase 53 to 60, do you see "'for indicator 'RKMEvalCTP' on bar 60: Object".... ?

    what about 600?
    Last edited by sledge; 11-03-2012, 11:25 PM. Reason: type, 50->60

    Leave a comment:


  • koganam
    replied
    Originally posted by rkm2011 View Post
    Hi,
    I have a custom indicator that instantiate (or embed) a few other custom/system indicators
    as follows:
    protected override void OnStartUp()
    {
    Print("Inside OnStartUp");
    _UpDown1 = RKMDCUpDown2(Color.Blue, Color.Red, MACDFast, MACDSlow, MACDSmooth);
    _Stoch1 = RKMDCStoch(barsUsedInCalc, dColor, dWidth, kColor, kWidth, pctDSmooth, pctKSmooth);
    _CCI1 = CCI(Typical, CCIPeriod);
    _KRB1 = RKMKRB();
    Print("Exiting OnStartUp");
    }

    I put some Print() statements in the OnBarUpdate() of the instantiated indicators and found that it is never called. The OnBarUpdate() is called in the top level indicator (the
    instantiating indicator). Here is the code snippet for the OnBarUpdate() of the top level:
    protected override void OnBarUpdate()
    {
    Print(" RKMEvalCTP OnBarUpdate Time: " + Time[0]);

    if (CurrentBar < 53)
    return;
    EvalCond();
    }

    I see the print statement above is executed for 53 times and then I got the following error when trying to access a DataSeries in the lower level indicator:
    Error on calling 'OnBarUpdate' method for indicator 'RKMEvalCTP' on bar 53: Object reference not set to an instance of an object.
    temp = _UpDown1.IsLongZoneArr[1];

    Thanks.
    Where did you declare _UpDown1?

    Leave a comment:


  • rkm2011
    started a topic OnBarUpdate() not called

    OnBarUpdate() not called

    Hi,
    I have a custom indicator that instantiate (or embed) a few other custom/system indicators
    as follows:
    protected override void OnStartUp()
    {
    Print("Inside OnStartUp");
    _UpDown1 = RKMDCUpDown2(Color.Blue, Color.Red, MACDFast, MACDSlow, MACDSmooth);
    _Stoch1 = RKMDCStoch(barsUsedInCalc, dColor, dWidth, kColor, kWidth, pctDSmooth, pctKSmooth);
    _CCI1 = CCI(Typical, CCIPeriod);
    _KRB1 = RKMKRB();
    Print("Exiting OnStartUp");
    }

    I put some Print() statements in the OnBarUpdate() of the instantiated indicators and found that it is never called. The OnBarUpdate() is called in the top level indicator (the
    instantiating indicator). Here is the code snippet for the OnBarUpdate() of the top level:
    protected override void OnBarUpdate()
    {
    Print(" RKMEvalCTP OnBarUpdate Time: " + Time[0]);

    if (CurrentBar < 53)
    return;
    EvalCond();
    }

    I see the print statement above is executed for 53 times and then I got the following error when trying to access a DataSeries in the lower level indicator:
    Error on calling 'OnBarUpdate' method for indicator 'RKMEvalCTP' on bar 53: Object reference not set to an instance of an object.
    temp = _UpDown1.IsLongZoneArr[1];

    Thanks.

Latest Posts

Collapse

Topics Statistics Last Post
Started by rwilliam, Today, 03:14 PM
0 responses
3 views
0 likes
Last Post rwilliam  
Started by rwilliam, Today, 03:10 PM
1 response
4 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by rontronimous, Today, 03:04 PM
2 responses
5 views
0 likes
Last Post rontronimous  
Started by zacharydw00, Today, 03:14 PM
0 responses
4 views
0 likes
Last Post zacharydw00  
Started by junkone, 09-12-2019, 07:10 PM
11 responses
84 views
0 likes
Last Post cnecorp
by cnecorp
 
Working...
X