Getting an alert

Created at 05 Feb 2014, 23:12
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ER

ErikD

Joined 22.04.2013

Getting an alert
05 Feb 2014, 23:12


Hi!

 

I am tying to program a simple indicator that would giv me an alert box when certain conditions are true

 

For example send an alert when price closes over a 20 day moving avreage

 

I cant get it to work tho ( no alert are popping up)

 

Can anyone point out whats wrong with the code?


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

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

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



        private SimpleMovingAverage mma;


        protected override void Initialize()
        {

            mma = Indicators.SimpleMovingAverage(MarketSeries.Close, 20);


        }


        public override void Calculate(int index)
        {

            if (MarketSeries.Close[index] < mma.Result[index - 1])
            {

                DisplayAlert("Buy signal");
            }

            else if (MarketSeries.Close[index] > mma.Result[index - 1])
            {

                DisplayAlert("Sell signal");

            }

        }


        protected void DisplayAlert(string tradyTypeSignal)
        {


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

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

        }
    }


}

 


@ErikD
Replies

bachapk
01 Jan 2015, 03:56

Change

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]

to

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, , AccessRights = AccessRights.FullAccess)]


@bachapk

bachapk
01 Jan 2015, 04:00

RE:

bachapk said:

 

 

Change

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]

to

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]

 


@bachapk