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)
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.
Comment