Free Ease of Life Bot

Created at 04 Oct 2019, 04:05
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!
TH

thoy1

Joined 15.02.2018

Free Ease of Life Bot
04 Oct 2019, 04:05


Hi All,

Here is a simple Ease of Life Bot to improve your interface management. It's purpose is to simply zoom in and out without having to manually adjust your Y-scale.


4x Parameters

#1 - Top of Range - defines the Top Y-value of that you wish to make visible. ie. AUDNZD set to 1.12

#2 - Bottom of Range - defines the Bottom Y-value that you wish to make visible. ie. AUDNZD set to 1.0

#3 - Range of View Percent - defines the percentage of the range that you wish to see while zoomed in. ie. 15 = 15%

#4 - Follow Ask/Bid - setting to "1" will cause the Chart to continually centre around the Ask/Bid lines. Anything else will turn Following off.


When the Bot starts, the chart will zoom in to show only the percentage of the chart you have set.

When the Bot is stopped, the chart will zoom out to show the entire Y-range that you have set. ie AUDNZD 1.0 - 1.12

 

I hope some of you find this usefull.

Enjoy!

Thoy1

 

using System;
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 AAAInterface : Robot
    {
        [Parameter("Top of Range", DefaultValue = 1.18)]
        public double extremeHigh { get; set; }
        [Parameter("Bottom of Range", DefaultValue = 1.0)]
        public double extremeLow { get; set; }
        [Parameter("Range of View Percent", DefaultValue = 25)]
        public double rangePercentage { get; set; }
        [Parameter("Follow Ask/Bid? 1=On, 0=Off", DefaultValue = 1)]
        public double follow { get; set; }

        protected override void OnStart()
        {
            Chart.SetYRange(Symbol.Bid - ((extremeHigh - extremeLow) * (rangePercentage / 200)), Symbol.Bid + ((extremeHigh - extremeLow) * (rangePercentage / 200)));
        }

        protected override void OnTick()
        {
            if (follow == 1)
            {
                Chart.SetYRange(Symbol.Bid - ((extremeHigh - extremeLow) * (rangePercentage / 200)), Symbol.Bid + ((extremeHigh - extremeLow) * (rangePercentage / 200)));
            }
        }

        protected override void OnStop()
        {
            Chart.SetYRange(extremeLow - ((extremeHigh - extremeLow) * 0.1), extremeHigh + ((extremeHigh - extremeLow) * 0.1));
        }
    }
}

 


@thoy1
Replies

PanagiotisCharalampous
04 Oct 2019, 08:35

Hi thoy1,

Thanks for sharing your cBot with us. You can always upload it in the relevant algo section so that it does not get lost in the discussions.

Best Regards,

Panagiotis


@PanagiotisCharalampous

thoy1
04 Oct 2019, 09:17

RE:

Panagiotis Charalampous said:

Hi thoy1,

Thanks for sharing your cBot with us. You can always upload it in the relevant algo section so that it does not get lost in the discussions.

Best Regards,

Panagiotis

Hi Panagiotis,

I have done this now. Thanks for the suggestion :)

Kind regards,

Thoy1

 


@thoy1