GitHub で見る

MultiLayer Awesome Oscillator Saucer

Implements a bullish multi-layer strategy based on the Awesome Oscillator saucer pattern and fractal trend detection. The strategy counts consecutive saucer signals and places up to five layered buy stop orders above price. Positions are closed when the trend reverses.

Parameters

  • EMA Length – period of the EMA filter.
  • Candle Type – type of candles.
  • Trade Start – start of trading period.
  • Trade Stop – end of trading period.
using System;
using Ecng.Common;
using StockSharp.Algo.Indicators;
using StockSharp.Algo.Strategies;
using StockSharp.BusinessEntities;
using StockSharp.Messages;
namespace StockSharp.Samples.Strategies;
public class MultiLayerAwesomeOscillatorSaucerStrategy : Strategy
{
	private readonly StrategyParam<DataType> _candleType;
	public DataType CandleType { get => _candleType.Value; set => _candleType.Value = value; }
	public MultiLayerAwesomeOscillatorSaucerStrategy()
	{
		_candleType = Param(nameof(CandleType), TimeSpan.FromMinutes(15).TimeFrame());
	}
	protected override void OnStarted2(DateTime time)
	{
		base.OnStarted2(time);
		var fast = new ExponentialMovingAverage { Length = 8 };
		var slow = new ExponentialMovingAverage { Length = 21 };
		var rsi = new RelativeStrengthIndex { Length = 14 };
		var prevF = 0m; var prevS = 0m; var init = false;
		var sub = SubscribeCandles(CandleType);
		sub.Bind(fast, slow, rsi, (c, f, s, r) =>
		{
			if (c.State != CandleStates.Finished || !fast.IsFormed || !slow.IsFormed || !rsi.IsFormed) return;
			if (!init) { prevF = f; prevS = s; init = true; return; }
			if (prevF <= prevS && f > s && r > 45 && Position <= 0) BuyMarket();
			else if (prevF >= prevS && f < s && r < 55 && Position > 0) SellMarket();
			prevF = f; prevS = s;
		}).Start();
		var area = CreateChartArea();
		if (area != null) { DrawCandles(area, sub); DrawIndicator(area, fast); DrawIndicator(area, slow); DrawOwnTrades(area); }
	}
}