PureBytes Links
Trading Reference Links
|
Hello List,
I would appreciate some coding help if anyone can spot what is wrong
with the stop loss code below.
The system trades on 5 minute bars and can enter 1 contract at 1pm and
under certain coditions, a second contract at 2pm.
The system is supposed to exit a 1 contract short position at
breakeven-MinPftPts once adJstp level of profit is reached and the market then
moves against the profit.
If the system has 2 contracts short it is supposed to exit both
positions at their respective entryprices-MinPftPts if the combined
trade highest profits have been greater than 2*adjStp.
What is happening is the system is exiting both short positions when the
combined loss is greater than adjStp but has never reached 2*adjStp.
The first stop statement is closing both positions at 2:05
when it shouldn't even be working because there are two contracts
open. Is there something wrong with my usage of "CurrentContracts"?
If Marketposition = -1 and CurrentContracts = 1 then begin
If MaxPositionProfit >= adJStp Then begin
ExitShort("SBEStp1") at EntryPrice-MinPftPTs stop;
End;
End;
If Marketposition = -1 and CurrentContracts = 2 then begin
If MaxPositionProfit >= adJStp*2 Then begin
ExitShort("SBEStp1+") 1 contract at EntryPrice(1)-MinPftPTs stop;
ExitShort("SBEStp2") 1 contract at EntryPrice(0)-MinPftPTs stop;
End;
End;
--Thanks in advance
Best regards,
Roger mailto:mailrs@xxxxxxxxxx
|