Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No backtest results

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

    No backtest results

    Is there anything obvious I have wrong with the strategy code below, I'm not getting any results in the backtest for a month run on all dow stocks. I haven't used this thing in a while, but I have other old strategies that are getting results.

    Code:
       protected override void Initialize()
            {
                Add(PeriodType.Day, 1);
    			Add(PeriodType.Day, 5);
    			CalculateOnBarClose = false;
    			
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Condition set 1 Long Entry, current price > week high & current price < 5% from day low. 
    			// And time to start/stop entering positions.
                if ((BarsInProgress == 0) //OnBarUpdate called for 5min bars	
    			&& (Close[0] > Highs[2][0] && Close[0] < Lows[1][0] * 1.05)
    			&& (ToTime(Time[0]) >= timestart && ToTime(Time[0]) < timeend))	
    			
    			//Dayhigh - Daylow > ATR20*.75. AvDailyVol>500k, Stocks $10-90, and ATR>1.5 & ATR<3.	
    			{avgdailyvolume = SMA(Volumes[1],20)[0];}
    			if ((BarsInProgress == 1) //OnBarUpdate called for daily bars
    			&& (Highs[1][0] - Lows[1][0] > ATR(BarsArray[1], 20)[0]*ATRrange)
    			&& (avgdailyvolume > 500000)
    			&& (Closes[1][1] >= 10 && Closes[1][1] <= 90)
    			&& (ATR(BarsArray[1], 20)[0] > 1.5 && ATR(BarsArray[1], 20)[0] < 3))	
    			
                {
                    EnterLong(200);
                }
    			
    			// Condition set 2 Fixed Stop, 
    			if ((BarsInProgress == 0) && (Position.MarketPosition == MarketPosition.Flat))
                {
    				SetStopLoss(CalculationMode.Price, ATR(BarsArray[1], 14)[0]*longstopATRperc);
    			}
    			// Condition set 3 Trail Trigger & Trail How
    			else if ((BarsInProgress == 0)
                &&	(Position.MarketPosition == MarketPosition.Long && ToTime(Time[0]) > 93500))  
    			{SetStopLoss(CalculationMode.Price, Swing(1).SwingLowBar(0, 1, 10));}
    
    			// Condition set 4 Long Exit,
    			if (ToTime(Time[0]) >= 155000)
    			{
                    ExitLong(200);
                }
            }

    #2
    zachj, if you run this script - are you getting any errors in your Control Center Log tab? If not I would suggest simplying the script / debugging to better understand why condition would not trigger as you expect from the code.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Does it matter where I define.... {avgdailyvolume = SMA(Volumes[1],20)[0];} in the script I posted? Do I have it in the right place?

      Also is having a barsinprogess=0 and then barsinprogress=1 all in one entry condition as I have messing anything up?

      Comment


        #4
        zachj, you can mix BarsInProgress in your OnBarUpdate(), however for your script - when you want then to enter? Intraday? Then I would not suggest submitting from the daily series, but merely using it for calculations.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        27 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 04-23-2024, 09:53 PM
        2 responses
        74 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        193 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,235 views
        0 likes
        Last Post xiinteractive  
        Working...
        X