Supertrend convert cBot

Created at 30 Dec 2021
simonaggioriccardo's avatar

simonaggioriccardo

Joined 29.01.2021

Status

In progress


Budget

10.00 EUR


Payment Method

Direct Payment

Job Description

Convert the attached indicator into a cBot

Is it possible to add the bot function that will buy on green and sell on red?

Grazie 

TELEGRAM:     Riccardo S.     +39 328 347 0121     @simonaggioriccardo     simonaggioriccardo@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TrendMagicVL : Indicator
    {
        [Parameter("CCI Period", DefaultValue = 20)]
        public int cciPer { get; set; }
        [Parameter("MA Method", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MaType { get; set; }
        [Parameter("ATR Period", DefaultValue = 5)]
        public int atrPer { get; set; }
        [Parameter("ATR Factor", DefaultValue = 1, MinValue = 0.1, MaxValue = 4.0)]
        public double Factor { get; set; }
        [Parameter("ATR Multiplier", DefaultValue = 1.0)]
        public double atrMul { get; set; }
        [Output("Trend Magic", LineColor = "Yellow")]
        public IndicatorDataSeries TM { get; set; }
        [Output("Trend Magic Up", PlotType = PlotType.DiscontinuousLine, LineColor = "Lime", Thickness = 2)]
        public IndicatorDataSeries TMUp { get; set; }
        [Output("Trend Magic Down", PlotType = PlotType.DiscontinuousLine, LineColor = "Red", Thickness = 2)]
        public IndicatorDataSeries TMDown { get; set; }

        private CommodityChannelIndex cci;
        private AverageTrueRange atr;
        private IndicatorDataSeries bufferUp, bufferDown, x, swap;


        protected override void Initialize()
        {
            cci = Indicators.CommodityChannelIndex(cciPer);
            atr = Indicators.AverageTrueRange(atrPer, MaType);
            bufferDown = CreateDataSeries();
            bufferUp = CreateDataSeries();
            x = CreateDataSeries();
            swap = CreateDataSeries();
        }
        public override void Calculate(int index)
        {
            bufferDown[index] = MarketSeries.High[index] + Factor * (atrMul * (100 * atr.Result[index] / MarketSeries.Close[index]));
            bufferUp[index] = MarketSeries.Low[index] - Factor * (atrMul * (100 * atr.Result[index] / MarketSeries.Close[index]));

            if (cci.Result[index] >= 0 && cci.Result[index - 1] < 0)
            {
                bufferUp[index] = bufferDown[index - 1];
            }
            if (cci.Result[index] <= 0 && cci.Result[index - 1] > 0)
            {
                bufferDown[index] = bufferUp[index - 1];
            }
            if (cci.Result[index] >= 0 && bufferUp[index] < bufferUp[index - 1])
                bufferUp[index] = bufferUp[index - 1];
            else if (cci.Result[index] <= 0 && bufferDown[index] > bufferDown[index - 1])
                bufferDown[index] = bufferDown[index - 1];

            x[index] = cci.Result[index] >= 0 ? bufferUp[index] : cci.Result[index] < 0 ? bufferDown[index] : x[index - 1];
            swap[index] = x[index] > x[index - 1] ? 1 : x[index] < x[index - 1] ? -1 : swap[index - 1];

            TM[index] = x[index];
            if (swap[index] == 1)
            {
                TMUp[index] = x[index];
                TMDown[index] = double.NaN;
            }
            if (swap[index] == -1)
            {
                TMDown[index] = x[index];
                TMUp[index] = double.NaN;
            }
        }
    }
}

 

 

Comments
Log in to add a comment.
4xDev's avatar
4xDev · 2 years ago

Hello!
My name is Mike from 4xdev. I am a member of the 4xdev development company, specialized in creating trading tools:
custom indicators, EAs, scripts, bots, alerts, cAlgo, cBots, etc.

We have a great experience in a сTrader platform.
Our clients are satisfied with the quality of our work and repeatedly contact us after completing an order to optimize their own cAlgos.
You can see reviews of us at forexpeacearmy.com and trustpilot.com, and our website 4xdev.com.

We can help you with your project. Please let me know if you are interested: support@4xdev.com

We offer the rate in the amount of $60 per hour, including the work of our programmers and QA-engineer.
The cost starts from $300 on average.

Looking forward to hearing from you.

JosephTradingbot's avatar
JosephTradingbot · 2 years ago

Hi, I can do it for you.
with several years of experience in programming and forex analysis and trading.

Telegram: @iamjosepe

WhatsApp: (+98)930 462 2633

Email: joseph.tradingbot@gmail.com

DonaldD's avatar
DonaldD · 2 years ago

Hi there,

We can help you with your project. You can contact us at contact@clickalgo.com for more information.

Best Regards,

Donald