Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to combine " if any" and 'if all in one condition in strategy builder

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

    How to combine " if any" and 'if all in one condition in strategy builder

    Dear Team,
    question1:

    I want to set a condition in strategy builder:
    if (Position.MarketPosition = MarketPosition.Short)
    {

    if(CrossAbove(MACD(12, 26, 9).Default, MACD(12, 26, 9).Avg, 3) || loss>10 )

    {
    Exit short;
    }

    }

    Since there is only if any and if all ,but how to combine them?

    question2:

    I want to set separate value of stop loss to long and short,but in strategy builder ,it seems that I can only set the same stop loss to long and short at the same time.
    Is any good way to solve this issue?

    Thank you very much!
    Last edited by williamzz; 07-03-2019, 03:26 PM.

    #2
    Hello williamzz, thanks for your note.

    You can make a group for your second conditional. In the set, first make this statement: if (Position.MarketPosition = MarketPosition.Short) and set it to if all

    Then add a group and set that group to "If any", then add these conditions to that group: if(CrossAbove(MACD(12, 26, 9).Default, MACD(12, 26, 9).Avg, 3) || loss>10 )

    On your second question: You must give your long and short orders unique signal names. Then you can make two pairs of stops and targets, one set for longs and the other for shorts. You will notice that the set stop loss and set profit target both take a signal name, match this up with the name you gave your orders.

    Kind regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Very helpful!
      Thank you!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,229 views
      0 likes
      Last Post xiinteractive  
      Started by andrewtrades, Today, 04:57 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      7 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      441 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      12 views
      0 likes
      Last Post FAQtrader  
      Working...
      X