Replies

PanagiotisCharalampous
16 Oct 2017, 08:56

Hi ctid331981,

Thanks for posting in our forum. You should use the userID found in the Profile request e.g. https://sandbox-api.spotware.com/connect/profile?oauth_token=test002_access_token 

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Oct 2017, 15:55

Hi ycomp,

You need to contact your broker to add more funds to your demo account.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Oct 2017, 15:48

Hi ycomp.

TIMEOUT_ERROR is sent in the exceptional case our server does not respond within a specified time period.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Oct 2017, 15:34

Hi EmperorCy,

Thanks for posting in our forum. It is not clear what you mean when you say " i must make a source with apis?". However, from what I understand from your description, what you want to do is possible in a cBot. See an example below

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 NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
        protected override void OnStart()
        {
        }

        protected override void OnBar()
        {
            if ( MarketSeries.Close.Last(1) < 1.09)
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000);
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

This example executes a market order when the close value of the previous candle is lower than 1.09.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Oct 2017, 15:18

Hi hungtonydang,

Did you locate which variable becomes null and you  get a NullReferenceException? If yes, just use and if statement and check if the variable is null before accessing it.

Best Regards,

Panagiotis

 


@PanagiotisCharalampous

PanagiotisCharalampous
13 Oct 2017, 15:07

Hi hungtonydang,

How about the following?

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 NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
        private DateTime _date;
        protected override void OnStart()
        {
            _date = new DateTime(2017, 10, 9, 11, 30, 0);
        }

        protected override void OnBar()
        {
            if (_date.Day != DateTime.Now.Day)
                _date = _date.AddDays(1);
            var close = MarketSeries.Close[MarketSeries.OpenTime.GetIndexByExactTime(_date)];
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiots


@PanagiotisCharalampous

PanagiotisCharalampous
13 Oct 2017, 09:19

Hi mariuszpawel33,

Indeed TP and SL are not available through FIX API. See the following discussion. It might be helpful for you.

/forum/fix-api/11964?page=1#6

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Oct 2017, 09:15 ( Updated at: 21 Dec 2023, 09:20 )

Hi share.axp,

You can view you selected account in the top left of cTrader. See below

Let me know if this is what you are looking for.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 17:51

No that should not be the reason. How many positions do you have open and how many are getting closed in a tick?


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 17:30

Hi ycomp,

You can find this information in the ProtoOAOrder message of the ProtoOAExecutionEvent. Check the executionPrice field.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 17:09

Hi David,

Why do you believe the execution is slow?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 16:59

Hi David,

Use the code below

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 SamplecBot: Robot
    {       
        [Parameter("Min TP")]
        public double MinTP { get; set; }
        [Parameter("Max TP")]
        public double MaxTP { get; set; }   
 
        protected override void OnTick()
        {
            foreach (var position in Positions)
            {
                if (position.Pips > MinTP && position.Pips < MaxTP)
                {
                    ClosePosition(position);
                }
            }
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 16:43

RE: RE:

davideng5555 said:

Hi Panagiotis,

How to make your script into a stand alone robot.

-------------------------------------------------------------

                if (position.Pips > MinTP && position.Pips < MaxTP)

                {

                    ClosePosition(position);

                }

Thank you very much, I tried without success.

Best Regards

David

 

 

 

Hi David,

You cannot make the specific script a stand alone cBot. It needs to be a part of a Robot class. Maybe you could elaborate on what you want to achieve?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 16:41

RE: RE:

davideng5555 said:

Hi Panagiotis,

What to do when trying to edit a robot, and there is only this message.

'Source code is not available.'

Thank you very much

David.

 

This means that the cBot's creator did not provide the source code therefore you cannot edit the cBot


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 14:55

Hi davideng5555,

Here it is :)

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 MULTIMARKETORDER : Robot
    {
        [Parameter("Lot Size", DefaultValue = 0.01)]
        public double lot { get; set; }
        [Parameter("Positions nr.", DefaultValue = 100)]
        public int nr { get; set; }
        [Parameter("Buy ?")]
        public bool buy { get; set; }
        [Parameter("Sell ?")]
        public bool sell { get; set; }
        [Parameter("Min TP")]
        public double MinTP { get; set; }
        [Parameter("Max TP")]
        public double MaxTP { get; set; }
        protected override void OnStart()
        {
            long volume = Symbol.QuantityToVolume(lot);
            if (buy)
            {
                for (int i = 0; i < nr; i++)
                    ExecuteMarketOrder(TradeType.Buy, Symbol, volume);
            }
            if (sell)
            {
                for (int i = 0; i < nr; i++)
                    ExecuteMarketOrder(TradeType.Sell, Symbol, volume);
            }
        }

        protected override void OnBar()
        {
            foreach (var position in Positions)
            {
                if (position.Pips > MinTP && position.Pips < MaxTP)
                {
                    ClosePosition(position);
                }
            }
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 14:39

Hi

It depends where you want to make the check. If you want to make it on each candlestick change, try the following

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 MULTIMARKETORDER : Robot
    {
        [Parameter("Lot Size", DefaultValue = 0.01)]
        public double lot { get; set; }
        [Parameter("Positions nr.", DefaultValue = 100)]
        public int nr { get; set; }
        [Parameter("Buy ?")]
        public bool buy { get; set; }
        [Parameter("Sell ?")]
        public bool sell { get; set; }
        protected override void OnStart()
        {
            long volume = Symbol.QuantityToVolume(lot);
            if (buy)
            {
                for (int i = 0; i < nr; i++)
                    ExecuteMarketOrder(TradeType.Buy, Symbol, volume);
            }
            if (sell)
            {
                for (int i = 0; i < nr; i++)
                    ExecuteMarketOrder(TradeType.Sell, Symbol, volume);
            }
        }

        protected override void OnBar()
        {
            foreach (var position in Positions)
            {
                if (position.Pips > 5 && position.Pips < 20)
                {
                    ClosePosition(position);
                }
            }
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 14:05

Hi davideng5555,

Try the following condition

                if (position.Pips > 5 && position.Pips < 20)
                {
                    ClosePosition(position);
                }

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Oct 2017, 09:23

Hi anjupeguforex@gmail.com,

You get this exception because you are trying to access an array item that does not exist. Before accessing a position in Positions using index You should always check that the index is within the range of the array. I propose to change checks like the following 

            if (poz[1] != null)

to

            if (poz.Length > 1)

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
11 Oct 2017, 17:50

Hi zabarmel,

Thanks for the video. We tried this but we cannot reproduce it. We will forward it to the development team to investigate it further.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
11 Oct 2017, 15:48

Hi ycomp,

No nothing else has been depreciated. It is in our plans to inform you about all future Connect API changes via email. You can also check the Announcements section where we will put the relevant announcements.

Best Regards,

Panagiotis


@PanagiotisCharalampous