- ago
Is there a way to prohibit trades via the building blocks if there are more than N signals? Unfortunately, I have not found a way to do this. I have also not found a possibility in position sizing. If this is only possible via the code, does anyone have any idea what the code line should look like and where I should insert it?
0
291
Solved
5 Replies

Reply

Bookmark

Sort
Cone8
 ( 5.88% )
- ago
#1
That won't be possible in blocks (at least not currently).

Does "N signals" include other symbols too? What's the scenario exactly?
0
- ago
#2
The restriction ‘N-signals’ should refer to days on which there are 40 signals in the S&P100, for example. Since my backtest shows that days with 40 signals are bad trading days, I don't want to take any of the signals on this day (this is just an example). I am looking for a way to skip days with a certain number of signals.
0
Glitch8
 ( 9.28% )
- ago
#3
You would do it in PostExecute. Here's an example where all orders are removed if the number of signals is greater than the day of the month.

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; using System.Data; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) {             PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } else { PlaceTrade(bars, TransactionType.Sell, OrderType.Market); } } //prune signals public override void PostExecute(DateTime dt, List<BarHistory> participants) {    if (Backtester.Orders.Count > dt.Day)             Backtester.Orders.Clear(); } //declare private variables below } }
0
Best Answer
- ago
#4
Thank you very much! I will try it out. Could such a function be implemented in the blocks in future?
0
Glitch8
 ( 9.28% )
- ago
#5
Yes but it's not a very general requirement, so we could handle it via a private Concierge job.
0

Reply

Bookmark

Sort