Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reverse Logic (short) question

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

    Reverse Logic (short) question

    What is the code for the reverse logic of the EnterLong on this snippet of straetgy code taken from: http://www.ninjatrader-support.com/H...lPressure.html ------------------------------------------ protected override void OnBarUpdate() { // Looking for a long breakout signal if (Close[0] > DonchianChannel(20).Upper[5]) { // !! See notes below !! if (Historical || BuySellPressure().BuyPressure[0] > 70) EnterLong(); } } ------------------------------------------ How would it be coded to go short & cover a long position lets say and vise versa?

    #2
    Hello,

    This is basically the opposite of what you have below:

    if (Close[0] < DonchianChannel(20).Lower[5])
    {
    if (Historical || BuySellPressure().SellPressure[0] > 70)
    EnterShort();
    }

    Please note that BuySellPressure will only work in real-time operation and not in backtesting.
    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. I got that far. Let me correct my initial question. How is the code structured (nested, i think) so that it looks to see if the long condition exists first and go long (and/or cover a short), otherwise looks for the short condition and goes short (and/or to cover a long)

      Comment


        #4
        Hello,


        You are on the right track. Do something like this:


        if(....)
        EnterLong();
        else if(....)
        EnterShort();
        DenNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        47 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        15 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        21 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X