• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StreamWritter in MultiTime Frame indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • cbadr
    replied
    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.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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.

    https://ninjatrader.com/support/help...urrentbars.htm

    Leave a comment:


  • cbadr
    started a poll StreamWritter in MultiTime Frame indicator

    StreamWritter in MultiTime Frame indicator

    0
    ?
    0%
    0
    ?
    0%
    0
    Hi,

    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;
                }
            }

Latest Posts

Collapse

Topics Statistics Last Post
Started by corman, Today, 04:28 AM
0 responses
8 views
0 likes
Last Post corman
by corman
 
Started by schwamm, Today, 04:26 AM
0 responses
7 views
0 likes
Last Post schwamm
by schwamm
 
Started by elliot5, Today, 04:20 AM
1 response
7 views
0 likes
Last Post elliot5
by elliot5
 
Started by aviat72, Today, 12:41 AM
1 response
12 views
0 likes
Last Post NinjaTrader_ChrisSch  
Started by _Zero_, 01-06-2020, 01:16 PM
2 responses
78 views
2 likes
Last Post CiprianV  
Working...
X