- ago
Hi,
I have a simple strategy to backtest symbols in a dataset.
It would generate an alert for all those symbols that closed higher than last week.

I am hoping if anyone can help convert this WL6 code to equivalent WL7 :

CODE:
namespace WealthLab.Strategies {    public class MyStrategy0 : WealthScript    {       protected override void Execute()       {           int FirstBar_Friday = Bars.Count - 6;          int SecondBar_Friday = Bars.Count - 1;              double Week1_close = Bars.Close[FirstBar_Friday];          double Week2_close = Bars.Close[SecondBar_Friday];                    {             if (IsLastPositionActive)             {                Position p = LastPosition;             }             else             {                if (Week2_close > Week1_close)                { BuyAtMarket(SecondBar_Friday + 1, "");                }             }          }       }    } }



Thanks!
0
847
Solved
2 Replies

Reply

Bookmark

Sort
- ago
#1
CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; namespace WealthScript1 {    public class subing20210710 : UserStrategyBase    {       TimeSeries weekly;       //create indicators and other objects here, this is executed prior to the main trading loop       public override void Initialize(BarHistory bars)       {          //get weekly data          weekly = TimeSeriesSynchronizer.Synchronize(BarHistoryCompressor.ToWeekly(bars).Close, bars);          PlotTimeSeries(weekly, "Close(Weekly)", "Price", Color.Blue);       }       //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(idx > 0)             if(weekly[idx] > weekly[idx - 1])                PlaceTrade(bars, TransactionType.Buy, OrderType.Market);       }    } }
1
Best Answer
- ago
#2
Thank you, Eugene!

WL version 7 seems to be so different from WL6..
The TimeSeriesSynchronizer is cool tool I was not aware of.
1

Reply

Bookmark

Sort