Category Trend  Published on 05/08/2021

OrglobalFx MA MTF Indicator

Description

Telegram: @orglobalng 

Donate

 


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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.EasternStandardTime, AccessRights = AccessRights.None)]
    public class OrglobalFx_Simple_MA_MTF_Indicator : Indicator
    {
        [Parameter("Timeframe1", DefaultValue = "Weekly")]
        public TimeFrame Time_frame1 { get; set; }
        [Parameter("Timeframe2", DefaultValue = "Daily")]
        public TimeFrame Time_frame2 { get; set; }
        [Parameter("Timeframe3", DefaultValue = "Hour4")]
        public TimeFrame Time_frame3 { get; set; }
        [Parameter("Timeframe4", DefaultValue = "Hourly")]
        public TimeFrame Time_frame4 { get; set; }
        [Parameter("Timeframe5", DefaultValue = "Minute15")]
        public TimeFrame Time_frame5 { get; set; }

        [Parameter("MA Type", DefaultValue = "Simple")]
        public MovingAverageType _maType { get; set; }
        [Parameter("MA Period", DefaultValue = 20)]
        public int _maperiod { get; set; }

        public Bars series1;
        private MovingAverage cloud;
        public bool res1bull, res2bull, res3bull, res4bull, res5bull;
        public bool res1bear, res2bear, res3bear, res4bear, res5bear;

        protected override void Initialize()
        {

        }

        public override void Calculate(int index)
        {
            txtfunction("10 2 0 0");

            tffunction(Time_frame1, "10 20 0 0");
            logicfunction(Time_frame1, "70 20 0 0");

            tffunction(Time_frame2, "10 40 0 0");
            logicfunction(Time_frame2, "70 40 0 0");

            tffunction(Time_frame3, "10 60 0 0");
            logicfunction(Time_frame3, "70 60 0 0");

            tffunction(Time_frame4, "10 80 0 0");
            logicfunction(Time_frame4, "70 80 0 0");

            tffunction(Time_frame5, "10 100 0 0");
            logicfunction(Time_frame5, "70 100 0 0");
        }

        //bars function
        public Bars seriestf(TimeFrame _tf)
        {
            Bars series = MarketData.GetBars(_tf);
            return series;
        }

        //txt function
        public void txtfunction(string _txtmargin)
        {
            var texttxt = new TextBlock 
            {
                FontSize = 12,
                //BackgroundColor = Color.Transparent,
                ForegroundColor = Color.Silver,
                Text = SymbolName.ToString(),
                Padding = "6 4",
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = _txtmargin
            };
            Chart.AddControl(texttxt);
        }


        //timeframetxt function
        public void tffunction(TimeFrame _tf, string _txtmargin)
        {
            var texttf = new TextBlock 
            {
                FontSize = 12,
                //BackgroundColor = Color.Transparent,
                ForegroundColor = Color.Silver,
                Text = _tf.ToString(),
                Padding = "6 4",
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = _txtmargin
            };
            Chart.AddControl(texttf);
        }

        public void logicfunction(TimeFrame _tf, string _txtmargin)
        {
            cloud = Indicators.MovingAverage(seriestf(_tf).ClosePrices, _maperiod, _maType);

            //Price and MA on timeframe
            res1bear = seriestf(_tf).ClosePrices.Last(1) < cloud.Result.Last(1);
            res1bull = seriestf(_tf).ClosePrices.Last(1) > cloud.Result.Last(1);

            if (res1bull == true)
            {
                txtsignal(Color.LimeGreen, Color.Black, _txtmargin, " BULLISH ", 12);
            }

            else if (res1bear == true)
            {
                txtsignal(Color.Red, Color.Black, _txtmargin, " BEARISH ", 12);
            }

            else
            {
                txtsignal(Color.Yellow, Color.Black, _txtmargin, "NEUTRAL", 12);
            }
        }

        public void txtsignal(Color bgclor, Color fgclor, string _txtmargin, string txt, int fnt)
        {
            var text3 = new TextBlock 
            {
                FontSize = fnt,
                BackgroundColor = bgclor,
                ForegroundColor = fgclor,
                Text = txt,
                Padding = "6 4",
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = _txtmargin
            };
            Chart.AddControl(text3);
        }
    }
}


Orglobalfx01's avatar
Orglobalfx01

Joined on 03.03.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: OrglobalFx_Simple_MA_MTF_Indicator.algo
  • Rating: 0
  • Installs: 1641
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
PA
paulanderonly · 1 year ago

MyKFCExperience - The overview offers a voucher, which you will get toward the finish of the fruitful review. With this voucher, you can utilize the proposition previously imprinted on your receipt.

Orglobalfx01's avatar
Orglobalfx01 · 3 years ago

thanks...
Adjusted...
Please, confirm

EV
evgrinaus · 3 years ago

rewrite as else if (res1bear == true)

EV
evgrinaus · 3 years ago

error on line 113 stops bearish appearing