I am looking at turning points: i.e.:
if (MyInd[0] > MyInd[1] && MyInd[1] <= MyInd[2])
EnterLongLimit(100,Close[0]-10*TickSize);
if (MyInd[0] < MyInd[1] && MyInd[1] >= MyInd[2])
EnterShortLimit(100,Close[0]+10*TickSize);
SetTrailStop(CalculationMode.Percent,0.05);
My strategy executes on 30-min bar closes.
Sequence:
9:30 MyInd = 142.31
10:00 MyInd = 142.30 result: 10:00:01 enters short limit that executes that second!
10:30 MyInd = 142.34 result: should enter limit order to go long, but NOTHING HAPPENS!
11:00 MyInd = 142.40
Price definitely went well through where the limit order should have been entered on the next bar.
So, now I am short 100 shares of this stock when I should be long, and what should be a winning day becomes a losing one.
What happened?
1. The trace and log show that the trailing stop was updated on the 10:30 bar (they are never updated in real-time, contrary to the documentation).
2. No evidence of an EnterLongLimit order exists in either trace or log!
Net result: I lose real money.
How do I avoid this? I will implement whatever programming I have to in order to fix this logic - I am an expert programmer - but it is unclear from the documentation why this should have failed.
Please answer the following:
1. Does the existence of a stoploss order break any strategy with limit orders that trade both directions?
2. If I modify the code to the following should it absolutely fix this?
if (MyInd[0] > MyInd[1] && MyInd[1] <= MyInd[2])
{
if (Position.MarketPosition == MarketPosition.Short)
{
ExitShort();
}
EnterLongLimit(100,Close[0]-10*TickSize);
}
I should do this anyway to ensure an exit, but will it also place the long limit entry order?
Comment