Topics

Forum Topics not found

Replies

amusleh
15 Oct 2021, 08:27

RE: Option to Change Grid Lines Color

RayAdam said:

Hi Support,

Is there a possibility to change the GridLines color/format ?

var grid = new Grid(3, 2)
{
    BackgroundColor = Color.LightGray,
    ShowGridLines = true
};

 

Thanks

 

There is no way for changing grid lines color, If you need it then you can open a thread for it on suggestions section.


@amusleh

amusleh
13 Oct 2021, 14:30

Hi,

The decimal places of your stop price must much with symbol digits.

You can get the symbol digits from ProtoOASymbol.


@amusleh

amusleh
13 Oct 2021, 08:12 ( Updated at: 13 Oct 2021, 08:45 )

RE:

Hi,

Once cTrader 4.2 released you will be bale to use Windows Task manager to check each custom indicator or cBot resource usage while its running.

There is no way to get server host name via Automate API, you can create a suggestion for it.

You can use FIX host name and ping it to check the latency.


@amusleh

amusleh
12 Oct 2021, 14:24

Hi,

Did you contacted your broker regarding this issue?


@amusleh

amusleh
12 Oct 2021, 09:26

Hi,

Most probably we will support officially Visual Studio 2022 after cTrader 4.2 release.


@amusleh

amusleh
12 Oct 2021, 09:24 ( Updated at: 21 Dec 2023, 09:22 )

Hi,

During that time period you had no fee to be paid.

Because of spreads, commissions, etc your followers might have different PnL result.


@amusleh

amusleh
12 Oct 2021, 07:21

Hi,

No, there is no way to get the resource usage statistics of your cBot/indicator.

You can check indicators/cBots resource usage in cTrader 4.2 from Task manager, which will run each indicator/cBot on its own sandbox process.

Please wait for cTrader 4.2 release.


@amusleh

amusleh
11 Oct 2021, 06:51

Hi,

I just tried with 15 running instance and it was able to delete all of the files.

 


@amusleh

amusleh
11 Oct 2021, 06:47

Hi,

Some of the built-in indicators support multi time frame some other doesn't.

You can create a suggestion for it if you want to or you can also develop a multi time frame version for those indicators.


@amusleh

amusleh
11 Oct 2021, 06:44

Hi,

First of all please create your thread under correct category, open a new thread under Automate API section and post your cBot full code, then we will be able to help you.


@amusleh

amusleh
11 Oct 2021, 06:42

Hi,

You can't get that data from API, try to open a thread under suggestions for it to be added.


@amusleh

amusleh
09 Oct 2021, 08:41

RE: ctrader crashed

Hi,

Something is wrong with alert XML configuration files, it located at cAlgo folder.

There is an Alerts folder inside cAlgo folder, delete it and retry.

Also please copy and post the full log of exception so I will be able to find the exact issue.


@amusleh

amusleh
09 Oct 2021, 08:40

Hi,

There is no such limitation from API, you can open as many positions/orders as you want to.

Please post your cBot code then we will be able to help you.

For documentation please check: 

 


@amusleh

amusleh
08 Oct 2021, 07:14

Hi,

Try this sample cBot:

using System;
using System.Linq;
using cAlgo.API;
using System.Globalization;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        private TimeSpan _closeTime;

        [Parameter("Close Time", DefaultValue = "17:00:00")]
        public string CloseTime { get; set; }

        [Parameter("Close Day", DefaultValue = DayOfWeek.Friday)]
        public DayOfWeek CloseDay { get; set; }

        protected override void OnStart()
        {
            if (TimeSpan.TryParse(CloseTime, CultureInfo.InvariantCulture, out _closeTime) == false)
            {
                Print("Incorrect close time value");

                Stop();
            }

            Timer.Start(1);
        }

        protected override void OnTimer()
        {
            if (Server.Time.DayOfWeek == CloseDay && Server.Time.TimeOfDay >= _closeTime)
            {
                var positionsCopy = Positions.ToArray();

                foreach (var position in Positions)
                {
                    ClosePosition(position);
                }
            }
        }
    }
}

 


@amusleh

amusleh
07 Oct 2021, 19:59

Hi,

You can use Bars inside OnTick method to get access to bars data, Bars.HighPrices.Last(1) will give you the latest closed bar high value and Bars.HighPrices.LastValue will give you the current open bar high.


@amusleh

amusleh
07 Oct 2021, 19:56

Ho,

Try this:

using cAlgo.API;
using cAlgo.API.Alert;
using System;
using cAlgo.API.Alert.Utility;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class AlertTest : Indicator
    {
        public MacdHistogram _Macd;
        
        private int _lastAlertBar;

        [Parameter("source")]
        public DataSeries Source { get; set; }

        [Parameter("Long Cycle 1", DefaultValue = 26)]
        public int LongCycle1 { get; set; }

        [Parameter("Short Cycle 1", DefaultValue = 12)]
        public int ShortCycle1 { get; set; }

        [Parameter("Signal 1", DefaultValue = 9)]
        public int inpSingal1 { get; set; }

        public IndicatorDataSeries Macdup { get; set; }
        [Output("Macd", LineColor = "Red", Thickness = 2, PlotType = PlotType.Histogram)]

        public IndicatorDataSeries Macd { get; set; }

        protected override void Initialize()
        {
            _Macd = Indicators.MacdHistogram(Source, LongCycle1, ShortCycle1, inpSingal1);
        }


        public override void Calculate(int index)
        {

            Macd[index] = _Macd.Histogram[index];
            
            if (index == _lastAlertBar) return;
            
            _lastAlertBar = index;
            
            if (_Macd.Histogram[index - 1] > 0 && _Macd.Histogram[index - 2] <= 0)
            {
                Notifications.ShowPopup(MarketSeries.TimeFrame, Symbol, TradeType.Buy, "AcademyWave.com", Symbol.Bid, "Macd cross Above zero", Server.Time);
            }

            if (_Macd.Histogram[index - 1] < 0 && _Macd.Histogram[index - 2] >= 0)
            {
                Notifications.ShowPopup(MarketSeries.TimeFrame, Symbol, TradeType.Sell, "AcademyWave.com", Symbol.Bid, "Macd cross Below zero", Server.Time);
            }
        }
    }
}

It uses the last closed bar MACD value not the current open bar.


@amusleh

amusleh
06 Oct 2021, 12:40

Hi,

If you call LoadMoreHistory method it will load more bars data for that time frame, you can call it if your indicator needs to.

Regarding values not matching issue, it can be caused by difference in data that your cBot process and fed to indicator for calculation.

You can also check the indicator calculation code, the indicator itself can be the reason too.

The code I posted was just a guide for you to make the indicator support multiple time frames, not something read for use on your code.


@amusleh

amusleh
06 Oct 2021, 09:16

Hi,

The indicator doesn't support multi time frame, it only has one parameter which is Period.

To make it multi time frame it should have a data series source parameter so you would be able to pass another time price series to it and indicator will use that instead of current chart price series.

Try this:

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class VariableMovingAverage : Indicator
    {
        [Parameter(DefaultValue = 6)]
        public int Period { get; set; }

        [Parameter("TimeFrame")]
        public TimeFrame BaseTimeFrame { get; set; }

        [Output("Main", LineColor = "Cyan")]
        public IndicatorDataSeries Result { get; set; }

        private double K = 1;
        private IndicatorDataSeries pdmS, mdmS, pdiS, mdiS, iS, tempResult;
        private Bars _baseBars;

        protected override void Initialize()
        {
            _baseBars = MarketData.GetBars(BaseTimeFrame);

            K /= Period;
            pdmS = CreateDataSeries();
            mdmS = CreateDataSeries();
            pdiS = CreateDataSeries();
            mdiS = CreateDataSeries();
            iS = CreateDataSeries();
            tempResult = CreateDataSeries();
        }

        public override void Calculate(int index)
        {
            var baseIndex = _baseBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);

            if (baseIndex < Period) return;

            double pdm = Math.Max(_baseBars[baseIndex].Close - _baseBars[baseIndex - 1].Close, 0), mdm = Math.Max(_baseBars[baseIndex - 1].Close - _baseBars[baseIndex].Close, 0);
            pdmS[index] = ((1 - K) * (double.IsNaN(pdmS[index - 1]) ? 0 : pdmS[index - 1]) + K * pdm);
            mdmS[index] = ((1 - K) * (double.IsNaN(mdmS[index - 1]) ? 0 : mdmS[index - 1]) + K * mdm);
            double pdi = pdmS[index] / (pdmS[index] + mdmS[index]);
            double mdi = mdmS[index] / (pdmS[index] + mdmS[index]);
            pdiS[index] = ((1 - K) * (double.IsNaN(pdiS[index - 1]) ? 0 : pdiS[index - 1]) + K * pdi);
            mdiS[index] = ((1 - K) * (double.IsNaN(mdiS[index - 1]) ? 0 : mdiS[index - 1]) + K * mdi);
            iS[index] = ((1 - K) * (double.IsNaN(iS[index - 1]) ? 0 : iS[index - 1]) + K * Math.Abs(pdiS[index] - mdiS[index]) / (pdiS[index] + mdiS[index]));
            double hhv = iS.Maximum(Period);
            double llv = iS.Minimum(Period);
            tempResult[index] = (1 - K * (iS[index] - llv) / (hhv - llv)) * (double.IsNaN(tempResult[index - 1]) ? 0 : tempResult[index - 1]) + _baseBars[baseIndex].Close * K * (iS[index] - llv) / (hhv - llv);
            if (index > Period * 10)
                Result[index] = tempResult[index];
        }
    }
}

I have added a new TimeFrame parameter on it, you can use it to pass an specific time frame to indicator so it will use that time frame price data instead of current time frame.

When using multiple time frames data the other time frame might not load all the historical data that your current chart time frame loaded, so you have to use LoadMoreHistory method of Bars to load more history based on your chart current amount of loaded data.

 


@amusleh

amusleh
06 Oct 2021, 09:04

Hi,

When a new bar opens all of its OHLC prices are same as its open price, but when new ticks are coming the high, low, and close will start to develop and change.

If you access the last bar OHLC values inside OnBar method it will be all same, because the OnBar method is called when a new bar opens and the new bar OHLC are all same.

Try this:

using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        protected override void OnTick()
        {
            Print("Open: {0} | High: {1} | Low: {2} | Close: {3}", Bars.OpenPrices.LastValue, Bars.HighPrices.LastValue, Bars.LowPrices.LastValue, Bars.ClosePrices.LastValue);
        }
    }
}

If you change the OnTick to OnBar you will see whenever a new bar opens the method will be called and all OHLC prices will be same.


@amusleh

amusleh
05 Oct 2021, 18:44

RE: RE:

khoshroomahdi said:

amusleh said:

Hi,

You should reference all DLL files inside Release zip file you downloaded, then it will work.

I strongly recommend you to use Visual Studio and install the alert library via Nuget.

Visual Studio is free, you can download it from here: Visual Studio - Visual Studio (microsoft.com)

is my code correct?

i do this even with visual studio but i didn't get any notification.

Hi,

Your code was correct, I tested and the popup showed up.

Check the cTrader automate logs tab, if your code calls the ShowPopup method and the popup didn't showed up then you most probably will see an error message on logs tab.


@amusleh