If I have a live strategy with stop orders, like the code below:
Code: Select all
if Time >=0901 and Time <=1601 then begin
buy 1 contract next bar at 2000 stop;
end;
Thank you so much for your help.
Code: Select all
if Time >=0901 and Time <=1601 then begin
buy 1 contract next bar at 2000 stop;
end;
Code: Select all
// Define input parameters for trading hours
Inputs:
startTradingTime(830), // Start trading at 08:30
endTradingTime(1600); // End trading at 16:00
// Variables to track trading status and previous date
Vars:
IntrabarPersist bool stopTrading(true),
IntrabarPersist int prevDate(0);
// New Trading Day Initialization
// Reset trading status at the start of a new day
If Date <> prevDate Then
Begin
stopTrading = true; // Assume stop trading at the start
prevDate = Date; // Update to the current date
End;
// Trading Hours Check
// Determine if current time is within specified trading hours
If Time >= startTradingTime and Time < endTradingTime Then
stopTrading = false // Enable trading
Else
stopTrading = true; // Disable trading outside hours
// --- Placeholders for Trading Logic ---
// Execute trading logic only during allowed hours
If not stopTrading Then
Begin
// Insert your trading logic here
End;
"if Time >=0901 and Time <=1601 then begin"The trading hours for the U.S. stock market are from Monday to Friday, 9:30 AM to 4:00 PM Eastern Time. However, in MultiCharts, when receiving data from Interactive Brokers, the trading hours are extended from 8:00 AM to 6:30 PM, including one and a half hours of pre-market and two and a half hours of after-hours trading.
If I have a live strategy with stop orders, like the code below:In this scenario, the stop orders might be triggered during the pre-market or after-hours sessions, which will result in entries being displayed on the chart. How can I ensure that the strategy does not execute during these periods? Can this only be achieved by modifying the exchange's trading start and end times in QuoteManager?Code: Select all
if Time >=0901 and Time <=1601 then begin buy 1 contract next bar at 2000 stop; end;
Thank you so much for your help.
Evaluation is per bar. So if the condition is not met for the current bar the action does not occur. It will cancel the order, if the order condition is not true. Another way to think about it is, every bar, the order conditions must be true otherwise the order is not submitted. Or another way, it is not like an order at IB where you set an order and it stays live until filled or canceled.Yes, this looks good. But the problem is: if you send an stop/limit order during the mainsession (0830 - 1600), the order is still placed and active at the broker in the after market session (1600 - 1800), if the order is not executed in the mainsession. How can we stop this active orders in the after market ... only manually? It should be a way to stop all orders after the mainsession automatically.