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 alifarahani, Today, 09:40 AM
      2 responses
      12 views
      0 likes
      Last Post alifarahani  
      Started by junkone, Today, 11:37 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by pickmyonlineclass, Today, 12:23 PM
      0 responses
      1 view
      0 likes
      Last Post pickmyonlineclass  
      Started by frankthearm, Yesterday, 09:08 AM
      12 responses
      44 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by quantismo, 04-17-2024, 05:13 PM
      5 responses
      35 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X