Supertrend Multisymbol

Created at 15 May 2024, 18:22
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ST

stegut

Joined 15.05.2024

Supertrend Multisymbol
15 May 2024, 18:22


Hi,
does anyone have an idea how i can set the right data to the Supertrend indicator in a multisymbol scenario?

for example on a RelativeStrengthIndex i can do something like this:
     _rsi = _bot.Indicators.RelativeStrengthIndex(_bars.ClosePrices, 7);
Supertrend however does not have a method that takes these arguments. So my question is if there is a workaround?

Example code:
namespace cAlgo.Robots
{
   [Robot(AccessRights = AccessRights.None)]
   public class bot: Robot
   {
       List<string> _symbols = new List<string> {
           "EURUSD", “EURAUD”
       };

       List<SuperTrend> _superTrends = new List<SuperTrend>();

       protected override void OnStart()
       {

           foreach (var sym in _symbols)
           {
               SuperTrend superTrend = new SuperTrend(this, sym);
               _superTrends.Add(superTrend);
           }
       }
   }

 

  public class SuperTrend
    {
       Robot _bot;
       string _symbolString;
       private Symbol _symbol;
       private Bars _bars;

       private Supertrend _supertrend;
       private RelativeStrengthIndex _rsi;


       public SuperTrend(Robot bot, string symbolString)
       {
           _bot = bot;
           _symbolString = symbolString;
           _symbol = _bot.Symbols.GetSymbol(_symbolString);

           _bars = _bot.MarketData.GetBars(_bot.TimeFrame, _symbolString);

           _supertrend = _bot.Indicators.Supertrend(20, 6);
           _rsi = _bot.Indicators.RelativeStrengthIndex(_bars.ClosePrices, 7);
       }


 


@stegut
Replies

PanagiotisCharalampous
16 May 2024, 06:03

Hi there,

At the moment this is not possible using the built in SuperTrend indicator.

Best regards,

Panagiotis


@PanagiotisCharalampous