Topics

Forum Topics not found

Replies

amusleh
23 May 2022, 09:07

Hi,

You don't have to use FindAll method of Positions, you use it only when you want to filter the positions based on a label.

Change your code to:

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

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.FullAccess)]
    public class NewcBot3 : Robot
    {
        protected override void OnStart()
        {
            Print("Started Bot...");
        //    ExecuteMarketOrder(TradeType.Buy, SymbolName, 0.01, "");
        //    ExecuteMarketOrder(TradeType.Buy, SymbolName, 0.03, "");
        }

        protected override void OnBar()
        {
            Print("onBar Executed on.. " + Chart.TimeFrame);

            Print("Positions Length=" + Positions.Count);
            foreach (var position in Positions)
            {
                if (position.SymbolName != SymbolName) continue;
                Print("Position Entry Time=" + position.EntryTime);
                //   if (position.VolumeInUnits >= 0.02)
                //   {
                ClosePosition(position);
                //   }
            }
        }
    }
}

 


@amusleh

amusleh
23 May 2022, 09:03

Hi,

Where you get that error message? from 2calgo.com site? we don't support that service anymore.

If you want to convert another platform indicator/robot to cTrader post a job request on our jobs page or contact one of our consultant partners.

 


@amusleh

amusleh
23 May 2022, 09:00

RE: RE: RE:

fcarabat said:

algotrader said:

forexner12 said:

I have tried but not succesful 

Now your indicator is supported by 2calgo.com. Please try to convert it one more time.

 

I know this is a super old post, but i'm trying to convert the same sweetspots indicator with this page you mentioned, but it gives me back an error.  not sure what i'm doing wrong, i just copy and pasted the code.  any help would be greatly appreciated.

Hi,

You can post a job request on our jobs page or contact one of our consultant partners.


@amusleh

amusleh
23 May 2022, 08:59

Hi,

Please use suggestions section, create a thread there for your suggestion.


@amusleh

amusleh
23 May 2022, 08:58

Hi,

This is a great idea, can you create a thread for it under suggestions section so user will be able to vote for it.


@amusleh

amusleh
23 May 2022, 08:57 ( Updated at: 23 May 2022, 08:58 )

RE: Display Date Pro issue

notoriousocean said:

Hey there!

 

I bought your display date pro, and installed it. It only displays the date and time but not the vertical lines as shown in the video. how can i get it to show the lines? 

Hi,

Not sure what you are talking about, please contact the company you bought the product from.

And don't post on threads that aren't related to your issue.


@amusleh

amusleh
23 May 2022, 08:56

Hi,

There is no GetIndexByTime method for Ticks series, because several ticks can occur per second and it's hard to match them against a fixed time, but if you want to you can create your own as an extension method to Ticks:

using System;
using cAlgo.API;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None)]
    public class NewIndicator2 : Indicator
    {
        protected override void Initialize()
        {
            var ticks = MarketData.GetTicks();

            var index = ticks.GetIndexByTime(Bars.OpenTimes.LastValue);

            Print(index);
        }

        public override void Calculate(int index)
        {
        }
    }

    public static class TickGetIndexByTimeExtension
    {
        public static int GetIndexByTime(this Ticks ticks, DateTime time)
        {
            for (var i = 0; i < ticks.Count; i++)
            {
                if (ticks[i].Time == time)
                {
                    return i;
                }
            }

            return -1;
        }
    }
}

 


@amusleh

amusleh
23 May 2022, 08:49

RE:

swapd0 said:

After reading this post I've changed my multi-register routine to send several subscribe messages, each one for each symbol but I only get quotes from the first one.

By the way, I'm using different values for MDReqID on each request (reqId1, reqId5, reqId7...), not sure if this is right.

What I'm doing wrong?

Edited: Using the same value for MDReqID I get quotes from two symbols, although I've subscribed for 24...

 

Here are my request messages

OUT: 8=FIX.4.4|9=144|35=V|34=5|49=live.icmarkets.****|50=******|52=20220520-19:21:27.018|57=QUOTE|56=cServer|262=reqId1|263=1|264=1|267=2|269=0|269=1|146=1|55=1|10=149|

OUT: 8=FIX.4.4|9=410|35=V|34=7|49=live.icmarkets.*****50=******|52=20220520-19:21:53.622|57=QUOTE|56=cServer|262=reqId5|263=1|264=1|267=2|269=0|269=1|146=1|55=14|10=203|

 

OUT: 8=FIX.4.4|9=152|35=V|34=9|49=live.icmarkets.*****50=******|52=20220520-19:21:53.788|57=QUOTE|56=cServer|262=reqId7|263=1|264=1|267=2|269=0|269=1|146=1|55=17|10=226|

And here are the quotes, I only got from EURUSD(1)

IN:8=FIX.4.4|9=141|35=W|34=301|49=cServer|50=QUOTE|52=20220520-17:24:51.269|56=live.icmarkets.****|57=****|55=1|268=2|269=0|270=1.05502|269=1|270=1.05502|10=064|

IN:8=FIX.4.4|9=141|35=W|34=302|49=cServer|50=QUOTE|52=20220520-17:24:51.804|56=live.icmarkets.****|57=****|55=1|268=2|269=0|270=1.05503|269=1|270=1.05503|10=062|

IN:8=FIX.4.4|9=141|35=W|34=303|49=cServer|50=QUOTE|52=20220520-17:24:52.774|56=live.icmarkets.****|57=****|55=1|268=2|269=0|270=1.05502|269=1|270=1.05502|10=068|

IN:8=FIX.4.4|9=137|35=W|34=304|49=cServer|50=QUOTE|52=20220520-17:24:52.974|56=live.icmarkets.****|57=****|55=1|268=2|269=0|270=1.055|269=1|270=1.055|10=136|

IN:8=FIX.4.4|9=141|35=W|34=305|49=cServer|50=QUOTE|52=20220520-17:24:53.182|56=live.icmarkets.****|57=****|55=1|268=2|269=0|270=1.05499|269=1|270=1.05499|10=094|

IN:8=FIX.4.4|9=141|35=W|34=306|49=cServer|50=QUOTE|52=20220520-17:24:53.410|56=live.icmarkets.****|57=****|55=1|268=2|269=0|270=1.05498|269=1|270=1.05498|10=087|

IN:8=FIX.4.4|9=141|35=W|34=307|49=cServer|50=QUOTE|52=20220520-17:24:54.457|56=live.icmarkets.****|57=*****|55=1|268=2|269=0|270=1.05497|269=1|270=1.05497|10=098|

 

Hi,

I just tested by subscribing to multiple symbols and I received quotes from all of them.

I used our QuickFIX console sample: spotware/quickfixnsamples.net: .NET Samples for QuickFIXn library and Spotware FIX API (github.com)

Change the SendMarketDataRequest method on console sample program.cs to:

        private static void SendMarketDataRequest(string[] fields, bool subscribe)
        {
            foreach (var symbolId in Enumerable.Range(0, 10))
            {
                MDReqID mdReqID = new("MARKETDATAID");
                SubscriptionRequestType subType = new(subscribe ? '1' : '2');
                MarketDepth marketDepth = new(fields[1].ToLowerInvariant().Equals("y", StringComparison.OrdinalIgnoreCase) ? 0 : 1);

                QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup bidMarketDataEntryGroup = new() { MDEntryType = new MDEntryType('0') };
                QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup offerMarketDataEntryGroup = new() { MDEntryType = new MDEntryType('1') };

                //QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup symbolGroup = new() { Symbol = new Symbol(fields[0]), };
                QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup symbolGroup = new() { Symbol = new Symbol(symbolId.ToString()), };

                QuickFix.FIX44.MarketDataRequest message = new(mdReqID, subType, marketDepth);

                message.AddGroup(bidMarketDataEntryGroup);
                message.AddGroup(offerMarketDataEntryGroup);
                message.AddGroup(symbolGroup);

                _application.SendMessage(message);
            }
        }

Now instead of sending a single request it sends 10 request for 10 symbols.


@amusleh

amusleh
23 May 2022, 08:38

RE:

toddslagowski06 said:

Well, that's a piece of bad news for me. Actually, I don't understand why the developers just don't create such a feature.

Hi,

It's a third party data, if you want to use their data on your cBots/Indicators then you can contact them and ask them to give you access to their API.


@amusleh

amusleh
23 May 2022, 08:36

Hi,

We checked and tested everything, we tried on Windows 10 Enterprise x64, but we were not able to reproduce the issue.


@amusleh

amusleh
23 May 2022, 08:35

Hi,

You have to contact your broker.


@amusleh

amusleh
20 May 2022, 10:37

Hi,

No it's not possible on current multi chart mode, what you can do is create separate detached chart windows and divide your screen to three equal separate columns by using Windows screen partitioner:

 


@amusleh

amusleh
20 May 2022, 10:23

RE: RE:

aidanfrankgriffiths said:

Where would I find that?

 

Hi,

Contact your cBot developer, and ask them to fix the issue, they have the source code.


@amusleh

amusleh
20 May 2022, 10:22

Hi,

There is no such functionality on Automate API, but you can use other third part services like Telegram.


@amusleh

amusleh
20 May 2022, 10:20 ( Updated at: 21 Dec 2023, 09:22 )

Hi,

The lines are discontinuous:

Discontinuous outputs can have empty or NAN values, and those NAN values will not be displayed on the chart.


@amusleh

amusleh
20 May 2022, 08:02

Hi,

By commenting I mean remove that line of code by making it a comment, ex:

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

namespace cAlgo
{
    [Indicator("Support and Resistance At Price", IsOverlay = true, AccessRights = AccessRights.None)]
    public class SRAtPrice : Indicator
    {
        private double extremeHigh = 0;
        private double extremeLow = 0;
        private double dayHi = 0;
        private double dayLo = 0;
        private SortedList<double, int> prices = new SortedList<double, int>();
        private IList<Zone> zones = new List<Zone>();

        private const string ExtremeHighName = "ExtremeHigh";
        private const string ExtremeLowName = "ExtremeLow";
        private const string DayHighName = "DayHigh";
        private const string DayLowName = "DayLow";

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

        [Parameter("Show Extreme H/L", DefaultValue = true)]
        public bool ShowExtremeHL { get; set; }

        [Parameter("Show Day H/L", DefaultValue = true)]
        public bool ShowDayHL { get; set; }

        [Parameter("Required Hits", DefaultValue = 0)]
        public int RequiredHits { get; set; }

        [Parameter("Zone Size", DefaultValue = 2)]
        public int ZoneSize { get; set; }

        [Parameter("Max Lines In Zone", DefaultValue = 1)]
        public int MaxLinesInZone { get; set; }

        [Output("Extreme H/L Style", Color = Colors.Red, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries ExtremeHLStyle { get; set; }

        [Output("Day H/L Style", Color = Colors.Blue, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries DayHLStyle { get; set; }

        [Output("S/R Style", Color = Colors.Orange, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries SRStyle { get; set; }

        public override void Calculate(int index)
        {
            if (this.IsLastBar)
            {
                var currentOpenDate = this.MarketSeries.OpenTime[index].Date;
                var earliest = index - this.Periods;
                for (var i = index; i >= earliest; i--)
                {
                    if (i >= 0)
                    {
                        var high = this.MarketSeries.High[i];
                        var nextHigh = this.MarketSeries.High[i + 1];
                        var low = this.MarketSeries.Low[i];
                        var nextLow = this.MarketSeries.Low[i + 1];
                        this.extremeHigh = Math.Max(high, this.extremeHigh);
                        this.extremeLow = this.extremeLow == 0 ? low : Math.Min(low, this.extremeLow);

                        if (this.TimeFrame < TimeFrame.Minute)
                        {
                            if (this.MarketSeries.OpenTime[i].Date == currentOpenDate)
                            {
                                this.dayHi = Math.Max(high, this.dayHi);
                                this.dayLo = this.dayLo == 0 ? low : Math.Min(low, this.dayLo);
                            }
                        }

                        if (nextHigh <= high)
                        {
                            this.AddOrUpdatePrice(high);
                        }

                        if (nextLow >= low)
                        {
                            this.AddOrUpdatePrice(low);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                this.zones.Clear();
                var rangePipSize = (this.Symbol.PipSize * (double)this.ZoneSize);
                for (var i = this.extremeLow + rangePipSize; i < this.extremeHigh - rangePipSize; i += rangePipSize + this.Symbol.PipSize)
                {
                    this.zones.Add(new Zone 
                    {
                        Start = i,
                        End = i + rangePipSize,
                        LinesRendered = 0
                    });
                }

                //this.ChartObjects.RemoveAllObjects();

                foreach (var price in this.prices.Keys)
                {
                    this.RenderSRIfRequred(price, this.prices[price]);
                }

                if (this.ShowExtremeHL)
                {
                    this.DrawExtremeHigh();
                    this.DrawExtremeLow();
                }

                if (this.TimeFrame < TimeFrame.Minute && this.ShowDayHL)
                {
                    this.DrawDayHigh();
                    this.DrawDayLow();
                }
            }
        }

        private void RenderSRIfRequred(double price, int count)
        {
            if (count < this.RequiredHits)
            {
                return;
            }

            foreach (var range in this.zones)
            {
                if (price >= range.Start && price <= range.End)
                {
                    if (range.LinesRendered != this.MaxLinesInZone)
                    {
                        range.LinesRendered++;
                        this.DrawSR(price);
                    }
                    return;
                }
            }
        }

        private void AddOrUpdatePrice(double priceValue)
        {
            if (this.prices.ContainsKey(priceValue))
            {
                this.prices[priceValue]++;
            }
            else
            {
                this.prices.Add(priceValue, 1);
            }
        }

        private void DrawExtremeHigh()
        {
            this.DrawExtreme(ExtremeHighName, this.extremeHigh);
        }

        private void DrawExtremeLow()
        {
            this.DrawExtreme(ExtremeLowName, this.extremeLow);
        }

        private void DrawDayHigh()
        {
            this.DrawDay(DayHighName, this.dayHi);
        }

        private void DrawDayLow()
        {
            this.DrawDay(DayLowName, this.dayLo);
        }

        private void DrawExtreme(string name, double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("ExtremeHLStyle");
            this.ChartObjects.DrawHorizontalLine(name, level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private void DrawDay(string name, double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("DayHLStyle");
            this.ChartObjects.DrawHorizontalLine(name, level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private void DrawSR(double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("SRStyle");
            this.ChartObjects.DrawHorizontalLine(string.Format("SR {0}", level), level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private T GetAttributeFrom<T>(string propertyName)
        {
            var attrType = typeof(T);
            var property = this.GetType().GetProperty(propertyName);
            return (T)property.GetCustomAttributes(attrType, false).GetValue(0);
        }

        private class Price
        {
            internal double Value { get; set; }
            internal int Count { get; set; }
        }

        private class Zone
        {
            internal double Start { get; set; }
            internal double End { get; set; }
            internal int LinesRendered { get; set; }
        }
    }
}

 


@amusleh

amusleh
19 May 2022, 14:54 ( Updated at: 21 Dec 2023, 09:22 )

Hi,

Check the Automate Tab:


@amusleh

amusleh
19 May 2022, 14:45

RE: RE: downgrade

dokinya said:

amusleh said:

Hi,

We were able to reproduce the issue with your indicator, we are investigating now what's causing it, please be patient and wait for our reply.

 

is there anyway i can downgrade the platform? 

Hi,

There is no way to downgrade, for this particular indicator you can comment the "this.ChartObjects.RemoveAllObjects();" line and it will work on version 4.2.


@amusleh

amusleh
19 May 2022, 09:56

Hi,

We were able to reproduce the issue with your indicator, we are investigating now what's causing it, please be patient and wait for our reply.

 


@amusleh

amusleh
19 May 2022, 09:34

Hi,

It depends on your email server that how many emails it allows you to send on a unit of time (seconds/milliseconds).

To avoid this issue you can place a delay after sending the first email, use Thread.Sleep, example:

            try
            {
                Notifications.SendEmail(EmailAddress1, EmailAddress1, "cTrader 5 Wick Alert", emailmsg);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Invalid email address", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (EmailAddress2 != "")
            {
                // 2 seconds delay
                Thread.Sleep(2000);
                // Call refresh data is required after suspending the main thread
                RefreshData();
                
                try
                {
                    Notifications.SendEmail(EmailAddress1, EmailAddress2, "cTrader 5 Wick Alert", emailmsg);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Invalid email address", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

 


@amusleh