• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.AvgPrice

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

    Position.AvgPrice

    I am trying to exit my position with the entry price value minus (some value)

    I am testing with this code but I cannot get it to work.


    if (Low[0] <= Position.AvgPrice - 5));
    {
    ExitLong(
    "Stopped Out", "");
    }

    When I print Position.AvgPrice to the output window the value is 0

    When I print Position.AvgPrice - 5 to the output window I get -5

    Thanks for any help

    #2
    I used the wizard to create the code copied and pasted it.

    I now get the proper values in the output window but it is still not triggering an exit

    if (Low[0] < Position.AvgPrice - 5)
    {
    ExitLong(
    "Exit Long Pos", "");
    }

    Comment


      #3
      delta20, sounds like you're not in a position for the strategy when you're trying to trigger it? Please add a check in for not being flat with your Position.MarketPosition
      BertrandNinjaTrader Customer Service

      Comment


        #4
        I am still having the same issue.

        I know I am in a position because it goes all the way to exit on close which is past the
        Position.AvgPrice-5

        Is this code correct for filtering?
        //Check if open position
        if (Position.AvgPrice == Null || Position.AvgPrice = 0)
        return;


        // Condition set 3
        if (Low[0] < Postion.AvgPrice - 5);
        {
        ExitLong(
        "", "Exit Open Price");
        }

        Thanks

        Comment


          #5
          Originally posted by delta20 View Post
          I am still having the same issue.

          I know I am in a position because it goes all the way to exit on close which is past the
          Position.AvgPrice-5

          Is this code correct for filtering?
          //Check if open position
          if (Position.AvgPrice == Null || Position.AvgPrice = 0)
          return;


          // Condition set 3
          if (Low[0] < Postion.AvgPrice - 5);
          {
          ExitLong(
          "", "Exit Open Price");
          }

          Thanks
          Then you need to check if your condition is actually ever true.
          Does price ever retrace enough so that Low[0] is below the average entry price minus 5?
          Is COBC true or false?
          On what instrument are you running the code?
          On what timeframe?

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sgiyrtv, Today, 06:36 AM
          0 responses
          4 views
          0 likes
          Last Post sgiyrtv
          by sgiyrtv
           
          Started by dastaan, Today, 06:29 AM
          0 responses
          6 views
          0 likes
          Last Post dastaan
          by dastaan
           
          Started by juanram, Today, 06:01 AM
          0 responses
          7 views
          0 likes
          Last Post juanram
          by juanram
           
          Started by random9570, Yesterday, 09:01 PM
          2 responses
          19 views
          0 likes
          Last Post Emma1
          by Emma1
           
          Started by SDaCosta30, Today, 04:19 AM
          0 responses
          8 views
          0 likes
          Last Post SDaCosta30  
          Working...
          X