1. Buy futures on SP-500 at the end of the session on the last day of the month if the closing price is higher than the moving average with a period 150.
2. Close the position at the end of the next session.
Who do we take money from?, too lazy to fantasize. Who knows, can comment :)
Test for 20 recent years with reinvestment.
- Average annual return— 30%.
- Winning trades — 70%
- Sharpe > 1
- Profit factor 2,47
- IN 2,73 times better than buy-and-hold
- Everything in the market 3,61% time
Please note that the last two years, the profitability 74% And 99%
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using WealthLab.Rules;
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
StrategyParameter strategyParameter1;
public MyStrategy()
{
strategyParameter1 = CreateParameter("ma", 150, 1, 200, 1);
}
protected override void Execute()
{
DataSeries ma = SMA.Series(Close, strategyParameter1.ValueInt);
PlotSeries(PricePane,SMA.Series(Close,strategyParameter1.ValueInt),Color.Blue,LineStyle.Solid,2);
for(int bar = GetTradingLoopStartBar(strategyParameter1.ValueInt); bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
SellAtClose(bar, LastPosition);
}
else
{
if(DateRules.IsLastTradingDayOfMonth(Bars.Date[bar]))
{
if (Close[bar] > ma[bar])
{
if(BuyAtClose(bar) != null )
LastActivePosition.Priority = -ROC.Value(bar, Close, 2);
}
}
}
}
}
}
}