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 pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      148 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,283 views
      0 likes
      Last Post Leafcutter  
      Working...
      X