Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I get exit signal from a non- primary data series in a strategy?

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

    How do I get exit signal from a non- primary data series in a strategy?

    Hi all. I've been reading what seems like dozens of posts of multi instrument/ series strategies and indicators, and I can't find a close enough parallel to make mine work. I'm working with a strategy using 5 min bars for an entry signal, and it checks conditions of daily bars (EMA lines). I want to then have an exit signal of a close below a 50 EMA daily bar. So the primary series is the 5 min bars (entry signal) and the added series will generate the exit. But... using the condition below, the exit fires based on 5 min bars.

    Code:
    if((BarsSinceEntry(1,"",0)<=3&&Highs[1][0]<=Highs[1][1]&&Highs[1][1]<=Highs[1][2])||
                        (BarsSinceEntry(1,"",0)>3&&Closes[1][0]<EMA(Closes[1],20)[0]))
                    {
                        ExitLong();    
                    }
    I'm assuming I'm using bars since entry(1,"",0) incorrectly, somehow. Any ideas? Big thanks in advance.

    #2
    CSharpTrader,

    In what order are you adding the series? Can you show me a snippet of your Initialize() method?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Sure. Here's the initialize:

      Code:
      protected override void Initialize()
         {
             CalculateOnBarClose = true;
             ExitOnClose = false;
             Add(PeriodType.Day,1);
         }

      Comment


        #4
        CSharpTrader,

        You may want to include the following :

        if ( BarsInProgress == 1)
        {

        if((BarsSinceEntry(1,"",0)<=3&&Highs[1][0]<=Highs[1][1]&&Highs[1][1]<=Highs[1][2])||
        (BarsSinceEntry(1,"",0)>3&&Closes[1][0]<EMA(Closes[1],20)[0]))
        {
        ExitLong();
        }
        }
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Thanks, looks like that did the trick.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          660 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          375 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
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          579 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X