Super Profit free

by atrader in category Trend at 10/04/2013
Description

Trend indicator with trigger alerts. 

15766 downloads
How to install
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 System.Runtime.InteropServices;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SuperProfit : Indicator
    {
        // Alert
        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
        public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);

        [Parameter(DefaultValue = 35)]
        public int DllPeriod { get; set; }

        [Parameter(DefaultValue = 1.7)]
        public double Period { get; set; }

        [Parameter(DefaultValue = MovingAverageType.Weighted)]
        public MovingAverageType MaType { get; set; }

        [Parameter()]
        public DataSeries Price { get; set; }

        [Parameter(DefaultValue = 5)]
        public int StopLoss { get; set; }

        [Parameter(DefaultValue = 20)]
        public int TakeProfit { get; set; }

        [Output("Up", PlotType = PlotType.Points, Thickness = 4)]
        public IndicatorDataSeries UpSeries { get; set; }

        [Output("Down", PlotType = PlotType.Points, Color = Colors.Red, Thickness = 4)]
        public IndicatorDataSeries DownSeries { get; set; }


        private DateTime _openTime;

        private MovingAverage _movingAverage1;
        private MovingAverage _movingAverage2;
        private MovingAverage _movingAverage3;
        private IndicatorDataSeries _dataSeries;
        private IndicatorDataSeries _trend;


        protected override void Initialize()
        {
            _dataSeries = CreateDataSeries();
            _trend = CreateDataSeries();

            var period1 = (int)Math.Floor(DllPeriod / Period);
            var period2 = (int)Math.Floor(Math.Sqrt(DllPeriod));

            _movingAverage1 = Indicators.MovingAverage(Price, period1, MaType);
            _movingAverage2 = Indicators.MovingAverage(Price, DllPeriod, MaType);
            _movingAverage3 = Indicators.MovingAverage(_dataSeries, period2, MaType);

        }

        public override void Calculate(int index)
        {
            if (index < 1)
                return;

            _dataSeries[index] = 2.0 * _movingAverage1.Result[index] - _movingAverage2.Result[index];
            _trend[index] = _trend[index - 1];

            if (_movingAverage3.Result[index] > _movingAverage3.Result[index - 1])
                _trend[index] = 1;
            else if (_movingAverage3.Result[index] < _movingAverage3.Result[index - 1])
                _trend[index] = -1;

            if (_trend[index] > 0)
            {
                UpSeries[index] = _movingAverage3.Result[index];

                if (_trend[index - 1] < 0.0)
                {
                    UpSeries[index - 1] = _movingAverage3.Result[index - 1];

                    if (IsLastBar)
                    {
                        var stopLoss = MarketSeries.Low[index - 1] - StopLoss * Symbol.PipSize;
                        var takeProfit = MarketSeries.Close[index] + TakeProfit * Symbol.PipSize;
                        var entryPrice = MarketSeries.Close[index - 1];

                        if (MarketSeries.OpenTime[index] != _openTime)
                        {
                            _openTime = MarketSeries.OpenTime[index];
                            DisplayAlert("Buy signal", takeProfit, stopLoss, entryPrice);
                        }
                    }
                }

                DownSeries[index] = double.NaN;
            }
            else if (_trend[index] < 0)
            {
                DownSeries[index] = _movingAverage3.Result[index];

                if (_trend[index - 1] > 0.0)
                {
                    DownSeries[index - 1] = _movingAverage3.Result[index - 1];

                    if (IsLastBar)
                    {
                        var stopLoss = MarketSeries.High[index - 1] + StopLoss * Symbol.PipSize;
                        var takeProfit = MarketSeries.Close[index] - TakeProfit * Symbol.PipSize;
                        var entryPrice = MarketSeries.Close[index - 1];

                        if (MarketSeries.OpenTime[index] != _openTime)
                        {
                            _openTime = MarketSeries.OpenTime[index];
                            DisplayAlert("Sell signal", takeProfit, stopLoss, entryPrice);
                        }
                    }
                }

                UpSeries[index] = double.NaN;
            }

        }

        protected void DisplayAlert(string tradyTypeSignal, double takeProfit, double stopLoss, double entryPrice)
        {
            string entryPricetext = entryPrice != 0.0 ? string.Format(" at price {0}", Math.Round(entryPrice, 4)) : "";
            string takeProfitText = takeProfit != 0.0 ? string.Format(", TP on  {0}", Math.Round(takeProfit, 4)) : "";
            string stopLossText = stopLoss != 0.0 ? string.Format(", SL on {0}", Math.Round(stopLoss, 4)) : "";

            var alertMessage = string.Format("{0} {1} {2} {3} {4}", tradyTypeSignal, entryPricetext, takeProfitText, stopLossText, Symbol.Code);

            MessageBox(new IntPtr(0), alertMessage, "Trade Signal", 0);

        }
    }
}
Comments

hellish - April 11, 2013 @ 09:36

cool

GDPR-24_67001 - April 11, 2013 @ 16:29

Unable to load assembly. Can not place indicator into robot's folder.

susantasaren - April 11, 2013 @ 18:41

@vipichigo : Its not a ROBOT its an INDICATOR. Install it in Indicator Folder.

GDPR-24_67001 - April 20, 2013 @ 06:21

@susantasaren: thanks :)

traderfx - May 21, 2013 @ 10:44

atrader.. I was looking at the code, which seems to have TP as well.. but it never shows up on the alert.. is something missing?

mazninno - September 18, 2013 @ 05:43

i sign error starting last night, after auto update;

the pop up message is LOOPING, cant be STOPped..

 

please HELP..

atrader - September 18, 2013 @ 12:42

Hi, I updated the code. I modified to have an entry for take profit as well and also fixed stop loss for the sell signal.

Thanks for the comments.

Pipwizard - September 18, 2013 @ 17:27

Build failed Errors: 2

Error: The name 'IsLastBar' does not exist in the current context

Error: The name 'IsLastBar' does not exist in the current context

tradermatrix - September 30, 2013 @ 12:35

hi
Has someone an idea to put it this indicator in a robot.
for example, open a command automatically at the same time AlertMessage.
thank you.
cordially

goodtrades - August 20, 2014 @ 20:22

@tradermatrix - did you convert it to a bot?

tradermatrix - September 02, 2014 @ 18:21

Hello 
no, I have completely forgotten this indicator. 
I think I will develop this idea. 

tynamite - November 09, 2014 @ 14:01

Hi tradermatrix,

please use this fine indicator and make a cbot out of it-

we would be very thankful for this !

8077821 - September 20, 2015 @ 07:58

is there a bot with this indicator ?

anurag.gakhar - February 01, 2016 @ 21:44

Hi,

Is it possible to add email notification to this indicator whenever the color of the dot changes from green to red or vice versa?

wilderness_images - September 16, 2016 @ 00:38

This indicator repaints.

Place it on an M1 chart and take a screenshot every minute for the proof.

That's why it looks so good.,

tenentedossantoscb@gmail.com - March 28, 2018 @ 06:15

Hi. Is It possible to trigger the sale when the high marker (green ball) appears and finish when the low marker (red ball) appears and at the same time open a sale, which will be closed when the high marker (green ball) appears and then open a new purchase and so on? as if it were a cycle? Thanks

JMFX - August 30, 2018 @ 07:15

Hello, is it updated?

janiolos - September 20, 2019 @ 07:22

Hi guys,

I am modifying this indicator to send Telegram message! this indicator is awesome!

When i finish it, I will post it here.

Thanks

firemyst - January 24, 2020 @ 21:22

Can you describe in plain English please what you're doing with the MA's in your code? I don't understand the reasoning, or what you're doing with these:

 

var period1 = (int)Math.Floor(DllPeriod / Period);

            var period2 = (int)Math.Floor(Math.Sqrt(DllPeriod));

            _movingAverage1 = Indicators.MovingAverage(Price, period1, MaType);

            _movingAverage2 = Indicators.MovingAverage(Price, DllPeriod, MaType);

            _movingAverage3 = Indicators.MovingAverage(_dataSeries, period2, MaType);

 

What the Sqrt function? And the DLLPeriod/Period. I don't understand what they're doing or purpose is?

Thank you.

5