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 Max238, Today, 01:28 AM
      5 responses
      42 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by giulyko00, Yesterday, 12:03 PM
      3 responses
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by habeebft, Today, 07:27 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_ChristopherS  
      Started by AveryFlynn, Today, 04:57 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by r68cervera, Today, 05:29 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X