Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	369
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
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rhyminkevin, Today, 04:58 PM
    3 responses
    48 views
    0 likes
    Last Post Anfedport  
    Started by iceman2018, Today, 05:07 PM
    0 responses
    5 views
    0 likes
    Last Post iceman2018  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    7 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    14 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    50 views
    0 likes
    Last Post futtrader  
    Working...
    X