- Look up BarsPeriod in the NT Help to see how you can .
- Query BarsPeriod.BasePeriodType
- If it is not what you want, return out of the event handler, in this case, most likely OnBarUpdate().
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
3 Points within 2 Bars
Collapse
X
-
That is because the computer is processing what you wrote. What you wrote is a set of conditions that can NEVER be satisfied.Originally posted by FxInception View PostThese is no error in a log, just nothing paints...
Please find it attached if you would like to have a look.
Thanks,
Arthur
Look at it and refactor it, and what it translates to is:"if the Close of this bar is equal to the Close of the previous bar and the Close of the previous bar (because it is equal to this bar), is higher than the high of the previous bar ..."
A bar cannot close higher than its high.
Comment
-
Ok, thank you, will try to rewrite it correctly
But in order to have a unique line each time and keep other lines on chart, which Tag a have to use? (plot each line that matches a single condition historically)
It says in guide:
"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."
Or it has to be applied another method to achieve this?
Many thanks,
Arthur
Comment
-
Create or find anything that is unique and use it, or concatenate it to another string and use the result. You can set up a counter, or you can use the natural counter called CurrentBar, as it has a unique one-to-one correspondence with the bars on the chart.Originally posted by FxInception View PostOk, thank you, will try to rewrite it correctly
But in order to have a unique line each time and keep other lines on chart, which Tag a have to use? (plot each line that matches a single condition historically)
It says in guide:
"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."
Or it has to be applied another method to achieve this?
Many thanks,
Arthur
Comment
-
Ok, I've got what I want in terms of initial expression.
But, as I told, the line which correspond to a particular condition disappear when the new same condition occur.
Sorry Koganam, I can't really get what you mean in the last message, if that is solution to this... If so, could you explain it please a bit more precise.
Just to clarify:
Simple Higher High, Higher Low:
if ((High[0] > High[1]) && (Low[0] > Low[1]))
DrawLine("MyLine1", true, 1, Low[1], 0, Low[0], Color.Blue, DashStyle.Solid, 1);
I would like to have this line on each HH HL from the very beginning of historical data.
Many thanks,
Arthur
Comment
-
I said that the bar Number is unique to the bar, so just concatenate it to the stub.Originally posted by FxInception View PostOk, I've got what I want in terms of initial expression.
But, as I told, the line which correspond to a particular condition disappear when the new same condition occur.
Sorry Koganam, I can't really get what you mean in the last message, if that is solution to this... If so, could you explain it please a bit more precise.
Just to clarify:
Simple Higher High, Higher Low:
if ((High[0] > High[1]) && (Low[0] > Low[1]))
DrawLine("MyLine1", true, 1, Low[1], 0, Low[0], Color.Blue, DashStyle.Solid, 1);
I would like to have this line on each HH HL from the very beginning of historical data.
Many thanks,
Arthur
Code:DrawLine("MyLine1"+CurrentBar.ToString(), true, 1, Low[1], 0, Low[0], Color.Blue, DashStyle.Solid, 1);
Comment
-
Thanks a lot mate, now I got it!Originally posted by koganam View PostI said that the bar Number is unique to the bar, so just concatenate it to the stub.
Code:DrawLine("MyLine1"+CurrentBar.ToString(), true, 1, Low[1], 0, Low[0], Color.Blue, DashStyle.Solid, 1);
Another issue I came up with:
double BarSize = (High[0] - Low[0]) / TickSize;
if (BarSize < BarsPeriod.Value)
DrawLine("Tag1" + CurrentBar.ToString(), true, 0, High[0], 0, Low[0], Color.Blue, DashStyle.Solid, 1);
It draws this line on each bar, which is smaller than period value. But for some reason it draws it on some other ordinary bars as well.. I use range bars in case. Any idea why it happens?
Many thanks,
Arthur
Comment
-
It looks like rounding errors may be flummoxing you. Print out the values to check.Originally posted by FxInception View PostThanks a lot mate, now I got it!
Another issue I came up with:
double BarSize = (High[0] - Low[0]) / TickSize;
if (BarSize < BarsPeriod.Value)
DrawLine("Tag1" + CurrentBar.ToString(), true, 0, High[0], 0, Low[0], Color.Blue, DashStyle.Solid, 1);
It draws this line on each bar, which is smaller than period value. But for some reason it draws it on some other ordinary bars as well.. I use range bars in case. Any idea why it happens?
Many thanks,
Arthur
You may want to try casting to int, or using Math.Ceiling() or Math.Floor(): after all, BarSize is attempting to find the size of the bar in ticks, which must be an integer.
Comment
-
Originally posted by koganam View PostIt looks like rounding errors may be flummoxing you. Print out the values to check.
You may want to try casting to int, or using Math.Ceiling() or Math.Floor(): after all, BarSize is attempting to find the size of the bar in ticks, which must be an integer.
Yes, you were right, that's why it happens:
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
I am not familiar with Math operators yet... But I've checked that I have to use Ceiling. Does it has to be written exactly like this?
double value;
string nl = Environment.NewLine;
Console.WriteLine("{0}Ceiling:", nl);
for (value = 0.0; value <= 1.1; value += 0.1)
Console.WriteLine("Ceiling({0:f}) = {1}", value, Math.Ceiling(value));
Don't think so, but have no clue at all..
Many thanks,
Arthur
Comment
-
Originally posted by FxInception View PostYes, you were right, that's why it happens:
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
19.9999999999989 20
I am not familiar with Math operators yet... But I've checked that I have to use Ceiling. Does it has to be written exactly like this?
double value;
string nl = Environment.NewLine;
Console.WriteLine("{0}Ceiling:", nl);
for (value = 0.0; value <= 1.1; value += 0.1)
Console.WriteLine("Ceiling({0:f}) = {1}", value, Math.Ceiling(value));
Don't think so, but have no clue at all..
Many thanks,
ArthurCode:double BarSize = Math.Ceiling((High[0] - Low[0]) / TickSize);
Comment
-
A second ago sorted it out myself:Originally posted by koganam View PostCode:double BarSize = Math.Ceiling((High[0] - Low[0]) / TickSize);
double BarSize = (High[0] - Low[0]) / TickSize;
double RoundBarSize = Math.Round(BarSize);
But will prefer a single line as you wrote.
Thanks a lot, much appreciate your help!
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
606 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
351 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
560 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
561 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment