Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Very Starnge outputs between Print & File!?

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

    Very Starnge outputs between Print & File!?

    Using the below code, the Last is printed to the output just fine which matches with the T&S perfectly. However using the second line of code after the Print statement to wrtite the same data to a .txt file causes some additional data which seem to be the Bid Ask data to be added to the file although the code below is not asking for it?!
    What’s wrong with my code below which BTW are extracts from the NT supplied samples.
    Thanks

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if (e.MarketDataType == MarketDataType.Last)
    Print(e.Time + ", L ," + e.Price + ", " + e.Volume );
    string myString = (e.Time + ", L ," + e.Price + ", " + e.Volume) + Environment.NewLine;
    File.AppendAllText(path, myString);
    }

    Data printed to output Data written to file

    4/10/2008 4:13:14 PM, L ,1363, 40 4/10/2008 4:13:14 PM, L ,1363, 40
    4/10/2008 4:13:14 PM, L ,1363, 275 4/10/2008 4:13:14 PM, L ,1363, 275
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,1362.75, 1168
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,0, 1777351
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,1363, 275
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,1363.25, 823
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,1363, 226
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,0, 1777352
    4/10/2008 4:13:14 PM, L ,1363, 1 4/10/2008 4:13:14 PM, L ,1363, 1
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,1363.25, 748
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,1363, 325
    Extra Data written to file! 4/10/2008 4:13:14 PM, L ,0, 1777373
    4/10/2008 4:13:14 PM, L ,1363, 21 4/10/2008 4:13:14 PM, L ,1363, 21

    #2
    The results you are getting is exactly what you have coded...

    You need to encapsulate with curly braces:

    Code:
    [FONT=Courier New][COLOR=#0000ff]protected[/COLOR] [COLOR=blue]override[/COLOR] [COLOR=blue]void[/COLOR] OnMarketData(MarketDataEventArgs e)[/FONT]
    [FONT=Courier New]{[/FONT]
    [FONT=Courier New][COLOR=blue]   if[/COLOR] (e.MarketDataType == MarketDataType.Last)[/FONT]
    [FONT=Courier New]   {[/FONT]
    [FONT=Courier New]   Print(e.Time + [COLOR=maroon]", L ,"[/COLOR] + e.Price + [COLOR=maroon]", "[/COLOR] + e.Volume );[/FONT]
    [FONT=Courier New][COLOR=blue]   string[/COLOR] myString = (e.Time + [COLOR=maroon]", L ,"[/COLOR] + e.Price + [COLOR=maroon]", [/COLOR]+  e.Volume) +[COLOR=teal] Environment[/COLOR].NewLine;[/FONT]
    [FONT=Courier New][COLOR=teal]   File[/COLOR].AppendAllText(path, myString);[/FONT]
    [FONT=Courier New]   }[/FONT]
    [FONT=Courier New]}[/FONT]
    RayNinjaTrader Customer Service

    Comment


      #3
      Ray,
      Thanks you so much for your prompt response.
      Obviously a beginner still on training wheels here .

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      56 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      37 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      18 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      20 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      49 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X