So for now I've overrided OnOrderUpdate, which provides me with averageFillPrice, and the method I used was as follows:
in onOrderUpdate:
if (orderState == OrderState.Filled) {
entry_price = averageFillPrice;
}
So in onBarUpdate, I had put something like:
takeLong();
setProfitTarget(entry_price + 4);
setStopLoss(entry_price - 4);
From this I notice one issue and I have one question as well.
When I call the function to take the long, will that function complete, then call onOrderUpdate, and THEN call setProfitTarget? It seems that when my code is executed, the entry_price variable is not updated to the most recent price. Instead, it uses the previous trade's prices. And if I put setProfitTarget above takeLong, the orderState won't be filled, and so that doesn't work either. I'm sure there's an easier way to do this, so if someone knows it I'd appreciate the help!
Thanks!
Comment