Topics

Forum Topics not found

Replies

amusleh
15 Oct 2021, 13:07

RE: RE:

douglascvas said:

 amusleh said:

Hi,

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

You can get the symbol digits from ProtoOASymbol.

As I said, that's weird because the value is a double, so I don't understand why I need to round it before sending. Anyway, using bigdecimal fixes that one problem:

request.setStopPrice(BigDecimal.valueOf(order.getTargetPrice())
                    .setScale(symbol.getDigits(), RoundingMode.HALF_UP)
                    .doubleValue());

 

Now I get another one in the relative price. And that one I can't see how to fix

request.setRelativeStopLoss((long) (stopLossPips * symbol.getPipSize() * 100000));

That gives me this error:

Error:Relative stop loss has invalid precision

How can that be if the field is a Long? There is absolutely no way to set decimal precision. I don't understand what is going on.

The .proto file states this:

optional int64 relativeTakeProfit = 20; // Relative Take Profit that can be specified instead of the absolute one. Specified in 1/100000 of unit of a price. For BUY takeProfit = entryPrice + relativeTakeProfit, for SELL takeProfit = entryPrice - relativeTakeProfit.​

 

Hi,

You should round the multiplication result before converting it back to long, ex:

        public static long GetRelativeFromPips(this ProtoOASymbol symbol, double pips)
        {
            var pipsInPrice = pips * symbol.GetPipSize();

            return (long)Math.Round(pipsInPrice * 100000, symbol.Digits);
        }

If you pass 10 pips for above method it will first multiply it by symbol pip size, for example EURUSD pip size is 0.0001, then it will multiply it to 100000 and then it rounds the multiplication result back to symbol digits.


@amusleh

amusleh
15 Oct 2021, 08:29

Hi,

You can only have access to the chart objects that your indicator/cBot is attached to, you can't access other charts objects.

 


@amusleh

amusleh
15 Oct 2021, 08:28

Hi,

Please post some sample code for replicating this issue.


@amusleh

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