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 f.saeidi, Today, 08:03 AM
      0 responses
      4 views
      0 likes
      Last Post f.saeidi  
      Started by cre8able, 04-17-2024, 04:16 PM
      7 responses
      64 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by Aviram Y, 08-09-2023, 09:04 AM
      11 responses
      299 views
      0 likes
      Last Post arjandezeeuw  
      Started by Christopher Leggit, 02-15-2024, 09:00 AM
      3 responses
      47 views
      0 likes
      Last Post rdtdale
      by rdtdale
       
      Started by DavidHP, Today, 07:56 AM
      0 responses
      4 views
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Working...
      X