I create the following code (see below), but my stop loss doesnt seem to work at some instances (both for the "stop l" and the "Stop&rev 1". Any idea why?
Thanks!
Can you help answer these questions from other members on futures io?
Normally Houston TX but currently travelling a lot
Experience: Advanced
Platform: TT and Stellar
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Posts: 4,747 since Dec 2013
Thanks: 4,063 given,
9,563
received
Not an expert, but I will point out that Tradestation runs code at the end of the bar, for action on the next bar. Since your stops are dependent upon you having a position (you use marketposition to check this) the bar that you enter your position, you will have no stop for that bar as marketposition was different at end of the previous bar. You can get around this by creating your own tracker variable to monitor your position and when you create a new order, update the variable.
ie
The following 2 users say Thank You to SMCJB for this post:
It's possible the Entryprice(1) is the culprit. Entryprice(0) is your current position entry. Entryprice(1) is your previous position. Looks like most of the logic is expecting more than one bar to hit stops or targets so you may not need intrabar order generation but that may be a good thing to check if you are expecting some fills in the same bar. I can see that being detrimental to this strategy though.
The following user says Thank You to ShadowFox for this post: