alert for ema crossover

Created at 20 Oct 2017, 20:09
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!
AR

arismac

Joined 20.10.2017

alert for ema crossover
20 Oct 2017, 20:09


Hi, 

i am looking for a way to be alerted on ema crossovers, maybe an indicator or cbot?

 

can someone help?

 

thanx


@arismac
Replies

PanagiotisCharalampous
23 Oct 2017, 11:54

Hi arismac,

Thanks for posting in our forum! It is possible to program a cBot that will alert you on ema crossovers. The following resources might be helpful for you.

/api/reference/functions/hascrossedabove

/api/reference/functions/hascrossedbelow

/api/reference/internals/inotifications

Let me know if you need any additional help.

Best Regards,

Panagiotis


@PanagiotisCharalampous

nguyendan81985
26 Oct 2018, 05:23

RE:

Panagiotis Charalampous said:

Hi arismac,

Thanks for posting in our forum! It is possible to program a cBot that will alert you on ema crossovers. The following resources might be helpful for you.

/api/reference/functions/hascrossedabove

/api/reference/functions/hascrossedbelow

/api/reference/internals/inotifications

Let me know if you need any additional help.

Best Regards,

Panagiotis

hi Panagiotis,

could you give me one example like: the last close price cross above EMA34 then Buy position, and last price cross below EMA34 then Sell position

thanks

 


@nguyendan81985

PanagiotisCharalampous
26 Oct 2018, 09:29

Hi nguyendan81985,

See below

using System;
using System.Collections.Generic;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        ExponentialMovingAverage _ema;
        protected override void OnStart()
        {
            _ema = Indicators.ExponentialMovingAverage(MarketSeries.Close, 34);
        }

        protected override void OnTick()
        {
            if (MarketSeries.Close.HasCrossedAbove(_ema.Result, 1))
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000);
            if (MarketSeries.Close.HasCrossedBelow(_ema.Result, 1))
                ExecuteMarketOrder(TradeType.Sell, Symbol, 1000);
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

nguyendan81985
28 Oct 2018, 06:20 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Panagiotis Charalampous said:

Hi nguyendan81985,

See below

using System;
using System.Collections.Generic;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        ExponentialMovingAverage _ema;
        protected override void OnStart()
        {
            _ema = Indicators.ExponentialMovingAverage(MarketSeries.Close, 34);
        }

        protected override void OnTick()
        {
            if (MarketSeries.Close.HasCrossedAbove(_ema.Result, 1))
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000);
            if (MarketSeries.Close.HasCrossedBelow(_ema.Result, 1))
                ExecuteMarketOrder(TradeType.Sell, Symbol, 1000);
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis

Thank Panagiotis,

i used your method to use with CCI, but the code is not working as I want:

could you give me an example: CCI crossed above or below 100 value will do some thing... My coding as below. and i also attached the picture the result of my coding. could you help me to review and advise if something is wrong

private CommodityChannelIndex cci;

protected override void OnStart()
        {
            cci = Indicators.CommodityChannelIndex(14);
            

        }

        protected override void OnBar()
        {


            if (cci.Result.HasCrossedBelow(100.0, 1))
                Print("CCI cross below 100");

            if (cci.Result.HasCrossedBelow(200.0, 1))
                Print("CCI cross below 200");

}

 


@nguyendan81985

PanagiotisCharalampous
29 Oct 2018, 11:27

Hi nguyendan81985,

Could you please let us know the symbol as well so that I can reproduce this behavior in backtesting?

Best Regards,

Panagiotis


@PanagiotisCharalampous

nelsonsilva.blog
26 Jun 2019, 05:25

MA CROSSOVER

Hello! 

 

I'm a developer but i dont know the ctrader api yet;

is it possible to build a simple indicator that send me an alert on price EMA crossover?

Could anyone help me on this?


@nelsonsilva.blog

PanagiotisCharalampous
26 Jun 2019, 09:43

Hi nelsonsilva.blog,

Let us know what kind of help do you need.

Best Regards,

Panagiotis


@PanagiotisCharalampous

ClickAlgo
26 Jun 2019, 10:23

Hi, Nelson,

This product may help you.

https://clickalgo.com/ctrader-moving-average-instant-alert-messages

Paul Hayes
Sales & Marketing
Emailcontact@clickalgo.com
Phone: (44) 203 289 6573
Websitehttps://clickalgo.com

 


@ClickAlgo

tradingpool
23 Mar 2023, 16:29

RE:

ClickAlgo said:

Hi, Nelson,

This product may help you.

https://clickalgo.com/ctrader-moving-average-instant-alert-messages

Paul Hayes
Sales & Marketing
Emailcontact@clickalgo.com
Phone: (44) 203 289 6573
Websitehttps://clickalgo.com

 

 

Hi Paul

Can you add a crossover Alert and a "MA change of direction" alert? Can you add a soundalert without a Popup?

Thanks!


@tradingpool

tradingpool
23 Mar 2023, 17:15

RE: RE:

tradingpool said:

ClickAlgo said:

Hi, Nelson,

This product may help you.

https://clickalgo.com/ctrader-moving-average-instant-alert-messages

Paul Hayes
Sales & Marketing
Emailcontact@clickalgo.com
Phone: (44) 203 289 6573
Websitehttps://clickalgo.com

 

 

Hi Paul

Can you add a crossover Alert and a "MA change of direction" alert? Can you add a soundalert without a Popup?

Thanks!

Found one!

 


@tradingpool