1) run the following ode, wait long enough to let EnterLongLimit() bought 100 shares of stock IBM.
2) stop Strategy, and restart Strategy
3) ExitLong() doesn't work.
Can you help to point out what I may have done wrong? Thanks.
need_flat = first_time = true; // initial value
protected override void OnBarUpdate()
{
if (need_flat)
{
Order myExit = ExitLong(); // being called once, 1st time to run Strategy doesn't do anything. I expect it do the job during the 2nd time to run
Print (" After () = = " + myExit); // it prints nothing for myExit after re-start Strategy.
need_flat = false;
}
if (first_time)
{
myEntry = EnterLongLimit(0, true, 100, GetCurrentBid() - 0.02, "MyBUY"); // this is called only once, wait until it is executed, so there are 100 bought IBM stocks in account.
first_time = false;
need_flat = false;
}
}
Comment