You are on page 1of 1

using WealthLab.

Backtest;
using System;
using WealthLab.Core;
using WealthLab.Indicators;
using finantic.Indicators;

namespace WealthScript1
{
public class MyStrategy : UserStrategyBase
{
MP movingPercentile;

public override void Initialize(BarHistory bars)


{
TR tr = new TR(bars);
movingPercentile = new MP(tr, lookback: 100, percentile:75);
}

public override void Execute(BarHistory bars, int idx)


{
foreach (var pos in OpenPositions) ClosePosition(pos,
OrderType.Market);

double mpfactor = 0.7;


double limit = bars.Close[idx] - movingPercentile[idx] *
mpfactor;
PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, limit);
}
}
}

You might also like