• 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

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Grantx, Today, 08:22 AM
    0 responses
    5 views
    0 likes
    Last Post Grantx
    by Grantx
     
    Started by Swing123, Today, 08:21 AM
    2 responses
    5 views
    0 likes
    Last Post Swing123  
    Started by lunardiplomacy, Today, 07:57 AM
    0 responses
    3 views
    0 likes
    Last Post lunardiplomacy  
    Started by Tagliareni, Yesterday, 08:10 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by SDaCosta30, Today, 04:19 AM
    2 responses
    14 views
    0 likes
    Last Post SDaCosta30  
    Working...
    X