OrglobalFx MA MTF Indicator free

by orglobalng in category Trend at 05/07/2021
Description

Telegram: @orglobalng 

Donate

 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐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);
        }
    }
}
Comments

evgrinaus - July 10, 2021 @ 14:23

error on line 113 stops bearish appearing

evgrinaus - July 10, 2021 @ 14:24

rewrite as else if (res1bear == true)

orglobalng - July 12, 2021 @ 23:38

thanks...
Adjusted...
Please, confirm

0