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
StreamWritter in MultiTime Frame indicator
Collapse
X
-
Thanks for the quick answer.
I ve found the problem. It appears that i have declared private variables that weren't used in the OnBarUpdate(). I removed them and now all works fine.
-
Hello cbadr,
Are you getting an error when running the script in the Log tab of the Control Center?
You may need a CurrentBars check for each series to have at least 1 bar.
Leave a comment:
-
StreamWritter in MultiTime Frame indicator
0?0%0?0%0Hi,
I have downloaded a sample indicator for streamwriter in NT7 and wanted to use it in a multi time frame manner.
Here below the code. Its doesnt work at all when adding a PeriodeType. Any idea why???
Code:protected override void Initialize() { CalculateOnBarClose = true; Add(PeriodType.Day, 1); } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; double AtrZero; if(ATR(1).Value.ContainsValue(0)) // checks whether the DataSeries contains a value AtrZero = Math.Round(ATR(1).Value.Get(CurrentBar),2); else AtrZero = 0.0; double AtrDay; if(ATR(BarsArray[1],1).Value.ContainsValue(0)) AtrDay = Math.Round(ATR(BarsArray[1],1).Value.Get(CurrentBar),2); else AtrDay = 0.0; try { if (CurrentBar == 0) sw = File.AppendText(path); sw.WriteLine(Time[0]+ " " + Time[0].DayOfWeek.ToString() + " " + AtrZero+ " " + AtrDay); } catch (Exception e) { Log("You cannot write and read from the same file at the same time. Please remove SampleStreamReader.", NinjaTrader.Cbi.LogLevel.Error); throw; } } protected override void OnTermination() { if (sw != null) { sw.Dispose(); sw = null; } }
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by traderqz, Today, 12:06 AM
|
10 responses
18 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
5 responses
46 views
0 likes
|
Last Post Today, 02:36 PM | ||
Started by arvidvanstaey, Today, 02:19 PM
|
1 response
6 views
0 likes
|
Last Post Today, 02:33 PM | ||
Started by mmckinnm, Today, 01:34 PM
|
3 responses
5 views
0 likes
|
Last Post Today, 02:12 PM | ||
Started by f.saeidi, Today, 01:32 PM
|
2 responses
9 views
0 likes
|
Last Post
by f.saeidi
Today, 02:10 PM
|
Leave a comment: