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

      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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          639 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          366 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          107 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          569 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          572 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X