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!
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
NinjaTrader
OnBarUpdate() not called
Collapse
X
-
Originally posted by rkm2011 View Post
-
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.
Object reference not set to an instance of an object.
The above error indicates that you have not initialized an object.
Leave a comment:
-
Originally posted by rkm2011 View PostHi 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.
if ( CurrentBar < 4) { return; }
or
if ( CurrentBar < BarsRequired) { return; }
Leave a comment:
-
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:
-
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:
-
Originally posted by rkm2011 View PostHi 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;
Try this for starters, so we can help isolate the issue. Change
Code:temp = _UpDown1.IsLongZoneArr[1];
Code:temp = _UpDown1.IsLongZoneArr[0];
Leave a comment:
-
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:
-
Originally posted by rkm2011 View PostHi,
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.
what about 600?
Leave a comment:
-
Originally posted by rkm2011 View PostHi,
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.
Leave a comment:
-
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.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by inanazsocial, Today, 01:15 AM
|
0 responses
1 view
0 likes
|
Last Post
by inanazsocial
Today, 01:15 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
22 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
3 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
||
Started by guillembm, Yesterday, 11:25 AM
|
2 responses
9 views
0 likes
|
Last Post
by guillembm
Yesterday, 11:58 PM
|
||
Started by junkone, 04-21-2024, 07:17 AM
|
9 responses
70 views
0 likes
|
Last Post
by jeronymite
Yesterday, 11:51 PM
|
Leave a comment: