Topics
16 Nov 2023, 07:42
 1170
 1
15 Nov 2023, 10:36
 2069
 16
Replies

Spotware
03 Aug 2017, 09:07

Dear YuriiZelinskyi,

We have checked Connect API authentication and we could not see any obvious problem with it. Could you please contact myfxbook.com as well in case there is any issue on their side?

Best Regards,

cTrader Team


@Spotware

Spotware
02 Aug 2017, 17:24

Hi alpha_austin,

As we mentioned above, we are happy to answer questions about cAlgo and give some guidelines but we cannot engage into developing cBots on demand. If you need professional assistance in developing your cBot you might contact a consultant or post a job in our jobs page.

Best Regards,

cTrader Team


@Spotware

Spotware
02 Aug 2017, 14:33

Hi alpha_austin,

"and at the smae time I wanna place the mentioned limit orders OF THE SAME DIRECTION OF THE MARKET ORDER,"

You can use the tradeType variable when placing your limit orders so that they are on the same direction as your market order. 

then once either trade TP (or gross profit > 0), return to the initial position of opening a new random market order.

You can call your ExecuteOrder() function again within the PositionClosed function

Best Regards,

cTrader Team


@Spotware

Spotware
02 Aug 2017, 11:45

Hi alpha_austin,

To achieve this you need to modify your code so that it handles the Positions.Closed event. You need to do the following changes

  1. Add an event handler in OnStart() method
  2. In the event handler check if the closed position has been closed with a profit.
  3. If yes, close all the remaining open positions.
  4. Execute a new market order.

The code should be modified as follows

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SampleRSIcBot : Robot
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

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

        [Parameter("Volume", DefaultValue = 10000)]
        public double Quantity { get; set; }

        private RelativeStrengthIndex rsi;

        protected override void OnStart()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, Periods);
            Positions.Closed += OnPositionsClosed;
        }

        void OnPositionsClosed(PositionClosedEventArgs obj)
        {
            if (obj.Position.NetProfit > 0)
            {
                foreach (var position in Positions)
                {
                    ClosePosition(position);
                }
                ExecuteMarketOrder(obj.Position.TradeType, Symbol, 10000, "New market order", 40, 10);
            }           
        }

        protected override void OnTick()
        {
            if (rsi.Result.LastValue > 70)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, 10000, "Sell", 40, 10);

                PlaceLimitOrder(TradeType.Sell, Symbol, 10000, Symbol.Bid + 10 * Symbol.PipSize, "Sell + 10", 30, 10);

                PlaceLimitOrder(TradeType.Sell, Symbol, 20000, Symbol.Bid + 20 * Symbol.PipSize, "Sell + 20", 20, 10);

                PlaceLimitOrder(TradeType.Sell, Symbol, 40000, Symbol.Bid + 30 * Symbol.PipSize, "Sell + 30", 10, 10);
            }


            else if (rsi.Result.LastValue < 30)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "Buy", 40, 10);

                PlaceLimitOrder(TradeType.Buy, Symbol, 10000, Symbol.Ask + 10 * Symbol.PipSize, "Buy + 10", 30, 10);

                PlaceLimitOrder(TradeType.Buy, Symbol, 20000, Symbol.Ask + 20 * Symbol.PipSize, "Buy + 20", 20, 10);

                PlaceLimitOrder(TradeType.Buy, Symbol, 40000, Symbol.Ask + 30 * Symbol.PipSize, "Buy + 30", 10, 10);
            }
        }

    }
}

Best Regards,

cTrader Team


@Spotware

Spotware
02 Aug 2017, 09:29

Dear ivan-rifo,

See below a code sample on how split your active orders into two lists of Buy and Sell orders.

            var listSellOrders = new List<PendingOrder>();
            var listBuyOrders = new List<PendingOrder>();
            foreach (var order in PendingOrders)
            {
                if (order.TradeType == TradeType.Sell)
                    listSellOrders.Add(order);
                else
                    listBuyOrders.Add(order);
            }

In order to use the List class you need to reference  System.Collections.Generic namespace. See below

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

Regarding the comparison, which attribute of the two lists would you like to compare?

Best Regards,

cTrader Team


@Spotware

Spotware
02 Aug 2017, 09:07

Dear acrigney,

You should modify the vsixmanifest by adding the node for the VS2107 edition. The edition version is 15.1. See the following example

<?xml version="1.0" encoding="utf-8"?>

<Vsix Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010">
  <Identifier Id="2c72cc50-6c69-4b16-b1f4-ab470673f284">
    <Name>cBots and Custom Indicators</Name>
    <Author>Spotware</Author>
    <Version>1.4</Version>
    <License>EULA.txt</License>
    <Description xml:space="preserve">Building cBots and Custom Indicators in Visual Studio</Description>
    <Locale>1033</Locale>
    <InstalledByMsi>false</InstalledByMsi>
    <SupportedProducts>
      <VisualStudio Version="10.0">
        <Edition>Pro</Edition>
      </VisualStudio>
      <VisualStudio Version="11.0">
        <Edition>Pro</Edition>
      </VisualStudio>
      <VisualStudio Version="12.0">
        <Edition>Pro</Edition>
      </VisualStudio>
<VisualStudio Version="13.0">
  <Edition>Community</Edition>
</VisualStudio>
<VisualStudio Version="14.0">
  <Edition>Community</Edition>
</VisualStudio>
<VisualStudio Version="15.0">
  <Edition>Community</Edition>
</VisualStudio>
<VisualStudio Version="15.1">
  <Edition>Community</Edition>
</VisualStudio>
    </SupportedProducts>
    <SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.0" />
  </Identifier>
  <References>
    <Reference Id="Microsoft.VisualStudio.MPF" MinVersion="10.0">
      <Name>Visual Studio MPF</Name>
    </Reference>
  </References>
  <Content>
    <VsPackage>VSExtension.pkgdef</VsPackage>
  </Content>
</Vsix>

Best Regards,

cTrader Team


@Spotware

Spotware
01 Aug 2017, 12:00

Hi alpha_austin,

We have modified the code so that it builds but we think that it does not do exactly what you intend it to do. Nevertheless, you can use the code below as a basis to continue your development.

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SampleRSIcBot : Robot
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

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

        [Parameter("Volume", DefaultValue = 10000)]
        public double Quantity { get; set; }

        private RelativeStrengthIndex rsi;

        protected override void OnStart()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, Periods);
        }

        protected override void OnTick()
        {
            if (rsi.Result.LastValue > 70)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, 10000, "Sell", 40, 10);

                PlaceLimitOrder(TradeType.Sell, Symbol, 10000, Symbol.Bid + 10 * Symbol.PipSize, "Sell + 10", 30, 10);

                PlaceLimitOrder(TradeType.Sell, Symbol, 20000, Symbol.Bid + 20 * Symbol.PipSize, "Sell + 20", 20, 10);

                PlaceLimitOrder(TradeType.Sell, Symbol, 40000, Symbol.Bid + 30 * Symbol.PipSize, "Sell + 30", 10, 10);
            }


            else if (rsi.Result.LastValue < 30)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "Buy", 40, 10);

                PlaceLimitOrder(TradeType.Buy, Symbol, 10000, Symbol.Ask + 10 * Symbol.PipSize, "Buy + 10", 30, 10);

                PlaceLimitOrder(TradeType.Buy, Symbol, 20000, Symbol.Ask + 20 * Symbol.PipSize, "Buy + 20", 20, 10);

                PlaceLimitOrder(TradeType.Buy, Symbol, 40000, Symbol.Ask + 30 * Symbol.PipSize, "Buy + 30", 10, 10);
            }
        }

    }
}

Best Regards,

cTrader Team


@Spotware

Spotware
01 Aug 2017, 10:18

Hi alpha_austin,

Thanks for posting in our forum. We can help you developing your cBot by answering specific questions related to cAlgo.API and C# programming, as well as by providing small code snippets demonstrating how to implement certain functions. However we cannot engage into developing cBots on demand or debugging complicated cBots.

Best Regards,
cTrader Team


@Spotware

Spotware
01 Aug 2017, 09:39

Hi ivan-rifo,

The problem is that in the loop you use NE as your array's index, which is always 0. Therefore the values are always assigned to N_array[0]. In the loop you need use i for the array's index and then introduce another variable that will start at 1.16660 will increase by 0.00001 in each loop. Let us know if you need any further assistance.

Best Regards,

cTrader Team 


@Spotware

Spotware
31 Jul 2017, 13:03

Dear thearrymail-ct,

In brief, a stop limit order is triggered as a stop order and executed as a limit order. Therefore, when the direction of the stop limit order is Sell it is triggered when the price crosses the stop price in a downwards direction. On the opposite side, when the direction of the stop limit order is Buy it is triggered when the price crosses the stop price in a upwards direction.

The change applied the previous week had to do with the order's duration. The duration was changed from Good Till Cancelled to Immediate or Cancel. The order's duration is not conflicting with the order type.

Regarding your comment 

" it didn't act as a sell limit after trigger price was reached"

Stop limit order does not act like limit order after triggering, it is only executed as Limit order. If not executed, It will continue to act like a Stop Limit order, which is an extension of the Stop Order. Acting as Limit order means the order needs to be triggered when the price satisfies the limit price. But acting as as Stop order (and Stop Limit order) means it is going to be triggered when the price satisfies the stop price.

Concluding, Stop Limit order is an extension of the Stop Order that allows a more accurate execution of the order.

We hope that the above clarifies the way that Stop Limit orders behave.

Best Regards,

cTrader Team,


@Spotware

Spotware
31 Jul 2017, 12:49

Hi andi21,

Thanks for noticing this, we have reported this issue so it can be fixed. 

Best Regards,

cTrader Team


@Spotware

Spotware
31 Jul 2017, 12:00 ( Updated at: 21 Dec 2023, 09:20 )

Dear Trader,

Thanks for your question. cTrader can handle more than 400 positions simultaneously without a problem. But due to the fact that cTrader is has a rich UI, much richer when compared to other platforms, it might become slow when a lot of information that needs to be updated in real time is displayed on the chart. We are working on improving the performance of this part of cTrader.

In the meanwhile, in case you want to open a large number of positions in cTrader e.g. more than 400, we advise that you first hide positions and the deal map from the chart. In order to do so, right click on the chart, go to Viewing Options and uncheck Positions. See image below

Best Regards,

cTrader Team


@Spotware

Spotware
31 Jul 2017, 11:33

Hi lec0456,

Thanks for reporting this issue to us. We will investigate and resolve if needed in one of the future updates.

Best Regards,

cTrader Team


@Spotware

Spotware
31 Jul 2017, 10:39

Dear Trader,

Thanks for your question. You can use cTrader Web on Apple Mac and Safari. Currently, there are no immediate plans for a desktop application for Mac. In case we release a cTrader application for Mac, we will inform you accordingly. 

Best Regards,

cTrader Team


@Spotware

Spotware
31 Jul 2017, 10:17

Dear croucrou,

Thanks for your post. Currently this is not possible. We will forward your suggestion for consideration.

Best Regards,

cTrader Team


@Spotware

Spotware
31 Jul 2017, 09:39

Dear .ics.

Thanks for your question. Please see the relevant answer in the discussion here.

Best Regards, 

cTrader Team


@Spotware

Spotware
28 Jul 2017, 14:22

Dear MaVe,

Thanks for reporting this behavior. We will investigate and check with the product team if this behavior can change in one of the future releases.

Best Regards,

cTrader Team


@Spotware

Spotware
28 Jul 2017, 11:45

Dear lec0456,

Thanks for posting your suggestion. We have forwarded your proposal to the product team for consideration in one of the future releases of cTrader. We will keep you updated.

Best Regards,

cTrader Team


@Spotware

Spotware
28 Jul 2017, 09:27

Dear rayscluster,

Indeed the problem might be caused by your network connection. We are currently working to optimize downloading and uploading of workspaces. Hopefully you should see improvements in download speed in future releases of cTrader.

Best Regards,

cTrader Team


@Spotware

Spotware
28 Jul 2017, 09:22

Dear ivan-rifo

.Net Framework has a List class that will allow you to implement what you need. See below an example of how you can add your positions in a list and order them by EntryPrice in a descending order

protected override void OnTick()
        {
            var positionList = new List<Position>();
            foreach (var position in Positions)
            {
                positionList.Add(position);
            }
            var orderedList = positionList.OrderByDescending(x => x.EntryPrice);
        }

In order to use lists you will need to reference System.Collections.Generic namespace. See below an example

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

Let us know if the above information is helpful to you.

Best Regards,

cTrader Team


@Spotware