- ago
I would like to simulate auto-trading on multiple strategies running simultaneously. Is there a method to do that in WL 8?
0
835
Solved
54 Replies

Closed

Bookmark

Sort
Cone8
 ( 24.10% )
- ago
#1
You don't have to simulate it. You can actually Auto-Trade multiple strategies simultaneously using the Strategy Monitor.

But if you really mean "simulate", to run a single backtest of multiple strategies, see Strategy > MetaStrategy in the Help guide (F1).

If using multiple markets with different quote currencies, see Preferences > Backtest > Other Settings > Multi-Currency

Here's a MetaStrategy on different markets -
0
- ago
#2
Thanks, Cone, this is exactly what I was looking for!
1
- ago
#3
Follow-up question. I set up the strategy monitor with a number of strategies, and I activated them and turned on auto-place for each one. One of the strategies was triggered outside the SM, but it's not firing inside it.

What am I missing?

0
Cone8
 ( 24.10% )
- ago
#4
Was it an exit order or entry order?
Did you enable "Use Live Positions" in the Trading Preferences?

Or, maybe it's because it didn't run for today and scheduled the Next Run for tomorrow.
0
- ago
#5
Here's what I'm seeing:



0
- ago
#6
And yes, I have "Use Live Positions" selected
0
Cone8
 ( 24.10% )
- ago
#7
Oh gosh. There's a bug with 60 minute bars polling.

I can't tell if you're using polling, but the bug will prevent all signals in the U.S. market except for the 4pm bar.

Until we can get that polling bug fixed, please use Streaming Bars instead and it will be fine.
2
- ago
#8
I believe I'm using the default, which is Steaming Bars
0
- ago
#9
0
Cone8
 ( 24.10% )
- ago
#10
First thing. I can't tell what's happening there, but there are some things that I'd be doing differently.

Do not load 25 years of data for a 60-minute strategy to trade something "today". This will just cause large delays due to unnecessarily processing a large backtest.

Use Live Positions will probably ease that somewhat, but the idea would be to load what you need to make your indicators valid and a little more so that the last position entry is guaranteed to appear. It's hard to imagine that more than a few months would be required unless you´re scaling to a higher timeframe for something like a 200-day moving average (and even then there's a better way to access that data).

I'm also at a loss to understand why it appears you created DataSets for one symbol. If that's the case, why? You can do that, but to run a strategy on just one symbol, click "Symbol" in the configuration and type in the Symbol to use.

If you can post one or your strategies that isn't working right, we can take a look at it tomorrow and get to the bottom of this.
1
- ago
#11
Thanks, Cone. I'll make the adjustments you suggested on the timeframe/data amount this evening. I set up the different data sets based on some previous issues that I had (my understanding issues, not the program) and so it's legacy that I won't use going forward.

Maybe we can spend a few minutes together in a consulting engagement to walk through what I'm doing and see where the gaps may be. I'm free most of this week if you have time.
0
- ago
#12
Here's the strategy. It seems to work fine in the backtest mode and if I drag it onto a chart. It fired yesterday at 10:30am when I ran the model separately but the signal didn't show up on the strategy monitor
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript1 { public class MyStrategy : UserStrategyBase {     public MyStrategy() : base() {          AddParameter("SL Long 1", ParameterType.Double, 9, 1, 10, 1);          AddParameter("Long Entry 1 Std Dev Period", ParameterType.Int32, 6, 1, 100, 1);          AddParameter("Long Entry 2 Std Dev Period", ParameterType.Int32, 30, 1, 100, 1);          AddParameter("SL Long 2", ParameterType.Double, 10, 1, 10, 1);          AddParameter("Long Close at Market Period", ParameterType.Int32, 9, 1, 100, 1);          AddParameter("Short Entry 1 Std Dev Period", ParameterType.Int32, 49, 1, 100, 1);          AddParameter("How many Bars ago - Short", ParameterType.Int32, 3, 1, 20, 1);          AddParameter("Short Entry 2 Std Dev Period", ParameterType.Int32, 74, 1, 100, 1);          AddParameter("How many Bars ago - Short 2", ParameterType.Int32, 20, 1, 20, 1);          AddParameter("Short SL Cover", ParameterType.Double, 4, 1, 10, 1);          AddParameter("Short Close at Market Period", ParameterType.Int32, 15, 1, 100, 1); StartIndex = 74; } public override void Initialize(BarHistory bars) {          indicator1 = bars.Close;          indicator2 = new BBLower(bars.Close,9,9.00);          PlotIndicator(indicator2,new WLColor(0,0,0));          _startIndexList.Add(indicator2);          trailing = false;          PlotStopsAndLimits(3);          indicator12 = bars.Close;          indicator22 = new BBUpper(bars.Close,68,3.00);          PlotIndicator(indicator22,new WLColor(0,0,255));          _startIndexList.Add(indicator22);          indicator13 = bars.Close;          indicator23 = new BBLower(bars.Close,Parameters[1].AsInt,1.00);          PlotIndicator(indicator23,new WLColor(255,0,0));          _startIndexList.Add(indicator23);          trailing2 = false;          PlotStopsAndLimits(3);          indicator14 = bars.Close;          indicator24 = new BBUpper(bars.Close,Parameters[4].AsInt,2.00);          PlotIndicator(indicator24,new WLColor(0,128,0));          _startIndexList.Add(indicator24);          indicator15 = bars.Close;          indicator25 = new BBLower(bars.Close,Parameters[2].AsInt,2.00);          PlotIndicator(indicator25,new WLColor(255,165,0));          _startIndexList.Add(indicator25);          trailing3 = false;          PlotStopsAndLimits(3);          indicator16 = bars.Close;          indicator26 = new BBUpper(bars.Close,Parameters[4].AsInt,2.00);          _startIndexList.Add(indicator26);          indicator17 = bars.Close;          indicator27 = new BBUpper(bars.Close,Parameters[5].AsInt,1.00);          PlotIndicator(indicator27,new WLColor(128,128,0));          _startIndexList.Add(indicator27);          indicator18 = bars.Close;          indicator28 = bars.Close;          trailing4 = false;          PlotStopsAndLimits(3);          indicator19 = bars.Close;          indicator29 = new BBLower(bars.Close,Parameters[10].AsInt,2.00);          PlotIndicator(indicator29,new WLColor(128,0,128));          _startIndexList.Add(indicator29);          indicator110 = bars.Close;          indicator210 = new BBUpper(bars.Close,Parameters[7].AsInt,2.00);          PlotIndicator(indicator210,new WLColor(0,255,255));          _startIndexList.Add(indicator210);          indicator111 = bars.Close;          indicator211 = bars.Close;          trailing5 = false;          PlotStopsAndLimits(3);          indicator112 = bars.Close;          indicator212 = new BBLower(bars.Close,Parameters[10].AsInt,2.00);          _startIndexList.Add(indicator212); foreach(IndicatorBase ib in _startIndexList) if (ib.FirstValidIndex > StartIndex) StartIndex = ib.FirstValidIndex; } public override void Execute(BarHistory bars, int idx) {          int index = idx;          Position foundPosition0 = FindOpenPosition(0);          bool condition0;          if (foundPosition0 == null)          {             condition0 = false;             {                if (indicator1.CrossesOver(indicator2, index))                {                   condition0 = true;                }             }             if (condition0)             {                _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose, 0, 0, "Buy At Close (1)");             }          }          else          {             condition0 = false;             {                condition0 = true;             }             if (condition0)             {                Backtester.CancelationCode = 563;                value = 1.0 - (Parameters[0].AsDouble / 100.0);                ClosePosition(foundPosition0, OrderType.Stop, foundPosition0.EntryPrice * value, "Sell at 9% stop loss");             }             condition0 = false;             {                if (indicator12.CrossesUnder(indicator22, index))                {                   condition0 = true;                }             }             if (condition0)             {                Backtester.CancelationCode = 563;                ClosePosition(foundPosition0, OrderType.MarketClose, 0, "Sell At Close (1)");             }          }          Position foundPosition1 = FindOpenPosition(1);          bool condition1;          if (foundPosition1 == null)          {             condition1 = false;             {                if (indicator13.CrossesOver(indicator23, index))                {                   condition1 = true;                }             }             if (condition1)             {                _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose, 0, 1, "Buy At Close (2)");             }          }          else          {             condition1 = false;             {                condition1 = true;             }             if (condition1)             {                Backtester.CancelationCode = 566;                value2 = 1.0 - (Parameters[3].AsDouble / 100.0);                ClosePosition(foundPosition1, OrderType.Stop, foundPosition1.EntryPrice * value2, "Sell at 10% stop loss");             }             condition1 = false;             {                if (indicator14.CrossesUnder(indicator24, index))                {                   condition1 = true;                }             }             if (condition1)             {                Backtester.CancelationCode = 566;                ClosePosition(foundPosition1, OrderType.MarketClose, 0, "Sell At Close (2)");             }          }          Position foundPosition2 = FindOpenPosition(2);          bool condition2;          if (foundPosition2 == null)          {             condition2 = false;             {                if (indicator15.CrossesOver(indicator25, index))                {                   condition2 = true;                }             }             if (condition2)             {                _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose, 0, 2, "Buy At Close (3)");             }          }          else          {             condition2 = false;             {                condition2 = true;             }             if (condition2)             {                Backtester.CancelationCode = 567;                value3 = 1.0 - (Parameters[3].AsDouble / 100.0);                ClosePosition(foundPosition2, OrderType.Stop, foundPosition2.EntryPrice * value3, "Sell at 10% stop loss");             }             condition2 = false;             {                if (indicator16.CrossesUnder(indicator26, index))                {                   condition2 = true;                }             }             if (condition2)             {                Backtester.CancelationCode = 567;                ClosePosition(foundPosition2, OrderType.MarketClose, 0, "Sell At Close (3)");             }          }          Position foundPosition3 = FindOpenPosition(3);          bool condition3;          if (foundPosition3 == null)          {             condition3 = false;             {                count = 0;                if (indicator17.CrossesUnder(indicator27, index))                {                   count++;                }                if (index - Parameters[6].AsInt >= 0 && indicator18[index] < indicator28[index - Parameters[6].AsInt])                {                   count++;                }                if (count >= 2)                {                   condition3 = true;                }             }             if (condition3)             {                _transaction = PlaceTrade(bars, TransactionType.Short, OrderType.MarketClose, 0, 3, "Short At Close (4)");             }          }          else          {             condition3 = false;             {                condition3 = true;             }             if (condition3)             {                Backtester.CancelationCode = 570;                value4 = 1.0 + (Parameters[9].AsDouble / 100.0);                ClosePosition(foundPosition3, OrderType.Stop, foundPosition3.EntryPrice * value4, "Cover at 4% stop loss");             }             condition3 = false;             {                if (indicator19.CrossesOver(indicator29, index))                {                   condition3 = true;                }             }             if (condition3)             {                Backtester.CancelationCode = 570;                ClosePosition(foundPosition3, OrderType.Market, 0, "Cover At Market (4)");             }          }          Position foundPosition4 = FindOpenPosition(4);          bool condition4;          if (foundPosition4 == null)          {             condition4 = false;             {                count2 = 0;                if (indicator110.CrossesUnder(indicator210, index))                {                   count2++;                }                if (index - Parameters[8].AsInt >= 0 && indicator111[index] < indicator211[index - Parameters[8].AsInt])                {                   count2++;                }                if (count2 >= 2)                {                   condition4 = true;                }             }             if (condition4)             {                _transaction = PlaceTrade(bars, TransactionType.Short, OrderType.MarketClose, 0, 4, "Short At Close (5)");             }          }          else          {             condition4 = false;             {                condition4 = true;             }             if (condition4)             {                Backtester.CancelationCode = 571;                value5 = 1.0 + (Parameters[9].AsDouble / 100.0);                ClosePosition(foundPosition4, OrderType.Stop, foundPosition4.EntryPrice * value5, "Cover at 4% stop loss");             }             condition4 = false;             {                if (indicator112.CrossesOver(indicator212, index))                {                   condition4 = true;                }             }             if (condition4)             {                Backtester.CancelationCode = 571;                ClosePosition(foundPosition4, OrderType.Market, 0, "Cover At Market (5)");             }          } } public override void NewWFOInterval(BarHistory bars) {          indicator1 = bars.Close;          indicator2 = new BBLower(bars.Close,9,9.00);          indicator12 = bars.Close;          indicator22 = new BBUpper(bars.Close,68,3.00);          indicator13 = bars.Close;          indicator23 = new BBLower(bars.Close,Parameters[1].AsInt,1.00);          indicator14 = bars.Close;          indicator24 = new BBUpper(bars.Close,Parameters[4].AsInt,2.00);          indicator15 = bars.Close;          indicator25 = new BBLower(bars.Close,Parameters[2].AsInt,2.00);          indicator14 = bars.Close;          indicator24 = new BBUpper(bars.Close,Parameters[4].AsInt,2.00);          indicator16 = bars.Close;          indicator26 = new BBUpper(bars.Close,Parameters[4].AsInt,2.00);          indicator19 = bars.Close;          indicator29 = new BBLower(bars.Close,Parameters[10].AsInt,2.00);          indicator19 = bars.Close;          indicator29 = new BBLower(bars.Close,Parameters[10].AsInt,2.00);          indicator112 = bars.Close;          indicator212 = new BBLower(bars.Close,Parameters[10].AsInt,2.00); }       private TimeSeries indicator1;       private IndicatorBase indicator2;       private double value;       private bool trailing;       private TimeSeries indicator12;       private IndicatorBase indicator22;       private TimeSeries indicator13;       private IndicatorBase indicator23;       private double value2;       private bool trailing2;       private TimeSeries indicator14;       private IndicatorBase indicator24;       private TimeSeries indicator15;       private IndicatorBase indicator25;       private double value3;       private bool trailing3;       private TimeSeries indicator16;       private IndicatorBase indicator26;       private int count;       private bool mc;       private TimeSeries indicator17;       private IndicatorBase indicator27;       private TimeSeries indicator18;       private TimeSeries indicator28;       private double value4;       private bool trailing4;       private TimeSeries indicator19;       private IndicatorBase indicator29;       private int count2;       private bool mc2;       private TimeSeries indicator110;       private IndicatorBase indicator210;       private TimeSeries indicator111;       private TimeSeries indicator211;       private double value5;       private bool trailing5;       private TimeSeries indicator112;       private IndicatorBase indicator212;       private Transaction _transaction; private List<IndicatorBase> _startIndexList = new List<IndicatorBase>(); } }
0
Cone8
 ( 24.10% )
- ago
#13
Which symbol(s)?
0
Cone8
 ( 24.10% )
- ago
#14
This script has issues.
I looked at ABG and this is what I see:



You have multiple "strategies" that are not mutually exclusive and allows long and short positions simultaneously. While that will work in a backtest, it probably won't work with live trading, but could depend on the broker.

Next, the trade at 10:30 is not signaled at 10:30 - it signaled at 4pm the day before. The dots show the bar on which the order is active, but they are signaled at the end of the previous bar.

The stop occurred between 09:30 and 10:30, so the order already needs to be in the market. Probably your 4pm orders are being canceled by the broker because "the market is closed", but these orders need to be "live" for the next session.

Which broker are you using?
0
- ago
#15
Right now I'm testing using the dummy broker. The symbol i was using was AAON.

I could use some help tightening the models up. Can I set up some time with you?
0
Cone8
 ( 24.10% )
- ago
#16
We'll have to shoot for the end of next week. I'm booked (and traveling) until Thursday, 20 July. If you want to, send us a Concierge Request (https://www.wealth-lab.com/Support/Concierge). Glitch is in Egypt, but he still might be able to pick it up before me.
0
- ago
#17
Will do, thanks. Safe travels
0
Cone8
 ( 24.10% )
- ago
#18
The dummy broker won't cancel those 4pm orders, but you'd probably have to leave WealthLab running overnight and into the next session for the orders to execute.

You can also check the S. Monitor for Signals when you turn it on in the morning. If there are Signals (Alerts), there should be working orders for them.
0
- ago
#19
Could you try to run the model with AAON and see if you get some different results? I'm curious to see if you get a different signal for a purchase on the 10th and see what happens.

Ultimately my problem is that the signals that are triggered are not showing up on SM right now, so either they aren't running the same under SM or there's some other issue.
0
Cone8
 ( 24.10% )
- ago
#20
Click on your AAON strategy item and copy the end of Log on the right. Just 10 or 20 lines is enough.. Please paste here.

Probably there's more of a problem with 60 minute bars than even I thought. It's all to do with WealthLab's convention to process the full bar interval from the market open, i.e., 10:30, 11:30, .. instead of like every other app in the world - 10:00, 11:00, etc.
0
- ago
#21
7/10/2023 19:57:50: Status = LoadingData
7/10/2023 19:57:50: Starting Streaming Bars Thread
7/10/2023 19:57:50: Populating Data
7/10/2023 19:57:50: Calling GetHistories Pass 1
7/10/2023 19:57:50: GetHistories returned with 1 symbols
7/10/2023 19:57:50: Calling GetHistories Pass 2
7/10/2023 19:57:50: GetHistories returned with 1 symbols
7/10/2023 19:57:50: AAON:858 bars to 20230710 1600|IQFeed
7/10/2023 19:57:50: NextRun set to 7/11/2023 10:30
7/10/2023 19:57:50: Status = Idle
7/11/2023 10:26:24: Status = Deactivated
7/11/2023 10:26:24: Leaving Streaming Bars Thread
7/11/2023 10:26:25: Status = LoadingData
7/11/2023 10:26:25: Starting Streaming Bars Thread
7/11/2023 10:26:25: Populating Data
7/11/2023 10:26:25: Calling GetHistories Pass 1
7/11/2023 10:26:33: GetHistories returned with 1 symbols
7/11/2023 10:26:33: Calling GetHistories Pass 2
7/11/2023 10:26:33: GetHistories returned with 1 symbols
7/11/2023 10:26:33: AAON:857 bars to 20230710 1600|IQFeed
7/11/2023 10:26:33: NextRun set to 7/11/2023 10:30
7/11/2023 10:26:33: Status = Idle
7/11/2023 10:30:00: Status = Processing
7/11/2023 10:30:40: NextRun set to 7/11/2023 11:30
7/11/2023 10:30:40: Status = Incomplete
7/11/2023 10:30:40: No Updates for 1 Symbol: AAON
7/11/2023 11:30:00: Status = Processing
7/11/2023 11:30:40: NextRun set to 7/11/2023 12:30
7/11/2023 11:30:40: Status = Incomplete
7/11/2023 11:30:40: No Updates for 1 Symbol: AAON
7/11/2023 12:30:00: Status = Processing
7/11/2023 12:30:40: NextRun set to 7/11/2023 13:30
7/11/2023 12:30:40: Status = Incomplete
7/11/2023 12:30:40: No Updates for 1 Symbol: AAON
7/11/2023 13:35:03: Status = Processing
7/11/2023 13:35:03: NextRun set to 7/11/2023 14:30
7/11/2023 13:35:03: Status = Incomplete
7/11/2023 13:35:03: No Updates for 1 Symbol: AAON
7/11/2023 14:30:00: Status = Processing
7/11/2023 14:30:40: NextRun set to 7/11/2023 15:30
7/11/2023 14:30:40: Status = Incomplete
7/11/2023 14:30:40: No Updates for 1 Symbol: AAON

0
- ago
#22
thanks
0
Cone8
 ( 24.10% )
- ago
#23
This is what I suspected: "No Updates for 1 Symbol: AAON"

What's happening is that the timestamp of the bar isn't matching the interval.

I was able to run off a quick test - and guess what? Polling actually works correctly for IQFeed. I verified the bars too. (The run times are in my GMT timezone.)

Switch to polling! (and we'll work on the 60-minute bars for Streaming Bars).
Note! "Filter Pre/Post" must be checked.

1
- ago
#25
Excellent! Thanks I'll give it a try.

Appreciate all the help
1
- ago
#26
Ok, next challenge. A signal was generated to buy at the market close, and I have Auto-Place selected, but I don't see the order showing up in the Dummy account.

Here's the log:

7/12/2023 10:30:00: Pass 1 - Requesting updates for 1 symbols...
7/12/2023 10:30:00: Leaving Polling Thread
7/12/2023 10:30:00: Leaving Polling Thread
7/12/2023 10:30:01: Pass 1 - UpdateHistories returned 1 symbols
7/12/2023 10:30:02: Ran Strategy on TEAM: 0 Signals, Run Time=1.46sec
7/12/2023 10:30:02: NextRun set to 7/12/2023 11:30
7/12/2023 10:30:02: Status = Completed
7/12/2023 10:30:02: Processed all Symbols
7/12/2023 11:30:01: Status = Processing
7/12/2023 11:30:01: Pass 1 - Requesting updates for 1 symbols...
7/12/2023 11:30:02: Pass 1 - UpdateHistories returned 1 symbols
7/12/2023 11:30:02: Ran Strategy on TEAM: 0 Signals, Run Time=478ms
7/12/2023 11:30:02: NextRun set to 7/12/2023 12:30
7/12/2023 11:30:02: Status = Completed
7/12/2023 11:30:02: Processed all Symbols
7/12/2023 12:30:01: Status = Processing
7/12/2023 12:30:01: Pass 1 - Requesting updates for 1 symbols...
7/12/2023 12:30:01: Pass 1 - UpdateHistories returned 1 symbols
7/12/2023 12:30:02: Ran Strategy on TEAM: 1 Signals, Run Time=702ms

7/12/2023 12:30:02: NextRun set to 7/12/2023 13:30
7/12/2023 12:30:02: Status = Completed
7/12/2023 12:30:02: Processed all Symbols
7/12/2023 14:31:24: Status = Processing
7/12/2023 14:31:24: Pass 1 - Requesting updates for 1 symbols...
7/12/2023 14:31:25: Pass 1 - UpdateHistories returned 1 symbols
7/12/2023 14:31:26: Ran Strategy on TEAM: 0 Signals, Run Time=439ms
7/12/2023 14:31:26: NextRun set to 7/12/2023 15:30
7/12/2023 14:31:26: Status = Completed
7/12/2023 14:31:26: Processed all Symbols
0
- ago
#27
0
Cone8
 ( 24.10% )
- ago
#28
It's not a position yet so it won't be in the account.
Look in the Order Manager.
0
- ago
#29
The model trades on the hourly close so I wonder if there's another setting I need to hit? And fyi, here's another screener page that shows it triggered at the same time

0
- ago
#30
Not there either - the symbol is TEAM. It should have traded at 1:30

0
Cone8
 ( 24.10% )
- ago
#31
Auto-Stage stages the orders. You have to click and place them.

Auto-Place is the the hands off mode.
0
Cone8
 ( 24.10% )
- ago
#32
You need to hit F1 and read everything about the Order Manager.

Your orders are being removed when "Canceled, Errored, Completed, etc." because those options are checked for Auto-Remove.
0
- ago
#33
Yes, I have that selected
0
Cone8
 ( 24.10% )
- ago
#34
what's "that"?
0
- ago
#35
But the order was triggered, and as far as I can tell by the log it wasn't cancelled, rejected or placed.

Is there an issue about auto placed orders happening at market close vs. open?
0
- ago
#36
"that" = auto place. sorry, messages going back and forth too fast
0
Cone8
 ( 24.10% )
- ago
#37
You posted 2 different images. It's clear that the orders in the first image were manually or auto Staged because they are "Staged".

The second image has active orders - those were "Placed".
0
- ago
#38
ok, sorry, I wasn't being clear.

Those orders are for an active account I'm using, separate from the Dummy Account. When I look for the order that should have been placed in the dummy account, the position "TEAM" isn't showing up either in the Order Manager nor in the account.
0
Cone8
 ( 24.10% )
- ago
#39
But if the order is a MarketClose order, this will be treated like a Market order by the Dummy Broker. (In general, the Dummy is used to check order flow, it's not going to give you "real" results. ) The order should have Filled and then Auto-Removed.

Uncheck all Auto-Remove actions. Then you'll be able to tell what happened to orders that were Placed.

1
- ago
#40
Thanks, I unchecked them and I'm going to monitor it for a couple days. Yesterday another order was placed (short) and immediately covered so something may be wrong with my models.
0
- ago
#41
It looks like signals that are placed immediately ("at market") make it but those signals that are " market close" get cancelled each time.
0
Cone8
 ( 24.10% )
- ago
#42
Since the dummy broker doesn’t support market close orders do this instead. Uncheck “Use MOC…” in the trading preferences. Enter the number of seconds to place MarketClose orders before the session close. This way, the market close orders will be put in a WaitForClose State, and when the number of seconds are reached before the session close, the orders will be placed at market. You don’t have to do this if you use a broker that supports market close orders.
1
Best Answer
- ago
#43
This is what I have in the settings now. It seems like this is already set the way you mention above:
0
- ago
#44
It also cancelled a Stop order for POWL:

0
Cone8
 ( 24.10% )
- ago
#45
If you double click on the Canceled orders, is there any extra information shown in the order messages?

The last MarketClose order for AGI placed at 16:00:02 will be a problem. You see that the state is WaitForClose, but the time has already passed. There's no way to signal an order at 1600 and fill it for MOC (the market is already closed).

You have to execute orders signaled at 1600 in the after-hours market, OR, make your strategy place a market order for the next open instead of a MarketClose order.

0
- ago
#46
The building block I use is "buy Next Bar at Market Close" - is there a different bb I can use (i.e. buy at open signal +1 bar)?

I looked at the cancelled orders and there's no additional information, unfortunately, and I couldn't find anything in the help documentation that explains why orders would be cancelled in the auto-place mode. Are there specific reasons why orders are cancelled?
0
- ago
#47
Also, with the trading preferences, shouldn't the AGI signal have been triggered 300 seconds before the end of the bar?
0
Cone8
 ( 24.10% )
- ago
#48
An active order would be canceled by the strategy if the order is not "repeated" on the next bar. Since you're trading intraday, that would explain what happened. Block Strategies are limited in this sense; intraday trading often requires special logic.

Like I said, MOC orders aren't handled by the dummy broker (we can work on that), but they are by all the supported brokers. I think (not sure) that the intraday strategy will work without modification if you check "Use MOC.." with a live broker. In this case, MOC orders are placed immediately with the broker as "MOC". The thing is, this order will probably still be canceled by the intraday strategy on the next bar if the order isn't repeated.

Probably we need to work on an intraday implementation for a MOC order placed midday.
0
- ago
#49
Got it, thanks
0
- ago
#50
What is the building block command (or the code) to buy on the open of the next bar?
0
Glitch8
 ( 12.85% )
- ago
#51
It's called "Buy at Market".
0
- ago
#52
well, let me be more clear - I want to buy at the next bar open +1 bar, i.e. at the 2nd bar after the signal is generated since the buy at market close won't fire in the dummy account.
0
- ago
#53
BTW, if there are basic training videos on YT or somewhere that I can read this without asking you guys the questions, let me know.
0
Glitch8
 ( 12.85% )
- ago
#54
You can only issue a signal for the next bar, not two bars out.

But if you’re using Building Blocks you can use the Qualifier “N Bars Ago” to base the signal on a Condition a number of bars in the past. This results in effectively the same thing.
1

Closed

Bookmark

Sort