Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Secondary data series in strategy not working..

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

    Secondary data series in strategy not working..

    Hi all. I'm trying to add a secondary data series (new instrument and different time period) to my strategy. My goal is pretty simple, I want to look for a currently "up" market by checking one ten minute bar back of symbol SPY. My code is below.. without the check for Spy Close> Open (if(Closes[1][1]>Opens[1][1])), this strategy runs. With it, I get all 0's in the statistics grid. Any ideas? Thanks in advance...

    Code:
    protected override void Initialize()
            {
                CalculateOnBarClose = true;
                
                Add("SPY", PeriodType.Minute, 10);
            }
            
            protected override void OnBarUpdate()
            {
                if(CurrentBar<85)
                {
                    Print("Not enough bars. Current bar count: " + CurrentBar);
                    return;
                }
                else
                {
                    if(BarsInProgress==0)
                    {
                        if(Closes[1][1]>Opens[1][1])
                        {
                            if((Close[0]>SMA(50)[0])&&
                            (ToTime(Time[0])<= 140000)&&
                            (Close[0]>Open[0])&&
                            (Close[0]>(MAX(High,10)[1]))&&
                            (Slope(SMA(50),11,1)<0)&&
                            (Low[0] <= SMA(50)[0])&&    
                            (CrossAbove(SMA(10),SMA(20),20))&&
                            (CountIf(delegate {return Close[0]>SMA(20)[0];},10)>4)&&
                            (CountIf(delegate {return (SMA(10)[0]<SMA(20)[0])&&(SMA(20)[0]<SMA(50)[0]);},30)>9)&&
                            (CountIf(delegate {return Low[0]>SMA(50)[0];},10)<3))
                            EnterLong();
                        }
                        
                        if(Close[0]<SMA(5)[0])
                            ExitLong();
                    }
                }
    }

    #2
    Got it.

    I've found the issue. You can't use CountIf() in a multi- instrument strategy. Thanks..

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    668 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    377 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X