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

No new longs 'til I get a short signal?

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

    No new longs 'til I get a short signal?

    I thought it would be simple, but if I wanted to define the condition that I could only initiate a long trade once (at a long entry signal) and then wait for a short signal and enter short once etc etc, how might I do that?

    For instance, I'm practising with a simple "if price opens > than this MA; enter long". I don't want it to keep entering long every subsequent time a new bar opens > than the MA. The next trade must be a short at a short signal. Whether it ever comes is another matter

    If that makes any sense at all?

    The Entries per Direction works, but not for this, because as soon as my previous trade closes (stopped or take profit) that opens the door for another in the same direction.

    Many thanks for any help

    p.s. I'm only using the wizard. I'm not a code-savvy user, sadly.

    #2
    Hi 5iver, have you tried using a CrossAbove condition as entry combined with the EntriesPerDirection?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      What you want to do is create yourself temporary variables. For your long condition you want to check for the temp variable to be true otherwise no trading (except for maybe the first entry). When you get short you set the variable to true.

      Untested code
      Code:
      if (condition && (wasShort || firstTrade))
      {
           EnterLong();
           firstTrade = false;
           wasShort = false;
      }
      
      if (short conditions)
      {
           EnterShort();
           wasShort = true;
      }
      Josh P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bsbisme, Yesterday, 02:08 PM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by prdecast, Today, 06:07 AM
      0 responses
      3 views
      0 likes
      Last Post prdecast  
      Started by i019945nj, 12-14-2023, 06:41 AM
      3 responses
      60 views
      0 likes
      Last Post i019945nj  
      Started by TraderBCL, Today, 04:38 AM
      2 responses
      18 views
      0 likes
      Last Post TraderBCL  
      Started by martin70, 03-24-2023, 04:58 AM
      14 responses
      106 views
      0 likes
      Last Post martin70  
      Working...
      X