SquareRoot wrote:
if (order.isLong()){
.....
}
Thanks, this is not what I want, position and order are different.
For example, my last order is a SellStop order for 10000 unit EURUSD, before this order executed, the original position is 20000 unit EURUSD long. After the SellStop order has been executed, the total position is long EURUSD 10000 unit. Then I'm not sure what is the result of order.islong().
By the way, I found out that if I simply use SellStop and BuyStop order to close and reverse a position, it only works once at the beginning of strategy execution.
I feel that I have to make this position class by myself, but then I have to know how the strategy is evaluated on each bar/tick, and what kind of index each bar/tick has...