Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Streamwriter in Multi-Strategy

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

    Streamwriter in Multi-Strategy

    Dear NT team

    I am trying to build a multi-time frame strategy (weekly/daily) that will print daily values into a txt file.

    I have my strategy programmed and have added the streamwriter code. If I use only one time frame, it will print the daily values (even if am running the strategy on weekly) AND the weekly prints (so there are double prints for Fridays).

    How can I change the code in the streamwriter to only print the daily values. I am receiving this error message

    **NT** Error on calling 'OnBarUpdate' method for strategy 'a1027SSTTSposONEPRINTwrite/a6bf1b5b51eb4bd1a4cbe054eea7ac05': Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    if I use:
    try
    {
    // If file at 'path' doesn't exist it will create the file. If it does exist it will append the file.
    if (CurrentBar == 0 && BarsInProgress == 1)
    sw = File.AppendText(path);

    // This is the output of all lines.
    sw.WriteLine(Time + ";" + Instrument.FullName + ";Exp;" );
    }
    As mentioned, the strategy is the same and works without the streamwriter; and the streamwriter works well without the BarsInProgress, so it has to do something with Bars In Progress.

    I have researched the forum but could not find an answer. How would I call the streamwriter on the daily update bar (=bars in Progress ==1) (weekly is BarsInProgress==0).

    Thank you for your help
    wtmnn

    #2
    Problem resolved

    Dear NT team

    I have resolved the problem myself. thus, this thread can be deleted. thank you.

    wtmnn
    Last edited by whotookmynickname; 03-21-2012, 03:11 PM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmoran13, Yesterday, 01:02 PM
    0 responses
    27 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    18 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    160 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    95 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    148 views
    2 likes
    Last Post CaptainJack  
    Working...
    X