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

trigger when strategy NOT met

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

    trigger when strategy NOT met

    Hello,

    Let's say I have a custom strategy called "apples", with criteria in it to trigger an action. Let's say I have another called "oranges", with a different set of criteria.

    I would like to create a trigger that basically says, if neither of those strategies are triggered, take a certain action (buy/sell/etc).

    Is it possible for a custom strategy in NT to reference other strategies which I have saved?

    EDIT: I've seen other posts that say calling outside strategies into a current running strategy doesnt work.

    So then lets say I have this....

    if ( indicator1 > 10
    && indicator2 > 300

    {buy etc}

    if ( macd > 1
    && bollinger > 2)

    {sell etc}

    so here, i have 2 conditions in 1 strategy....but....i would like there to be a condition here that says, if neither of these are met, then take a different action.
    Last edited by Bobbybattles; 05-10-2021, 06:59 PM.

    #2
    Hi Bobbybattles,
    You could add/use a bool (e.g. "CanDoTheTrade") and set it to "false", if the first or/and the second condition set is true.
    Only if the first and the second condition are false, set the CanDoTheTrade to "true", then allow the strat to fire.

    if ((first condition set) || (second condition set))
    { CanDoTheTrade = false; }
    else { CanDoTheTrade = true; }

    if ((CanDoTheTrade = true) && (third condition set)
    {
    Fire off the trade;
    CanDoTheTrade = false; (optional)
    }

    NT-Roland


    Last edited by NT-Roland; 05-11-2021, 01:09 AM.

    Comment


      #3
      Hello BobbyBattles,

      Thank you for your post.

      You could write to static variables in an addon to have strategies share variables with one another.

      See the sample script created by my colleague Chelsea in this forum post demonstrating the use of static variables.


      Let us know if we may assist further.
      Brandon H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by funk10101, Today, 11:35 AM
      0 responses
      0 views
      0 likes
      Last Post funk10101  
      Started by samish18, Today, 11:26 AM
      0 responses
      1 view
      0 likes
      Last Post samish18  
      Started by Trader146, 03-29-2024, 01:22 PM
      2 responses
      14 views
      0 likes
      Last Post Trader146  
      Started by tsantospinto, 04-12-2024, 07:04 PM
      7 responses
      127 views
      0 likes
      Last Post aligator  
      Started by futtrader, 04-21-2024, 01:50 AM
      5 responses
      56 views
      0 likes
      Last Post NinjaTrader_Eduardo  
      Working...
      X