Auf GitHub ansehen

NAS100 and Gold Smart Scalping Strategy PRO Enhanced v2

Strategy scalps short-term moves using EMA9 and VWAP as dynamic guides, RSI for momentum, and ATR for risk management. A 15 minute EMA200 trend filter keeps trades with the prevailing trend while a volume spike filter seeks strong candles. Positions size by risk and support optional trailing stops and cooldown periods between trades.

Details

  • Entry Criteria: indicator signal
  • Long/Short: Both
  • Exit Criteria: stop-loss, take-profit or opposite signal
  • Stops: Yes, ATR based
  • Default Values:
    • CandleType = 1 minute
    • RiskPercent = 1%
    • AtrMultiplierSl = 1
    • AtrMultiplierTp = 2
    • CooldownMins = 30
    • StartHour = 13
    • EndHour = 20
  • Filters:
    • Category: Scalping
    • Direction: Both
    • Indicators: EMA, VWAP, RSI, ATR, EMA200
    • Stops: Yes
    • Complexity: Intermediate
    • Timeframe: Intraday
    • Seasonality: No
    • Neural networks: No
    • Divergence: No
    • Risk level: Medium
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 Nas100AndGoldSmartScalpingProEnhancedV2Strategy : Strategy
{
	private readonly StrategyParam<DataType> _candleType;
	public DataType CandleType { get => _candleType.Value; set => _candleType.Value = value; }
	public Nas100AndGoldSmartScalpingProEnhancedV2Strategy()
	{
		_candleType = Param(nameof(CandleType), TimeSpan.FromMinutes(5).TimeFrame());
	}
	protected override void OnStarted2(DateTime time)
	{
		base.OnStarted2(time);
		var fast = new ExponentialMovingAverage { Length = 12 };
		var slow = new ExponentialMovingAverage { Length = 34 };
		var rsi = new RelativeStrengthIndex { Length = 14 };
		var prevF = 0m; var prevS = 0m; var init = false;
		var lastSignal = DateTimeOffset.MinValue;
		var cooldown = TimeSpan.FromMinutes(120);
		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 (c.OpenTime - lastSignal >= cooldown)
			{
				if (prevF <= prevS && f > s && r > 50 && Position <= 0) { BuyMarket(); lastSignal = c.OpenTime; }
				else if (prevF >= prevS && f < s && r < 50 && Position > 0) { SellMarket(); lastSignal = c.OpenTime; }
			}
			prevF = f; prevS = s;
		}).Start();
		var area = CreateChartArea();
		if (area != null) { DrawCandles(area, sub); DrawIndicator(area, fast); DrawIndicator(area, slow); DrawOwnTrades(area); }
	}
}