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

making progress, but still need help

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

    making progress, but still need help

    I've been troubleshooting this program for 2 weeks now. I have it narrowed down quite a bit and have new information.

    Basically, my strategy always enters a position, and it never exits using my ExitLongStop or ExitShortStop commands. It only reverses positions when a EnterShortStop is triggered. I just realized this after major debugging and printing.

    Here is the portion of my code with this logic. I'm assuming there is some fundamental thing that I'm missing. I hope someone can help.

    if ( movAvgVal[0] > movAvgVal[1] )
    {
    EnterLongStop(upBand, "Long Buy");
    }

    else if ( movAvgVal[0] < movAvgVal[1])
    {
    EnterShortStop(dnBand, "Short Buy");
    }


    if ((Position.MarketPosition == MarketPosition.Long))
    {
    ExitLongStop(movAvgVal2[0], "Long Exit");
    }


    else if ((Position.MarketPosition == MarketPosition.Short))
    {
    ExitShortStop(movAvgVal2[0], "Buy to Cover");
    }
    }


    The code will not run my ExitLongStop or ExitShortStop commands. If I change them to ExitLong() and ExitShort(), it will execute them, but it messes up the logic and testing. I need them to be stops.

    Please help, I'm been at this non stop for 2 weeks.

    #2

    ExitLongStop(double stopPrice, string fromEntrySignal)

    Your code: ExitLongStop(movAvgVal2[0], "Long Exit");

    Where do you have an entry signal "Long Exit"?

    Comment


      #3
      NinjaTrader Dierk,

      You are a genius! Thanks so much. I think this fixed it! I need to do more testing in the morning. I assumed that the parameters would be similar for EnterLongStop() and ExitLongStop.


      Thanks again!



      Originally posted by NinjaTrader_Dierk View Post
      http://www.ninjatrader-support.com/H...tLongStop.html
      ExitLongStop(double stopPrice, string fromEntrySignal)

      Your code: ExitLongStop(movAvgVal2[0], "Long Exit");

      Where do you have an entry signal "Long Exit"?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      57 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      35 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      19 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      9 views
      0 likes
      Last Post cre8able  
      Working...
      X