This strategy recreates the multi-indicator dashboard logic from the MetaTrader VirtualTradePad tool. It tracks twelve signals –
trend, momentum and channel based – and only trades when a configurable number of indicators agree. The goal is to mimic the
visual sentiment matrix of the original panel and convert it into a fully automated StockSharp strategy.
How it works
Data: trades a single instrument on the selected candle type (default 15 minutes).
Indicators:
Fast/slow simple moving averages for crossover direction.
Moving average envelope breakout back inside the channel.
Bill Williams Alligator jaw/teeth/lips alignment.
Kaufman Adaptive Moving Average slope (rising/falling).
Awesome Oscillator zero-line crosses.
Ichimoku Tenkan-Kijun crossing.
Each indicator produces a buy (+1), sell (-1) or neutral (0) vote. When the count of buy votes (or sell votes) reaches the
MinimumConfirmations parameter and exceeds the opposite side, the strategy opens a position in that direction.
Optional CloseOnOpposite closes the position when the opposite vote count reaches the threshold.
Risk management: optional take profit and stop loss defined in instrument price steps.
Parameters
FastMaLength, SlowMaLength – lengths for the crossover moving averages.
Count bullish and bearish votes from the indicators.
Enter long/short when votes reach the confirmation threshold and exceed the opposite side.
Optionally flatten when the opposite side reaches the threshold.
Apply optional take profit/stop loss measured in price steps.
The strategy is designed for discretionary traders who liked the VirtualTradePad sentiment board but want an automated
implementation inside the StockSharp framework.
using System;
using System.Collections.Generic;
using StockSharp.Algo.Indicators;
using StockSharp.Algo.Strategies;
using StockSharp.BusinessEntities;
using StockSharp.Messages;
namespace StockSharp.Samples.Strategies;
public class VirtualTradePadSignalStrategy : Strategy
{
private readonly StrategyParam<DataType> _candleType;
private readonly StrategyParam<int> _cciPeriod;
private decimal? _prevCci;
public DataType CandleType { get => _candleType.Value; set => _candleType.Value = value; }
public int CciPeriod { get => _cciPeriod.Value; set => _cciPeriod.Value = value; }
public VirtualTradePadSignalStrategy()
{
_candleType = Param(nameof(CandleType), TimeSpan.FromHours(1).TimeFrame()).SetDisplay("Candle Type", "Timeframe", "General");
_cciPeriod = Param(nameof(CciPeriod), 20).SetGreaterThanZero().SetDisplay("CCI Period", "CCI lookback", "Indicators");
}
public override IEnumerable<(Security sec, DataType dt)> GetWorkingSecurities() => [(Security, CandleType)];
/// <inheritdoc />
protected override void OnReseted()
{
base.OnReseted();
_prevCci = null;
}
protected override void OnStarted2(DateTime time)
{
base.OnStarted2(time);
_prevCci = null;
var cci = new CommodityChannelIndex { Length = CciPeriod };
var subscription = SubscribeCandles(CandleType);
subscription.Bind(cci, ProcessCandle).Start();
var area = CreateChartArea();
if (area != null) { DrawCandles(area, subscription); DrawOwnTrades(area); }
}
private void ProcessCandle(ICandleMessage candle, decimal cciVal)
{
if (candle.State != CandleStates.Finished) return;
if (!IsFormedAndOnlineAndAllowTrading()) { _prevCci = cciVal; return; }
if (_prevCci == null) { _prevCci = cciVal; return; }
if (_prevCci.Value < 0m && cciVal >= 0m && Position <= 0) { if (Position < 0) BuyMarket(); BuyMarket(); }
else if (_prevCci.Value > 0m && cciVal <= 0m && Position >= 0) { if (Position > 0) SellMarket(); SellMarket(); }
_prevCci = cciVal;
}
}
import clr
clr.AddReference("StockSharp.Messages")
clr.AddReference("StockSharp.Algo")
clr.AddReference("StockSharp.Algo.Indicators")
clr.AddReference("StockSharp.Algo.Strategies")
from System import TimeSpan
from StockSharp.Messages import DataType, CandleStates
from StockSharp.Algo.Indicators import CommodityChannelIndex
from StockSharp.Algo.Strategies import Strategy
from datatype_extensions import *
from indicator_extensions import *
class virtual_trade_pad_signal_strategy(Strategy):
"""CCI crossing zero line for buy/sell signals."""
def __init__(self):
super(virtual_trade_pad_signal_strategy, self).__init__()
self._cci_period = self.Param("CciPeriod", 20).SetGreaterThanZero().SetDisplay("CCI Period", "CCI lookback", "Indicators")
self._candle_type = self.Param("CandleType", DataType.TimeFrame(TimeSpan.FromHours(1))).SetDisplay("Candle Type", "Timeframe", "General")
@property
def CandleType(self): return self._candle_type.Value
@CandleType.setter
def CandleType(self, value): self._candle_type.Value = value
def OnReseted(self):
super(virtual_trade_pad_signal_strategy, self).OnReseted()
self._prev_cci = None
def OnStarted2(self, time):
super(virtual_trade_pad_signal_strategy, self).OnStarted2(time)
self._prev_cci = None
cci = CommodityChannelIndex()
cci.Length = self._cci_period.Value
sub = self.SubscribeCandles(self.CandleType)
sub.Bind(cci, self.OnProcess).Start()
area = self.CreateChartArea()
if area is not None:
self.DrawCandles(area, sub)
self.DrawOwnTrades(area)
def OnProcess(self, candle, cci_val):
if candle.State != CandleStates.Finished:
return
cv = float(cci_val)
if self._prev_cci is not None:
if self._prev_cci < 0 and cv >= 0 and self.Position <= 0:
if self.Position < 0:
self.BuyMarket()
self.BuyMarket()
elif self._prev_cci > 0 and cv <= 0 and self.Position >= 0:
if self.Position > 0:
self.SellMarket()
self.SellMarket()
self._prev_cci = cv
def CreateClone(self):
return virtual_trade_pad_signal_strategy()