Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about "Internal Order Handling Rules that Reduce Unwanted Positions"

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

    Question about "Internal Order Handling Rules that Reduce Unwanted Positions"

    Hello!

    Thank you ahead of time for looking at my question and answering it

    So the situation that I am in right now is that my strategy allows 1 entry per direction.

    So lets say i am hypothetically in a Long position

    I enter the position using the line:

    EnterLong(Convert.ToInt32(DefaultQuantity), "longEntry1");

    but before that line is called, I initialize a stop order:

    SetStopLoss(CalculationMode.Price, x);

    Now for some IF statement I want to get out of the position if it is true

    if (Statment){
    ExitLong();
    return;
    }


    By running this trough the strategy analyzer i get the "Internal Order Handling Rules that Reduce Unwanted Positions" error in console. Looking at the rules i am confused and wanted to clarify if it was because ​of this rule( I am assuming that it is)
    Click image for larger version

Name:	image.png
Views:	1038
Size:	34.9 KB
ID:	1219398
    QUESTIONS

    ​1.) Since I set a SetStopLoss() I'm assuming that the second rule is violated when I want to use ExsitLong() and that is why I'm getting the error?

    2.) How would I go about getting around this? Do I need to somehow cancel the existing stop order before calling ExitLong()​? Or is there some other way.


    TLDR: I have a long position, before I enter the position I make a stop loss using SetStopLoss() ​. BUT if some condition is true on BarUpdate() I want to get out of the position by calling ExitLong(). This violates the Internal Order Handling Rules​ and I am not sure how to get my logic across without violating the rules.

    I hope this is clear and what I'm describing is not confusing.

    #2
    Hi tchen7, thanks for posing. The way you can get around this is to use an Exit order instead of a Set order. e.g. ExitLongStopMarket(); would produce the same kind of order to exit the long position. Alternatively, you can call SetStopLoss() again at a different price to move the existing stop loss order to a new price.

    Kind regards,
    -ChrisL

    Comment


      #3
      so, this basically says that if you have `SetStopLoss/SetProfitTarget` methods used in your strategy, then you cant manually exit positions with `ExitLong/ExitShort` ? what a regress

      Comment


        #4
        Hello ttodua,

        This is not correct - Exitlong()/ExitShort() can be used while another order is working. If the Exit order closes the position, a stop loss or profit target from SetStopLoss() or SetProfitTarget() should automatically cancel.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        38 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 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