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
Indicator Plot
Collapse
X
-
Hello s.kinra,
Calling AddPlot() does not call the Order Flow. Instead this adds a plot to the indicator.
State.SetDefaults is fine. (State.Configure is also fine)
- Likes 1
Leave a comment:
-
Hello Chelsea,
Normally AddPlot(...) is called in State.SetDefaults, is there a specific exception for Order Flow ?
Leave a comment:
-
Hello sdauteuil,
To define a public series:
In State.SetDefaults:
AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Bar, "CumulativeDeltaPlot");
In #region Properties:
[Browsable(false)]
[XmlIgnore]
public Series<double> CumulativeDeltaPlot
{
get { return Values[0]; }
}
In OnBarUpdate():
CumulativeDeltaPlot = SUM(cumulativeDelta.DeltaClose, 3)[0];Last edited by NinjaTrader_ChelseaB; 11-22-2020, 11:06 PM.
Leave a comment:
-
Thank you that worked
In the first one the indicator wizard didn't add the State == State.DataLoaded
apparently I added that incorrectly.
In the second one the print function was working but no property area was create to define the series/variable
I wasn't sure how to create the series for the plot.
Leave a comment:
-
Hello sdauteuil,
In the file you posted in Post #1 I am able to import this, and there is no compile error.
However, there is logic run-time error.
You have 'if (State == State.DataLoaded)' nested within the action block for 'else if (State == State.Configure).
If the State is State.Configure then it cannot also be State.DataLoaded at the same time.
The condition on line 58 will never be true, and the cumulativeDelta will never have an indicator instance assigned.
Change this to 'else if (State == State.DataLoaded)' and move this below the action block for State.Configure, currently on line 65.
In the file you have posted in Post #11, I am not seeing any issue. This runs and I am seeing prints appearing in the output window. Let me know if you need a video of the script being tested and showing prints in the output window.
- Likes 1
Leave a comment:
-
Originally posted by sdauteuil View PostI am trying to create a simple indicator that sums 3 periods of the cumulative delta.
I cannot figure out how to get the addplot() to work.
I have created several indicators based on CD and found a good example by NinjaTrader_PaulH located here:
OFCDKeltner uses the Order Flow Cumulative Delta indicator as the input to draw the standard Keltner Channel. To use, please follow this process: 1) Add Order Flow Cumulative Delta to your chart. 2) Add the indicator OFCDKeltner and ensure before applying that you have selected the same parameters that the Order Flow Cumulative Delta indicator […]
It is a good reference for a starting point.
Robotman
OFCDKeltner uses the Order Flow Cumulative Delta indicator as the input to draw the standard Keltner Channel. To use, please follow this process: 1) Add Order Flow Cumulative Delta to your chart. 2) Add the indicator OFCDKeltner and ensure before applying that you have selected the same parameters that the Order Flow Cumulative Delta indicator […]
Leave a comment:
-
I found this in a previous post... not sure if this has anything to do with it
The secondary series is synced with the primary series
However there is no property region to define variables
protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
// Print the close of the cumulative delta bar with a delta type of Bid Ask and with a Session period
Print("Delta Close: " + cumulativeDelta.DeltaClose[0]);
}
else if (BarsInProgress == 1)
{
// We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
}Attached Files
Leave a comment:
-
I also tried adding
if ((CurrentBars[0] < 20)
|| (CurrentBars[1] < 20))
return;
In case the secondary series was the problem
Leave a comment:
-
I had tried adding that
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 20)
return;
whatever number I put in the CurrentBars statement comes up in the error log.I have tried adding Print() statements to debug it, none of the statements print in the output window only the error.11/22/2020 9:15:56 AM Default Indicator 'TestCumulativeDeltaSum': Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object.
I thought maybe there was a spelling or upper / lower case error but haven't found any.
The latest version is attachedAttached Files
Leave a comment:
-
OK great, it means no issues with plot. Order Flow might be unable to process on first bar, so you can exclude it.
You need to add this :-
Code:protected override void OnBarUpdate() {[INDENT]if(CurrentBar < 3)[/INDENT][INDENT=2]return;[/INDENT] ... // rest of code }
Leave a comment:
-
Log error
11/22/2020 12:28:19 AM Default Indicator 'TestCumulativeDeltaSum': Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object.
Leave a comment:
-
That was able to compile
I changed PlotStyle to Line and added IsAutoScale = true;
However the indicator panel is still empty
Leave a comment:
-
Let me also ask if you're getting any errors in Control Center Log tab ?
Leave a comment:
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by andrewtrades, Today, 04:57 PM
|
1 response
5 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
3 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
436 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
7 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
5 responses
19 views
0 likes
|
Last Post Today, 03:33 PM |
Leave a comment: