Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No results from Backtest

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

    No results from Backtest

    Hello,

    I have not been able to get any results by backtesting my own strategy or SampleMACrossOver. I cannot see what I am doing wrong, as I have read the help file and followed the instructions there and on the video. I have the historical data and have connected to MarketReplay as well as tried it without any connections, and results are always 0. Any ideas?

    Thanks!

    #2
    Hello GeorgeW,


    What instrument (and expiry if applicable) have you selected?


    What Bar type and interval are you running your backtest on?


    Who are you connected to? This is displayed by green on lower left corner of the Control Center window.
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      Hello ShawnB,
      1. I have tried it with ES 09-15 and 03-16
      2. I am using Tick data, 750
      3. I am connected to Market Replay Data. I don't have a live acoount yet.


      Thanks!

      Comment


        #4
        Hello GeorgeW,


        Do you have historical Tick data for the instrument and dates you are testing?


        You can check what data you have by going to Tools > Historical Data Manager > Edit tab.


        Here is the Historical Data Editing Help Guide to assist you further.
        Shawn B.NinjaTrader Customer Service

        Comment


          #5
          I do. I just checked the Edit tab, and 09-15 is there, but I don't see 12-15 or 03-16, even though I have up to 17 Feb 2016 in the folder and I have been trading SIM replays with that data.
          Last edited by GeorgeW; 03-11-2016, 12:21 PM.

          Comment


            #6
            I have been downloading my historical data with Market Replay Downloader and not NT, so I don't know if that makes a difference.

            Comment


              #7
              Ok, I downloaded the last 2 weeks tick data up to Wednesday and the SampleMACross is now generating backtest data. My own strategy is not doing so, but I now know that is probably a logic problem and will check.

              Thank you.

              Comment


                #8
                Originally posted by NinjaTrader_ShawnB View Post
                Hello GeorgeW,


                Do you have historical Tick data for the instrument and dates you are testing?


                You can check what data you have by going to Tools > Historical Data Manager > Edit tab.


                Here is the Historical Data Editing Help Guide to assist you further.
                Just a note to say that the edit tab includes a lot of folders which do not hold any historical data. I browsed to check the folder and they were empty. It seems that when I download market replay data with Market Replay Downloader, it also installs an empty folder to the historical tick data folder. I'll have to get historical tick data elsewhere.

                The reason my strategy was not generating any entries in market replay mode was due to the BarsSinceEntry not being correctly coded. The solution was to do 2 separate if statements for each type of entry (usually just long and short, so 4 in all). The first starting with a bool: if (firstTradeOccurred = false && other conditions) which then switches it to true in the actions below the first entry {entry actions; firstTradeOccurred = true;}, and then a second if statement which starts:if (firstTradeOccurred = true && BarsSinceEntry("") > 7 && other conditions) {entry actions,}.

                Comment


                  #9
                  Hello,

                  My backtest is still failing:

                  1. Strategy analyzer backtest produces no results
                  2. Historical data on computer. Downloaded from Continuum.
                  3. Instrument tested ES 12-15, OR 03-16
                  4. 750 Tick data – also tried 1 minute
                  5. SampleMACrossOver – produces results in Backtest for both Tick and Minute data
                  6. My strategy produces results when tested with MarketReplay data
                  7. My strategy uses SetStopLoss and SetProfitTarget in initialize section. The StopLoss is reset in OnBarUpdate(). Then it may be reset again to trail in: protected override void OnMarketData(MarketDataEventArgs e)


                  I would welcome suggestions of how to resolve this.
                  Thanks!

                  Edit: Just found this thread http://ninjatrader.com/support/forum...ad.php?t=72618
                  and commenting out if (Historical) return; now means strategy produces results.

                  It would help if information like this was in a prominent place in the Help manual section dealing with backtests. It would have saved me several days of knocking my head against a wall.
                  Last edited by GeorgeW; 03-21-2016, 06:33 AM.

                  Comment


                    #10
                    I now get a backtest for my strategy, but my trailing stop, which is set as a SetStopLoss in the protected override void OnMarketData(MarketDataEventArgs e) method is not trailing, and entries which should show a profit (and do so in MarketReplay) are exiting at a loss.
                    I have followed Chelsea_B's advice in this thread: http://ninjatrader.com/support/forum...ad.php?t=50521 to include the string FromEntrySignal in the SetStopLoss parameters, but the trailing part of the code still does not work. Any advice?

                    Code:
                       protected override void Initialize()
                            {
                    			// set the initial stop loss and profit target
                    			
                    			SetStopLoss("LE1", CalculationMode.Ticks, stoplossticks, false);
                    			SetStopLoss("SE1", CalculationMode.Ticks, stoplossticks, false);
                    			SetProfitTarget(CalculationMode.Ticks, profittargetticks);
                    			
                    			DefaultQuantity = 1;
                    			
                    			
                    			EntriesPerDirection = 1; 
                    			EntryHandling = EntryHandling.AllEntries;
                    	}
                    
                    
                            protected override void OnBarUpdate()			
                    		
                            {
                    			if (CurrentBar < period) return;
                    
                    			// Resets the stop loss to the original value when all positions are closed
                    			if (Position.MarketPosition == MarketPosition.Flat)
                    			{
                    				currentStop = 0;			
                    				stoplossticks = flatStopLossTicks;
                    				trail = false;
                    				SetStopLoss("LE1", CalculationMode.Ticks, stoplossticks, false);
                    				SetStopLoss("SE1", CalculationMode.Ticks, stoplossticks, false);
                    			}
                    
                    				//Set initial stop loss position - short entry	
                    				else if (Position.MarketPosition == MarketPosition.Short && trail == false 
                    				&& Math.Abs(((MAX(High,3)[0] + TickSize) - Position.AvgPrice) * tickPriceMultiplier) > stoplossticks
                    				&& Math.Abs(((MAX(High,3)[0] + TickSize) - Position.AvgPrice) * tickPriceMultiplier) < maxStopTicks)
                    				
                    				{
                    				if (GetCurrentAsk() > (MAX(High,3)[0] + TickSize))
                    				
                    				{currentStop = GetCurrentAsk();}	
                    				
                    				else
                    				
                    				{
                    				stoplossticks = (int) Math.Abs(((MAX(High,3)[0] + TickSize) - Position.AvgPrice) * tickPriceMultiplier); 
                    				SetStopLoss("SE1", CalculationMode.Ticks, stoplossticks, false);//My insert
                    				currentStop = Position.AvgPrice + stoplossticks * TickSize;
                    				}
                    
                    				
                    				}
                    
                    				else if (Position.MarketPosition == MarketPosition.Short && trail == false 
                    				&& Math.Abs(((MAX(High,3)[0] + TickSize) - Position.AvgPrice) * tickPriceMultiplier) > stoplossticks
                    				&& Math.Abs(((MAX(High,3)[0] + TickSize) - Position.AvgPrice) * tickPriceMultiplier) >= maxStopTicks)
                    				
                    				{
                    				if (GetCurrentAsk() > (MAX(High,3)[0] + TickSize))
                    				{currentStop = GetCurrentAsk();}	
                    				
                    				else
                    				
                    				{
                    				stoplossticks = maxStopTicks; //restricts max protective stop to maxStopTicks
                    				SetStopLoss("SE1", CalculationMode.Ticks, stoplossticks, false); //My insert
                    				currentStop = Position.AvgPrice + stoplossticks * TickSize;
                    				
                    				}
                    				}						
                    
                    			
                    				//To set stop loss to trailing stop once price falls to currentStop minus 11ticks
                    
                    				else if (Position.MarketPosition == MarketPosition.Short && trail == false 
                    				&& Low[0] <= currentStop - maxStopTicks * TickSize)
                    				{	
                    				trail = true; // after the trail is set to true, the stop loss trail in OnMarketData will take over
                    
                    				}
                    				//Set initial stop loss position - long entry
                    				//Similar to above conditions for short
                    
                    				ENTER LONG & SHORT CONDITIONS AND ACTIONS ARE HERE.
                    
                            }
                    		protected override void OnMarketData(MarketDataEventArgs e)
                    			{
                    				// After 12 ticks set stop loss to CurrentPrice - 11 Ticks. Repeat every 2 ticks.
                    				// This is done in OnMarketUpdate so that it happens intra-bar
                    				if (Position.MarketPosition == MarketPosition.Long) 
                    				if (e.MarketDataType == MarketDataType.Last && trail == true && e.Price >= currentStop + maxStopTicks * TickSize)
                    				{
                    				if (GetCurrentBid() < e.Price - maxStopTicks * TickSize)
                    				{currentStop = e.Price;}
                    				else
                    				{currentStop = e.Price - maxStopTicks * TickSize;}
                    				
                    				SetStopLoss("LE1", CalculationMode.Ticks, stoplossticks, false);//My insert
                    
                    				}
                    				//Smiilar condtions set for long.
                    			}

                    Comment


                      #11
                      To clarify matters, the part of the code that is not working in the strategy analyzer backtest is the trailing stop part within: protected override void OnMarketData(MarketDataEventArgs e)., although it does work in MarketReplay. I have checked the Traceorders and the first time the trail is required it does not come into play, and as price does not come back to the initial revised stop at stage 2 of my stop loss code above, that entry continues to run until the end of the day when it is closed - although price does come back to where the trailing stop should be. I have also tried the following for the trail, but the same results.

                      Code:
                      	protected override void OnMarketData(MarketDataEventArgs e)
                      		{
                      			if (Position.MarketPosition == MarketPosition.Short) 
                      			if (e.MarketDataType == MarketDataType.Last && trail == true && e.Price <= currentStop - maxStopTicks * TickSize)
                      			{						
                      				currentStop = (e.Price * tickPriceMultiplier) + maxStopTicks;
                      				SetStopLoss("SE1", CalculationMode.Ticks, currentStop - (e.Price * tickPriceMultiplier), false);		
                      			}
                      			
                      			if (Position.MarketPosition == MarketPosition.Long) 
                      			if (e.MarketDataType == MarketDataType.Last && trail == true && e.Price >= currentStop + maxStopTicks * TickSize)
                      			{							
                      				currentStop = (e.Price * tickPriceMultiplier) - maxStopTicks;
                      				SetStopLoss("LE1", CalculationMode.Ticks, ((e.Price * tickPriceMultiplier) - currentStop), false);
                      			}
                      		}

                      Comment


                        #12
                        Hello GeorgeW,

                        We have received your inquiry. We will look into the issue and report back to you with anything we find.

                        Thank you for your patience.
                        Shawn B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello ShawnB,
                          This matter has now been resolved in this thread with ChelseaB. http://ninjatrader.com/support/forum...700#post453700
                          Thank you.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by algospoke, Yesterday, 06:40 PM
                          2 responses
                          24 views
                          0 likes
                          Last Post algospoke  
                          Started by ghoul, Today, 06:02 PM
                          3 responses
                          15 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by jeronymite, 04-12-2024, 04:26 PM
                          3 responses
                          46 views
                          0 likes
                          Last Post jeronymite  
                          Started by Barry Milan, Yesterday, 10:35 PM
                          7 responses
                          23 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by AttiM, 02-14-2024, 05:20 PM
                          10 responses
                          181 views
                          0 likes
                          Last Post jeronymite  
                          Working...
                          X