Code: Select all
SetProfitTarget(ProfitTargetAmount);
SetStopLoss(StopLossAmount);
SetExitOnClose();
If Time >= TimeToExit then begin
sell ( "EOD LX" ) this bar on close;
buytocover ( "EOD SX" ) this bar on close;
end;
This strategy normally works fine. However, I had a hiccup today when I lost Internet connectivity before 3:10 PM. Once the 3:10 PM bar rolled around, MultiCharts couldn't connect to my broker to close out the position. As a result, my position remained open after the session close and I had to close it manually.
Is there any way to avoid this in the future? I would like to transmit a time-delayed order to Interactive Brokers that says, in essence, "if this order remains open after 3:10 PM, then exit at market." MultiCharts could theoretically transmit this order to Interactive Brokers immediately after I opened the position, so that IB would execute the order at 3:10 PM even if I lost Internet access.
Is a "time delayed" order like this possible? Or are MultiCharts and IB limited to transmitting orders only for immediate execution? Is there any other way to avoid this problem?