• 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 chrismcdermut, Yesterday, 01:46 PM
    3 responses
    19 views
    0 likes
    Last Post MojoJojo  
    Started by Bricolico, Yesterday, 09:28 PM
    0 responses
    5 views
    0 likes
    Last Post Bricolico  
    Started by Tradwell385, Yesterday, 08:51 PM
    0 responses
    7 views
    0 likes
    Last Post Tradwell385  
    Started by dvcpro4, Yesterday, 07:08 PM
    0 responses
    22 views
    0 likes
    Last Post dvcpro4
    by dvcpro4
     
    Started by pennywise, Yesterday, 06:40 PM
    0 responses
    8 views
    0 likes
    Last Post pennywise  
    Working...
    X