Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inaccurate backtest on instrument lists?

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

    Inaccurate backtest on instrument lists?

    the attached pics show the result of testing a list of instruments with a strategy using same set param (indeed, i simply back test it twice without changing anything).

    1st test show total number of trade is 414 and 2nd test show total # is 424.

    I'm using version 7.0.1000.2
    Attached Files

    #2
    Hello lawrence124

    Thank you for your post.

    Please provide the steps you take prior to receiving these results. This will allow us to attempt to recreate the issue on our end.

    I look forward to assisting you further.
    ChipNinjaTrader Customer Service

    Comment


      #3
      I got rid of the problem after i removed the trade log code, it would be great of you can tell me what caused the error as the log only save info, it shouldn't interfere with the strategy code :

      protected override void OnPositionUpdate(IPosition position)
      {

      if (position.MarketPosition == MarketPosition.Flat)
      {
      //To access the last completed trade please try
      Trade lastTrade = Performance.AllTrades[Performance.AllTrades.Count - 1];

      if (lastTrade != null)
      {
      //Print("The last trade profit is " + lastTrade.ProfitPoints);
      }
      // Do something like reset some variables here

      if (lastTrade != null)
      {
      sw.WriteLine("Instrument: ,"+Instrument.FullName + ",entry: ,"+ToDay(lastTrade.Entry.Time)+"," + lastTrade.Entry.Price+ ",exit: ,"+ToDay(lastTrade.Exit.Time)+"," + lastTrade.Exit.Price );
      }
      }
      if (position.MarketPosition == MarketPosition.Long )
      {
      // Do something like reset some variables here
      //sw.WriteLine(ToDay(Time[0]) +",Instrument: "+Instrument.ToString() + ",go long: " + position.AvgPrice);
      }
      if (position.MarketPosition == MarketPosition.Short )
      {
      // Do something like reset some variables here
      //sw.WriteLine(ToDay(Time[0]) +",Instrument: "+Instrument.ToString() + ",go short: " + position.AvgPrice);
      }
      }

      protected override void OnStartUp()
      {
      try
      {
      // If file at 'path' doesn't exist it will create the file. If it does exist it will append the file.
      sw = System.IO.File.AppendText(path);

      // This is the output of all lines. The output format is as follows: Date Open High Low Close

      }

      catch (Exception e)
      {
      // Outputs the error to the log
      Log("You cannot write and read from the same file at the same time. Please remove SampleStreamReader.", NinjaTrader.Cbi.LogLevel.Error);
      throw;
      }
      }
      // Necessary to call in order to clean up resources used by the StreamWriter object
      protected override void OnTermination()
      {
      // Disposes resources used by the StreamWriter
      if (sw != null)
      {
      sw.Dispose();
      sw = null;
      }
      }

      Comment


        #4
        Hello,

        This would not make a difference. Most likely something else or due to this comment out was resolved.

        However one thing I do know is that log messages to the log, expecially in either OnBarUpdate or in OnPositionUpdate() will cause issues with NinjaTrader running. Since you using all the RAM on log messages. Since all log messages are loaded in the control center in the background.

        I have seen where this will bring NinjaTrader down to be very slow on startup for example when there are too many log messages.

        Let me know if I can be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by geddyisodin, Yesterday, 05:20 AM
        9 responses
        50 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by George21, Today, 10:07 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        20 views
        0 likes
        Last Post DayTradingDEMON  
        Started by Stanfillirenfro, Today, 07:23 AM
        9 responses
        23 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by navyguy06, Today, 09:28 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X