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 fitspressoburnfat, Today, 04:25 AM
      0 responses
      2 views
      0 likes
      Last Post fitspressoburnfat  
      Started by Skifree, Today, 03:41 AM
      1 response
      4 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      604 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      23 views
      0 likes
      Last Post xiinteractive  
      Working...
      X