Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi- instument strategy giving results I'm not expecting

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

    Multi- instument strategy giving results I'm not expecting

    Hi... I thought I had the basics down of multi-instrument strategies but apparently not. The strategy below is returning trades that have no similarities to the conditions coded. For example, entries at 9:35am and 4:00pm (I have coded only between 10-2), no moving average conditions present as specified, etc. Any ideas?

    Code:
    protected override void Initialize()
            {
                CalculateOnBarClose = true;
                Add("SPY",PeriodType.Minute,5);
            }
    
            protected override void OnBarUpdate()
            {
                if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired){return;}
                else
                {
                    if(BarsInProgress==0)
                    {
                        if(((ToTime(Time[0])>= 100000) && (ToTime(Time[0])<= 140000)) &&
                            (Closes[1][0]>Closes[1][Bars.BarsSinceSession-1]))    //is market up?
                        {
                            if((Close[0]>EMA(50)[0])&&
                                (Close[0]>EMA(10)[0])&&
                                (Open[0]<EMA(50)[0])&&
                                ((High[0]-Close[0])/(High[0]-Low[0])<=.25)&&
                                (CountIf(delegate{return High[1]<=EMA(20)[1];},30)>=28)&&
                                (CountIf(delegate{return EMA(20)[0]<EMA(50)[0];},30)==30)&&
                                (Volume[0]>=SMA(Volume,15)[2]*4))
                            {
                                EnterLong(0,100,"Signal");
                            }
                        }
                        if(Position.MarketPosition==MarketPosition.Long)
                        {
                            if(Close[0]<EMA(20)[0])
                                ExitLong(0,100,"Exit","Signal");
                        }
                    }
                }
            }

    #2
    Where are you testing this? Market Replay? Strategy Analyzer? Sim? Live?

    What is the time frame of the main series?

    The code looks right glancing at it, but your setup might be incorrect.



    Originally posted by CSharpTrader View Post
    Hi... I thought I had the basics down of multi-instrument strategies but apparently not. The strategy below is returning trades that have no similarities to the conditions coded. For example, entries at 9:35am and 4:00pm (I have coded only between 10-2), no moving average conditions present as specified, etc. Any ideas?

    Code:
    protected override void Initialize()
            {
                CalculateOnBarClose = true;
                Add("SPY",PeriodType.Minute,5);
            }
    
            protected override void OnBarUpdate()
            {
                if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired){return;}
                else
                {
                    if(BarsInProgress==0)
                    {
                        if(((ToTime(Time[0])>= 100000) && (ToTime(Time[0])<= 140000)) &&
                            (Closes[1][0]>Closes[1][Bars.BarsSinceSession-1]))    //is market up?
                        {
                            if((Close[0]>EMA(50)[0])&&
                                (Close[0]>EMA(10)[0])&&
                                (Open[0]<EMA(50)[0])&&
                                ((High[0]-Close[0])/(High[0]-Low[0])<=.25)&&
                                (CountIf(delegate{return High[1]<=EMA(20)[1];},30)>=28)&&
                                (CountIf(delegate{return EMA(20)[0]<EMA(50)[0];},30)==30)&&
                                (Volume[0]>=SMA(Volume,15)[2]*4))
                            {
                                EnterLong(0,100,"Signal");
                            }
                        }
                        if(Position.MarketPosition==MarketPosition.Long)
                        {
                            if(Close[0]<EMA(20)[0])
                                ExitLong(0,100,"Exit","Signal");
                        }
                    }
                }
            }

    Comment


      #3
      Thank you sledge. I was running it on 5 min bars in strategy analyzer. I had been backtesting a different strategy from the same analyzer before, and, going out on a limb here, I wonder if this had something to do with it. I say this since after restarting NT and rerunning the strategy (and removing the other instrument) it performed as expected..

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, Yesterday, 10:06 AM
      0 responses
      20 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      18 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      9 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      40 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X