Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Slowly running
Collapse
X
-
two questions:
- why your example of indicator that the only thing it does is "Plot0.Set(Close[0]);" plots the close of the bars but not since the beginning of the chart?. It has nothing in the code - if i'm seeing it ok - to do that. It should plot the close for each bar.
- and then, if i say (in another indicator):
"
date = int.Parse(split[0]);
if (ToDay(Time[0]) == date
{
Print ("found:");
Print (ToDay(Time[0]));
Print (date);
}
else
Print ("not found");
"
then it ALWAYS prints "not found" and only one time it prints:
found:
20081208
20081208
I thought Time[0] is the Time of everybar when the indicator is running across the chart. Not only the last (today) bar.
"date" is the date of the first column in a txt (first created with "SampleStreamWriter"). It should be compared every line (while (sr.ReadLine != null)) with every bar in the chart
ż?
Comment
-
What example of indicator are you talking about? Time[0] is the time of the current bar being referenced. You need to debug your code. If you feel your code is not behaving the way you want just print out the values. Instead of trying to put things into an if-statement just print them out. Then you will see how things behave and then you can figure out how to do it manually. From there then you will be able to codify it.Josh P.NinjaTrader Customer Service
Comment
-
I was doing that just now. And I see that "ToDay(Time[0])" is always today. I'll check more. I don't understand how it behaves.
The other example is very simple: you get it when you create a new indicator without any code. But don't worry about this last question.
I'll try to see what's happening with the "ToDay(Time[0])"
thanks,
jr
Comment
-
If i say "Print (Time[0]);" it always prints "08/12/2008 0:00:00" but if i say another sentence: Plot0.Set(Close[0]) it plots ok the close of every bar. If i say "Print(Close[0])" it always prints the close of the last bar. żWhy?
żPlot0 converts every bar in the time "0"?. It would be solved if existed a "Print0" order. żDo you know what i mean?.
Comment
-
Not sure what you are talking about. Time[0] prints the timestamp of the bar being processed. If you get the same prints it is just the timestamps you are getting. Close[0] will give you the close of the bar being processed. I do not understand your confusion.
You need to understand how bars are processed. It starts with whatever is on the very left of the chart. When you go Close[0] you will print the close of that bar. When you do Time[0] you will get the time of that bar. When that bar closes you now move forward a bar. Now the new bar is now Close[0] and the previous bar is Close[1]. The same with Time[0] and Time[1].
If you are trying to print EVERY close or EVERY time stamp you need to cycle through all of the [] indexing.
I highly suggest you review the indicator tutorials in the Help Guide.Josh P.NinjaTrader Customer Service
Comment
-
I understand - i think - how it runs. It is the same like almost any other sw.
What i want to do, if it'd run, is something like "Print(Plot0.Set(Close[0]));" i.e. print the close of every bar, or the date of every bar or anything of every bar.
I think that this code "Print(Close[0])" should start in the very left of the chart. I should see so many closes in the output window like bars in the chart and not having to cycle through the [] index. If i write "Print(Close[1])" starting in the second bar, i should see the same closes displaced one bar. And so on. My last printing would be the close of the last but one bar. My last but one printing would be the close of the last but two bar, etc. But i should have a printing for each bar in the chart without cycling... If i have to cyle, is there any sentence to know how many bars are there in the chart?
thanks again and excuse me for my insistence.
Comment
-
Why would you run a print on a plot set? Just print out the value the plot is setting to or just print the plot value itself.
You can either do Print(Close[0]) or Print(Plot0[0]). Print(Close[0]) does start at the left of the chart. I do not understand your confusion on this. Your script starts processing from the left to the right. If you tell it to do Print(Close[0]) in OnBarUpdate() it will print the close of every single bar as it processes it.
There is a fundamental disconnect here. You are going to need to copy and paste what you are seeing in your Output Window with a screenshot of what is on the chart. Just do Print(Time[0] + " " + Close[0]). You will see the timestamp of the bar being printed and the close of the bar being printed.Josh P.NinjaTrader Customer Service
Comment
-
Resolved.
There is nothing like clearing almost every text not needed.
Can you now tell me why every matching appears twice in this code:
protected override void OnBarUpdate()
{
sr = new System.IO.StreamReader(path);
string line;
while ((line = sr.ReadLine()) != null)
{
string [] split = line.Split(new Char [] {' '});
date = int.Parse(split[0]);
if (ToDay(Time[0]) == date)
{
Print ("Found:");
Print (ToDay(Time[0]));
Print (date);
}
}
}
like this:
Found:
20081204
20081204
Found:
20081204
20081204
Found:
20081205
20081205
Found:
20081205
20081205
Found:
20081208
20081208
Found:
20081208
20081208
Comment
-
Yes, i know that. But the sequence appears two times (i mean, four times de date and two times "found"):Found:
20081208
20081208
Found:
20081208
20081208
But don't worry. I must investigate. I can't be asking everytime i have an error.
thank you very much,
jr.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
647 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 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
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment