Category Volatility  Published on 31/03/2020

ATR Multi Symbol pips

Description

Multi Symbol ATR pips
===========================

 

This Indicator can show ATR from 4 symbols simultaneously.
ATR shown is in pips.






For more information or Inquiry you can contact me at : 
rony.sitepu@gmail.com


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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class TEMA : Indicator
    {



        [Parameter("C1", Group = "Currency", DefaultValue = "EUR/USD")]
        public string c1 { get; set; }

        [Parameter("C2", Group = "Currency", DefaultValue = "EUR/GBP")]
        public string c2 { get; set; }

        [Parameter("C3", Group = "Currency", DefaultValue = "EUR/JPY")]
        public string c3 { get; set; }

        [Parameter("C4", Group = "Currency", DefaultValue = "EUR/CAD")]
        public string c4 { get; set; }

        [Parameter("ATR Period", Group = "Other", DefaultValue = 20)]
        public int atrper { get; set; }

        Bars b1, b2, b3, b4;





        [Output("cur 1", LineColor = "green")]
        public IndicatorDataSeries out_c1 { get; set; }
        [Output("cur 2", LineColor = "red")]
        public IndicatorDataSeries out_c2 { get; set; }
        [Output("cur 3", LineColor = "blue")]
        public IndicatorDataSeries out_c3 { get; set; }
        [Output("cur 4", LineColor = "yellow")]
        public IndicatorDataSeries out_c4 { get; set; }



        protected override void Initialize()
        {


            b1 = MarketData.GetBars(Chart.TimeFrame, c1);
            b2 = MarketData.GetBars(Chart.TimeFrame, c2);
            b3 = MarketData.GetBars(Chart.TimeFrame, c3);
            b4 = MarketData.GetBars(Chart.TimeFrame, c4);

            //===



        }

        public override void Calculate(int index)
        {


            //get time
            var charttime = Bars.OpenTimes[index];




//result 
            out_c1[index] = calcval(index, charttime, b1, c1);
            out_c2[index] = calcval(index, charttime, b2, c2);
            out_c3[index] = calcval(index, charttime, b3, c3);
            out_c4[index] = calcval(index, charttime, b4, c4);



        }


        double calcval(int index, DateTime time, Bars b, string currency)
        {

            //get index
            var idx1 = MarketData.GetBars(Chart.TimeFrame, currency).OpenTimes.GetIndexByTime(time);


            var atr = Indicators.AverageTrueRange(b, atrper, MovingAverageType.Exponential);
            var ps = Symbols.GetSymbol(currency).PipSize;

            var val = atr.Result[idx1] / ps;
            val = rd(val);



            //string text = string.Format("{0} {1}", currency, rd(val));

            //ChartObjects.DrawText(currency, text, index + 1, val, VerticalAlignment.Center, HorizontalAlignment.Right, Colors.Yellow);


            return val;

        }





        double rd(double val)
        {

            return Math.Round(val, 2);
        }


    }
}


fundspreader's avatar
fundspreader

Joined on 30.01.2017

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: ATR Multisymbol 1.0.algo
  • Rating: 0
  • Installs: 1743
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.