Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Stop at Each Percentage of Open Profit

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

    Setting Stop at Each Percentage of Open Profit

    Hi I am trying to just set a simple profit stop after I have 2% of open profit in a position. The following code works fine for when I have 1% open profit but if I change it to anything over 1% it doesn't work.


    if ((InLong == true)
    && (High[0] > (Position.AveragePrice * 1.01) ))
    {
    ExitLongStopMarket(Convert.ToInt32(DefaultQuantity ), (Position.AveragePrice * 1.0075) , @"1%ProfitProtect", "");
    }



    This doesn't work:


    if ((InLong == true)
    && (High[0] > (Position.AveragePrice * 1.02) ))
    {
    ExitLongStopMarket(Convert.ToInt32(DefaultQuantity ), (Position.AveragePrice * 1.0075) , @"2%ProfitProtect", "");
    }


    Thanks

    #2
    Hello prescottbph,

    Thank you for the post.

    I wanted to check, are you currently using Prints or any other type of way to see the value you are calculating?

    Nothing looks out of place in what you provided, however, the value you are calculating may be the problem. Have you tried using a Print like the following before the condition to see what values it is reporting?

    Code:
    Print("InLong: " + InLong + " High[0]: " + High[0] + " Position.AveragePrice * 1.02: " + (Position.AveragePrice * 1.02));
    
    if ((InLong == true) && (High[0] > (Position.AveragePrice * 1.01) ))
    This would likely be the easiest way to see what is happening here.



    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X