- ago
How do I set a strategy so it enters and exits orders based on these parameters?

1-Backtesting resolution- Look inside bar backtesting - in other words entries are based on tick rather than minute so orders can be placed intra bar and not always next bar or close of bar.
2-Position limits for pyramiding - Allow x number of entries/exits in the direction currently held.
3-Is it possible when intrabar order generation is enabled to limit entries to once per bar o x number of entries/exits per bar?

Thank you in advance.
0
577
Solved
1 Replies

Reply

Bookmark

Sort
Glitch8
 ( 8.77% )
- ago
#1
WL doesn't use tick data in its backtester, it uses bar data. But you can certainly simulate intra-bar fills by using Limit or Stop orders. Here's a quick example.

And the other matter of limiting positions is all under the control of your Strategy code. The sky's the limit but it requires some coding knowledge.

CODE:
using WealthLab.Backtest; using WealthLab.Core; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //Execute public override void Execute(BarHistory bars, int idx) {          if (idx == bars.Count - 3)          {             double price = bars.Close[idx];             PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, price);             PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, price * 1.02);             PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, price * 1.04);             PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, price * 1.06);          } } } }


1
Best Answer

Reply

Bookmark

Sort