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:	373
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 pibrew, Today, 06:37 AM
    0 responses
    4 views
    0 likes
    Last Post pibrew
    by pibrew
     
    Started by rbeckmann05, Yesterday, 06:48 PM
    1 response
    14 views
    0 likes
    Last Post bltdavid  
    Started by llanqui, Today, 03:53 AM
    0 responses
    6 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    11 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    16 views
    0 likes
    Last Post AaronKoRn  
    Working...
    X