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 StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,967 views
      3 likes
      Last Post jhudas88  
      Started by rbeckmann05, Today, 06:48 PM
      0 responses
      4 views
      0 likes
      Last Post rbeckmann05  
      Started by rhyminkevin, Today, 04:58 PM
      4 responses
      55 views
      0 likes
      Last Post dp8282
      by dp8282
       
      Started by iceman2018, Today, 05:07 PM
      0 responses
      6 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      8 views
      0 likes
      Last Post lightsun47  
      Working...
      X