- ago
Why this happening? And how to fix it, if it's possibilite?
0
173
Solved
5 Replies

Reply

Bookmark

Sort
Cone8
 ( 4.83% )
- ago
#1
Not enough information.
1. Switching where, when?
2. What code is involved?
If you don't want to share your Strategy, create a "minimal Strategy" that demonstrates what you're seeing and post it. Images help too.
0
- ago
#2
1-Change the entry price after the trade. The day before, when I load the data, it gives me an entry price, but the next day when the trade is executed, the entry price appears as being different, always better than the one previously informed.

2-This is the simple one, no problem to share.

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; using WealthLab.TASC; namespace WealthScript1 { public class MyStrategy : UserStrategyBase {     public MyStrategy() : base() {          AddParameter("Band average", ParameterType.Int32, 3, 1, 10, 1);          AddParameter("Deviation factor", ParameterType.Double, 1, 1, 5, 1);          AddParameter("Low band adjustment", ParameterType.Double, 0.9, 0.1, 1, 0.1); StartIndex = 30; } public override void Initialize(BarHistory bars) {          source = new SVESmoothedVolatilityBandLower(bars,Parameters[0].AsInt,3,Parameters[1].AsDouble,Parameters[2].AsDouble);          PlotIndicator(source,new WLColor(0,0,0));          _startIndexList.Add(source);          pct = 0.00;          pct = (100.0 - pct) / 100.0;          multSource = source * pct;          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;          bool condition0;             {                Backtester.CancelationCode = 1;                val = multSource[idx];                _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, val, 0, "Buy " + 0.00 + "% below " + source.Description);                PlaceTrade(bars, TransactionType.Sell, OrderType.MarketClose);             }             {             foreach(Position foundPosition0 in OpenPositions)             {                if (foundPosition0.PositionTag == 0)                {                   Backtester.CancelationCode = 1;                   ClosePosition(foundPosition0, OrderType.MarketClose, 0, "Sell At Close (1)");                }             }             } } public override void NewWFOInterval(BarHistory bars) {          source = new SVESmoothedVolatilityBandLower(bars,Parameters[0].AsInt,3,Parameters[1].AsDouble,Parameters[2].AsDouble);          pct = 0.00;          pct = (100.0 - pct) / 100.0;          multSource = source * pct; }       public override void AssignAutoStopTargetPrices(Transaction t, double basisPrice, double executionPrice)       {          double price = 0;          if (t.PositionTag == 1)          {          }       }       private double pct;       private double val;       private IndicatorBase source;       private TimeSeries multSource;       private Transaction _transaction; private List<IndicatorBase> _startIndexList = new List<IndicatorBase>(); } }
0
Glitch8
 ( 11.08% )
- ago
#3
It's because this is a "peeking" indicator. See the warning here? You should not use it for trading purposes.

1
Best Answer
- ago
#4
Thanks Glitch. I saw this warning later. But I was wondering if there was no way to use it without having this change in the entry price, for example, using longer parameters or some additional calculation.
0
Glitch8
 ( 11.08% )
- ago
#5
No, there's really no way.
1

Reply

Bookmark

Sort