OnBarUpdate()
{
if (condition)
GoLong();
}
GoLong()
{
SetStopLoss("Long1", CalculationMode.Price, (Position.AvgPrice - myVar), false);
SetProfitTarget("Long1", CalculationMode.Price, myVar2);
EnterLong(DefaultQuantity, "Long1");
}
Now, on the surface this looks fine to me, but it wasn't giving the expected results.
I stuck a ton of print statements in there, and everything is fine except Position.AvgPrice is coming back 0 at every step. The print function was called from GoLong(). As a result, none of the stops are being set correctly. Is it a problem of the ordering I'm calling things here? Thanks guys.
*edited to add this is for an FX trade, maybe that has something to do with it

Comment