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

Quick question on this exit

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

    Quick question on this exit

    // Condition set 1
    if (Close[0] > CurrentDayOHL().CurrentOpen[0])
    {
    EnterLong(DefaultQuantity, "Long");
    }

    // Condition set 2
    if (Close[0] < CurrentDayOHL().CurrentOpen[0])
    {
    ExitLong();
    }
    // Condition 3
    if (High[0] >= CurrentDayOHL().CurrentOpen[0] + (CurrentDayOHL().CurrentOpen[0] * 0.05))
    {
    ExitLong();
    }

    conditions 1 and 2 work fine, condition 3 does not do anything. how do i calculate the target exit in this manner and have it execute? (closes the position if the current price is a 5% increase over the session open price)
    Thanks!

    #2
    How are you determining that condition 3 is not working? Your high price needs to be >= 105% of the day's open. Please ensure such a condition does in fact evaluate to true.

    Say your day open was 100. Then your high needs to be >= 105.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I'm running this strategy on FAS right now on my IB feed. The open was 2.53 and the high was 2.96. 2.53*1.05=2.65, or 2.53+(2.53*.05)=2.65 which should make condition 3 true either way i would assume, and should trigger the exit.

      condition 1 and 2 work just fine on multiple time frames, but it never exits at 2.65 or above.


      edit: it just exited before mkt close, so that part works too
      Last edited by tortexal; 03-09-2009, 02:00 PM.

      Comment


        #4
        tortexal,

        The only way you can test this is by actually printing values. Print out the value of High[0] as well as CurrentDayOHL().CurrentOpen[0] + (CurrentDayOHL().CurrentOpen[0] * 0.05). That is the only way you can follow the code.

        Code:
        Print(High[0] + " " + CurrentDayOHL().CurrentOpen[0] + (CurrentDayOHL().CurrentOpen[0] * 0.05));
        Also, if your second condition was already evaluated to true there would be no position to close for your third condition. Ensure there is actually an open position as condition three is true.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          haha awesome, thanks i'll give that a shot


          totally got it fixed, thanks again. i was doing this all types of screwy
          Last edited by tortexal; 03-09-2009, 06:46 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by lorem, 04-25-2024, 09:18 AM
          19 responses
          80 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by joselube001, 05-10-2024, 12:17 PM
          6 responses
          29 views
          0 likes
          Last Post joselube001  
          Started by bigc0220, 09-18-2018, 09:16 AM
          6 responses
          2,580 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by DawnTreader, 05-08-2024, 05:58 PM
          21 responses
          81 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by doihaveto13, Today, 12:46 PM
          2 responses
          8 views
          0 likes
          Last Post doihaveto13  
          Working...
          X