Topics

Forum Topics not found

Replies

amusleh
28 Jul 2021, 14:33

Hi,

Can you please provide your broker name and cTrader version?


@amusleh

amusleh
28 Jul 2021, 08:56

Hi,

You can post a job request on the Jobs page or ask one of our consultants to develop your cBot for you.


@amusleh

amusleh
28 Jul 2021, 08:50

Hi,

Try this:

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AWMultiData : Indicator
    {
        private TextBlock tb = new TextBlock();

        [Parameter("FontSize", DefaultValue = 12)]
        public int FontSize { get; set; }

        [Parameter("Space to Corner", DefaultValue = 10)]
        public int Margin { get; set; }

        [Parameter("Horizental Alignment", DefaultValue = HorizontalAlignment.Right)]
        public HorizontalAlignment HAlignment { get; set; }

        [Parameter("Vertical Alignment", DefaultValue = VerticalAlignment.Bottom)]
        public VerticalAlignment VAlignment { get; set; }

        [Parameter("Color", DefaultValue = "Red")]
        public string Color1 { get; set; }

        [Parameter("Opacity", DefaultValue = 0.7, MinValue = 0.1, MaxValue = 1)]
        public double Opacity { get; set; }

        [Parameter("Text Alignment", DefaultValue = TextAlignment.Center)]
        public TextAlignment Alignment { get; set; }

        protected override void Initialize()
        {
            Chart.AddControl(tb);
        }

        public override void Calculate(int index)
        {
            if (IsLastBar)
                DisplaySpreadOnChart();
        }

        public void DisplaySpreadOnChart()
        {
            // Calc Spread
            var spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2);
            string sp = string.Format("{0}", spread);

            //Calc daily Net Profit
            double DailyNet1 = Positions.Sum(p => p.NetProfit);
            double DailyNet2 = History.Where(x => x.ClosingTime.Date == Time.Date).Sum(x => x.NetProfit);
            double DailyNet = Math.Round(DailyNet1 + DailyNet2, 2);

            var oldTrades = History.Where(x => x.ClosingTime.Date != Time.Date).OrderBy(x => x.ClosingTime).ToArray();

            // get Starting Balance
            double StartingBalance = oldTrades.Length > 0 ? oldTrades.Last().Balance : Account.Balance;

            //calc Daily Percent Profit

            string DailyPercent = Math.Round(DailyNet / StartingBalance * 100, 2).ToString();

            //text property
            tb.Text = Symbol.Name + ", " + TimeFrame.ShortName + "\n" + StartingBalance + "\n" + DailyPercent + " %" + "\n" + DailyNet + " $" + "\n" + sp;
            tb.FontSize = FontSize;
            tb.ForegroundColor = Color1.TrimEnd();
            tb.HorizontalAlignment = HAlignment;
            tb.VerticalAlignment = VAlignment;
            tb.TextAlignment = Alignment;
            tb.Margin = Margin;
            tb.Opacity = Opacity;
        }
    }
}

 


@amusleh

amusleh
27 Jul 2021, 13:33

RE: RE: RE: RE: Exactly same issue

mohanrajdeenadayalan said:


pepperstone

iphone 11 Pro 256 GB

iphone software 14.6

c trader version 4.1.54294

 

amusleh said:

witmq said:

myrtlegonzalez73 said:

Hello,

I've been troubleshooting this same problem as well, where it wont connect to ctrader server on Telstra 4G mobile network, seems to
be after a recent update, where its been rock solid for last 6 months.

I also tried the legacy app with same symtoms.

I have also updated to IOS 14.4.2 on both iphone x and ipad and doesn't work on 4G network and works always when on wifi network

I couldn't see how the ISP blocking as the same device same IOS same app that wont connect on 4G connects immediately on telstra wifi

I've also deleted the app and its data and re signed in again and get exact same issue

Lastly I just tried connecting from ipad wifi only device using my ios iPhone as hotspot and works yet wont work directly from iphone unless it is connection to wifi.

 

Hi there,

I’ve been on undergoing with exactly the same issue and advised from Telstra support to contact CTrader support as per case ref.# 16500936. At the moment I’m looking forward to what solution of it. 
 

Hi,

Can you give me these details please:

  • Your broker name
  • cTrader app version
  • Your phone model
  • Your phone OS version

 

Hi,

Thank you for providing the detail, we will continue our investigation and we will update you ASAP.


@amusleh

amusleh
27 Jul 2021, 12:22

RE: RE: Exactly same issue

witmq said:

myrtlegonzalez73 said:

Hello,

I've been troubleshooting this same problem as well, where it wont connect to ctrader server on Telstra 4G mobile network, seems to
be after a recent update, where its been rock solid for last 6 months.

I also tried the legacy app with same symtoms.

I have also updated to IOS 14.4.2 on both iphone x and ipad and doesn't work on 4G network and works always when on wifi network

I couldn't see how the ISP blocking as the same device same IOS same app that wont connect on 4G connects immediately on telstra wifi

I've also deleted the app and its data and re signed in again and get exact same issue

Lastly I just tried connecting from ipad wifi only device using my ios iPhone as hotspot and works yet wont work directly from iphone unless it is connection to wifi.

 

Hi there,

I’ve been on undergoing with exactly the same issue and advised from Telstra support to contact CTrader support as per case ref.# 16500936. At the moment I’m looking forward to what solution of it. 
 

Hi,

Can you give me these details please:

  • Your broker name
  • cTrader app version
  • Your phone model
  • Your phone OS version

@amusleh

amusleh
27 Jul 2021, 12:17

Hi,

DayOfWeek type is not part of Automate API, it's part of .NET framework.

To use DayOfWeek on your code you must add "using System;" on top of your indicator/cBot code file.


@amusleh

amusleh
26 Jul 2021, 09:19 ( Updated at: 21 Dec 2023, 09:22 )

Hi,

Open your strategy page, then click on the share icon:


@amusleh

amusleh
26 Jul 2021, 09:14 ( Updated at: 09 Feb 2023, 11:43 )

Hi,

Please follow this tutorial: https://spotware.github.io/open-api-docs/symbol-data/#historical-bars-data

If you still had the same issue then please post your broker name and we will test.


@amusleh

amusleh
26 Jul 2021, 09:10

Right now the zooming with mouse wheel only works if you keep the ctrl button pressed, if you want to change this behavior please open a thread on the suggestions section and it will be changed if your thread got enough support from other users.


@amusleh

amusleh
26 Jul 2021, 09:08

Hi,

You can post your request on the Jobs page.

 


@amusleh

amusleh
26 Jul 2021, 08:44

Hi,

You can use Symbol.Bid or Symbol.Ask if you want to get the latest Bid/Ask price of a symbol.

If you want to get the latest bar close Price you can use Bars.ClosePrices.LastValue.

For historical bars, you can use the Bars collection index and iterate over them.


@amusleh

amusleh
26 Jul 2021, 08:41

Hi,

Try this:

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AWBoxOffline : Indicator
    {
        private ChartVerticalLine _vl;

        private ChartRectangle _box;

        [Parameter("Period", DefaultValue = 26, MinValue = 1)]
        public int Period { get; set; }

        [Parameter("Line Color", DefaultValue = "Red", Group = "Line")]
        public string LineColor { get; set; }

        [Parameter("LineStyle", DefaultValue = LineStyle.LinesDots, Group = "Line")]
        public LineStyle ls { get; set; }

        [Parameter("Thickness", DefaultValue = 2, Group = "Line")]
        public int Thickness { get; set; }

        protected override void Initialize()
        {
            _vl = Chart.DrawVerticalLine("scrollLine", Chart.LastVisibleBarIndex, Color.FromName(LineColor), Thickness, ls);
            _vl.IsInteractive = true;

            var verticalLineBarIndex = Bars.OpenTimes.GetIndexByTime(_vl.Time);

            _box = Chart.DrawRectangle("rectangle_sample", verticalLineBarIndex, Bars.LowPrices.Minimum(Period), verticalLineBarIndex - Period, Bars.HighPrices.Maximum(Period), Color.FromArgb(100, Color.Red));
            _box.IsFilled = true;
            _box.IsInteractive = false;
            _box.IsFilled = false;
            _box.Thickness = 3;

            Chart.ObjectsUpdated += Chart_ObjectsUpdated;
        }

        private void Chart_ObjectsUpdated(ChartObjectsUpdatedEventArgs obj)
        {
            if (!obj.ChartObjects.Contains(_vl)) return;

            var verticalLineBarIndex = Bars.OpenTimes.GetIndexByTime(_vl.Time);

            _box.Time1 = Bars.OpenTimes[verticalLineBarIndex];
            _box.Time2 = Bars.OpenTimes[verticalLineBarIndex - Period];

            _box.Y1 = GetMinimum(Bars.LowPrices, verticalLineBarIndex, Period);
            _box.Y2 = GetMaximum(Bars.HighPrices, verticalLineBarIndex, Period);
        }

        private double GetMinimum(DataSeries source, int index, int periods)
        {
            double min = double.MaxValue;

            var lastBarIndex = index - periods;

            for (int i = index; i > lastBarIndex; i--)
            {
                min = Math.Min(min, source[i]);
            }

            return min;
        }

        private double GetMaximum(DataSeries source, int index, int periods)
        {
            double max = double.MinValue;

            var lastBarIndex = index - periods;

            for (int i = index; i > lastBarIndex; i--)
            {
                max = Math.Max(max, source[i]);
            }

            return max;
        }

        public override void Calculate(int index)
        {
        }
    }
}

 


@amusleh

amusleh
26 Jul 2021, 08:35

Hi,

You can share a portion of the code that will help us replicate this specific issue, otherwise, we can't replicate the issue.

 


@amusleh

amusleh
26 Jul 2021, 08:33

Hi,

cTrader doesn't have such a feature, but you can do it with a custom indicator.

Create your double Stochastic indicator and then use chart controls for showing/hiding one of the indicator outputs.

If the hide button got clicked you can fill the whole indicator output with NAN and it will disappear.


@amusleh

amusleh
26 Jul 2021, 08:31

Hi,

This feature is still not available, please open a thread in the suggestions section.


@amusleh

amusleh
26 Jul 2021, 08:29

Hi,

No, for now, you can only see a single time frame chart on the cTrader back tester.


@amusleh

amusleh
24 Jul 2021, 16:21

Hi,

Your code is not correct at all! you should use instead Chart ObjectsUpdated event:

using cAlgo.API;
using System.Linq;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AWBoxOffline : Indicator
    {
        private ChartVerticalLine _vl;

        private ChartRectangle _box;

        [Parameter("Period", DefaultValue = 26, MinValue = 1)]
        public int Period { get; set; }

        [Parameter("Line Color", DefaultValue = "Red", Group = "Line")]
        public string LineColor { get; set; }

        [Parameter("LineStyle", DefaultValue = LineStyle.LinesDots, Group = "Line")]
        public LineStyle ls { get; set; }

        [Parameter("Thickness", DefaultValue = 2, Group = "Line")]
        public int Thickness { get; set; }

        protected override void Initialize()
        {
            _vl = Chart.DrawVerticalLine("scrollLine", Chart.LastVisibleBarIndex, Color.FromName(LineColor), Thickness, ls);
            _vl.IsInteractive = true;

            var verticalLineBarIndex = Bars.OpenTimes.GetIndexByTime(_vl.Time);

            _box = Chart.DrawRectangle("rectangle_sample", verticalLineBarIndex, Bars.LowPrices.Minimum(Period), verticalLineBarIndex - Period, Bars.HighPrices.Maximum(Period), Color.FromArgb(100, Color.Red));
            _box.IsFilled = true;
            _box.IsInteractive = false;
            _box.IsFilled = false;
            _box.Thickness = 3;

            Chart.ObjectsUpdated += Chart_ObjectsUpdated;
        }

        private void Chart_ObjectsUpdated(ChartObjectsUpdatedEventArgs obj)
        {
            if (!obj.ChartObjects.Contains(_vl)) return;

            var verticalLineBarIndex = Bars.OpenTimes.GetIndexByTime(_vl.Time);

            _box.Time1 = Bars.OpenTimes[verticalLineBarIndex];
            _box.Time2 = Bars.OpenTimes[verticalLineBarIndex - Period];
        }

        public override void Calculate(int index)
        {
        }
    }
}

The above code only works for past bars, not future, the best way is to use Time instead of Bars index.

 


@amusleh

amusleh
24 Jul 2021, 11:15

RE: RE:

yaghouti said:

Hi again

just one more problem.

i try to use this linePriceValue in for my stoploss:

position.ModifyStopLossPrice(Math.Round(DefaultSTL,Symbol.Digits)); or position.ModifyStopLossPrice(DefaultSTL);

but unfortunately i get the error:

23/07/2021 18:50:48.947 | → Modifying position PID17057357 (SL: 1.17751257895653, TP: 1.17541361298747) FAILED with error "InvalidStopLossTakeProfit", Position PID17057357

i print the linePriceValue and the printed value is OK but when i try to assign it to my position stoploss i get the error.

 

amusleh said:

Hi,

You can draw an interactive chart trend line and then whenever the user changed it you can use the chart objects updated event.

 

Hi,

Can you post the full code of your cBot, please?


@amusleh

amusleh
24 Jul 2021, 11:12

Hi,

Try to set the vertical line IsInteractive property to True.


@amusleh

amusleh
23 Jul 2021, 15:24

Hi,

You can draw an interactive chart trend line and then whenever the user changed it you can use the chart objects updated event.


@amusleh