- ago
I am trading a dip buyer on a daily basis

Today there are 5 executed entries, 5 rejected entries (that's ok) - but also 5 take profi orders (exits). the exit orders were activated shortly after the entry and transferred to the broker account. but the strategy is set so that there should be no same bar exits.

Limit extis always only from day 2. why does this happen in this case? I can't find a setting in the preferences that allows/prevents these same bar exits and the "same bar" check mark is not active in the building block.

Have I overlooked something? Thanks!

0
395
8 Replies

Reply

Bookmark

Sort
Glitch8
 ( 10.65% )
- ago
#1
We'd need to see the Strategy, but it looks like the Strategy is configured to trade multiple positions per symbol.
0
Cone8
 ( 4.72% )
- ago
#2
Glitch, hh is showing that same bar exits fired for the 6 Limit orders that filled.
It certainly shouldn't happen if the strategy hasn't assigned t.AutoProfitTargetPrice.

The only thing I can suggest is that if it's block strategy, export it to C# and look for AutoProfitTargetPrice. Does it appear somewhere?
0
- ago
#3
@Cone: no. AutoProfit... does not appear in the code.

This is the code. It's a simple dip buyer for for test purposes

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; using finantic.Indicators; namespace WealthScript3 { public class MyStrategy : UserStrategyBase {     public MyStrategy() : base() {          AddParameter("ATR Period", ParameterType.Int32, 6, 6, 12, 1);          AddParameter("ATR Factor2", ParameterType.Double, 1.3, 0.9, 1.4, 0.1);          AddParameter("How many bars ago", ParameterType.Int32, 0, 0, 2, 1);          AddParameter("Fast Period", ParameterType.Int32, 9, 5, 25, 1);          AddParameter("Middle Period", ParameterType.Int32, 3, 3, 5, 1);          AddParameter("Slow Period", ParameterType.Int32, 5, 2, 5, 1);          AddParameter("Value", ParameterType.Double, 132, 50, 135, 1); StartIndex = 9; } public override void Initialize(BarHistory bars) {          indicator = new UltimateOsc(bars,Parameters[3].AsInt,Parameters[4].AsInt,Parameters[5].AsInt);          PlotIndicator(indicator,new WLColor(0,0,0));          _startIndexList.Add(indicator);          // Buy at Limit P-ATR (GenerateInitCode)          atr = new ATR(bars, Parameters[0].AsInt); // measured volatility          PlotStopsAndLimits(3); 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 (indicator[index] < Parameters[6].AsDouble)                {                   condition0 = true;                }             }             if (condition0)             {                Backtester.CancelationCode = 1;                // Buy at Limit P-ATR (GenerateMainCode)                double dist = atr[idx] * Parameters[1].AsDouble;                double limit = bars.GetPriceComponent(PriceComponent.Open)[idx-Parameters[2].AsInt] - dist;                _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, limit, 0);             }          }          else          {             {                Backtester.CancelationCode = 1;                if (idx - foundPosition0.EntryBar + 1 >= 2)                {                   ClosePosition(foundPosition0, OrderType.Market, 0,"Sell after 2 bars");                }             }             {                Backtester.CancelationCode = 1;                value = (3.00 / 100.0) + 1.0;                ClosePosition(foundPosition0, OrderType.Limit, foundPosition0.EntryPrice * value, "Sell at " + 3.00 + "% profit tgt");             }          } } public override void NewWFOInterval(BarHistory bars) {          indicator = new UltimateOsc(bars,Parameters[3].AsInt,Parameters[4].AsInt,Parameters[5].AsInt); }       private IndicatorBase indicator;       private ATR atr;       private double value;       private Transaction _transaction; private List<IndicatorBase> _startIndexList = new List<IndicatorBase>(); } }
0
Cone8
 ( 4.72% )
- ago
#4
The only scenario I can imagine is that the "Same-Bar" checkbox for the Profit target order was checked and saved with the Strategy when you added it to the Strategy Monitor. Since it's not a parameter that could be changed later, it had to be saved with the strategy.

There's always a slim chance (Glitch would know better) that that setting isn't being read correctly when it was loaded in the Strategy Monitor. But, if at any time you had selected the Same-Bar option, it would be even a slimmer chance.
0
- ago
#5
@Cone: I do not use the Strategy Monitor for this dip buyer. Instead, I simply let the building block strategy "run through" and then transfer the orders using "send to quotes window".

I also have not activated the "same bar" checkbox in the building block strategy itself. See screenshot please.

To be honest, I am also a bit perplexed, because this error (?) did not occur during my last dip buyer test a few weeks ago.

Could this have something to do with the update to B82, where you did something with the "Pre Signal Thersholds"?

0
Cone8
 ( 4.72% )
- ago
#6
We're perplexed too. We'll have to find the cause
0
- ago
#7
@Cone: today the DB strategy is running again. but today there are no limit orders with new entrys on day 1...

very strange because i did not change any settings.

I also have to mention that I am still running B85. The IB Extension is up to date.

0
Cone8
 ( 4.72% )
- ago
#8
I couldn't duplicate it either with a similar strategy.
We'll just have to keep an eye on it.
0

Reply

Bookmark

Sort