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 plots only one value
Collapse
X
-
Indicator plots only one value
I have a simple indicator to plot a dot if close price is x% higher than open price. It only plots for one value for the most recent bar and doesn't work on historical data. Is there a setting to make it do for historical bars as well?Tags: None
-
without seeing this "code", there might be a if (Historical) return type thing in there...
-
I didn't find that in my code.. please see bleow code. its just plotting one value (last value whenever its true even its in historical data). My question is why is not plotting for all bars when its true
public class jBar : Indicator
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#endregion
private double percent = 25; // Default setting for Percent
private int distance = 3;
private int emavalue = 3;
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
if(CurrentBar < 1) return;
//if (Close[0] > High[0] - ((High[0] - Low[0]) * (percent / 100)) && Range()[0] > (EMA(Range(), 20)[1] * 1.5))//EMA(Range(), emavalue)[0] > (EMA(Range(), emavalue)[1] * 1.2))
if (Close[0] < High[0])
{
//Jbars[0] = Low[0] - distance * TickSize;
DrawDot("tag1", true, 0, High[0] + TickSize, Color.DarkGreen);
}
Comment
-
Hello chakriare,
Thank you for writing in.
You need to ensure the tag for each of your dots are different. With the code provided, the DrawDot() method will always overwrite the position of an already existing dot with the tag of "tag1". This is why you only see one dot.
Per the help guide (https://ninjatrader.com/support/help...?drawdot.htm):
A user defined unique id used to reference the draw object. For example, if you pass in a value of "myTag", each time this tag is used, the same draw object is modified. If unique tags are used each time, a new draw object will be created each time.
Example:
Code:DrawDot("tag1" + CurrentBar, true, 0, High[0] + TickSize, Color.DarkGreen);
Zachary G.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Waxavi, Today, 02:10 AM
|
0 responses
3 views
0 likes
|
Last Post
by Waxavi
Today, 02:10 AM
|
||
Started by TradeForge, Today, 02:09 AM
|
0 responses
9 views
0 likes
|
Last Post
by TradeForge
Today, 02:09 AM
|
||
Started by Waxavi, Today, 02:00 AM
|
0 responses
2 views
0 likes
|
Last Post
by Waxavi
Today, 02:00 AM
|
||
Started by elirion, Today, 01:36 AM
|
0 responses
4 views
0 likes
|
Last Post
by elirion
Today, 01:36 AM
|
||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
0 responses
4 views
0 likes
|
Last Post Today, 01:30 AM |
Comment