Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

mixing two strategies X EntriesPerDirection

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

    mixing two strategies X EntriesPerDirection

    I ve mixed two strategies in one script. However, when testing it, I see that there is a unwanted interaction taking place. As I see it, there must be something related to EntriesPerDirection.
    How can I let two different logics (algos inside my strat) trigger order. e.g. The strategy is long 2 contracts and due to the other strat buys 1 more..
    In case I allow EntriesPerDirection = 2, one strategy can generate 2 buy orders, and that is not what I want. I want to let each strat generates 1 entry.
    How can I manage EntriesPerDirection that way?

    #2
    Hello dafonseca, and thank you for your question.

    In order to do what you are describing, you will need to set EntriesPerDirection to the total number of entries your strategy will manage - in your case too - and then use flags that are stored outside your OnBarUpdate method. Here is some sample code which can get you started.

    Code:
    [FONT=Courier New]IOrder trade1, trade2;
    protected override void OnBarUpdate()
    {
        bool trade1Condition = false;
    
        if (trade1Condition && trade1 == null)
        {
            trade1 = EnterLong();
        }
    }[/FONT]
    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      I am following you.
      One question:

      let me remake my question..
      i just want to differentiate trade 1 from trade2 on execution().
      Can you inform me if when a Stop order were triggered on trade1 how can I choose between trade1 and trade 2 OnExecution()?

      if (execution.Order != null && (execution.Name == "Stop loss") && ......................)
      {
      carrytrade1long == false;
      }
      the problem is: both stop loss has the same name "Stop loss". if i could get the entry name from the execution() would be fine, but I cant.
      As I ve tested I cannot access IOrder object properties inside OnExecution(), can I?
      Last edited by dafonseca; 10-04-2016, 05:29 PM.

      Comment


        #4
        Provided you defined your IOrder objects outside of any method - as you can see in the example, the ones I posted are defined outside of OnBarUpdate - then you'll be able to access objects like trade1 and trade2 in any method including OnExecution. You will therefore be able to e.g.

        Code:
        [FONT=Courier New]if (execution.Order == trade1 && execution.Order != null)
        [/FONT]
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        368 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        571 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X