Topics

Forum Topics not found

Replies

amusleh
11 Jan 2022, 08:32

Hi,

Each instance of a cBot runs separate from others, one can't have any effect on other running cBots.

Most probably something is wrong with your cBot code, and its not related to running multiple instances.

You should use unique labels for each of your running cBot instances, and use it to only manage the positions and orders that were opened by that instance.

Please post your cBot code then we will be able to help you.

Regarding debugging multiple running instances, right now there is no feasible way to do this.


@amusleh

amusleh
10 Jan 2022, 16:57

RE: RE:

heinrich.munz said:

amusleh said:

Hi,

Sorry, I misunderstood you, I thought you want to get the current back test time on a cBot.

The close time of a bar is the open time of next bar, so there is no need for an extra data collection.

For indicators, the calculate method is called once for each historical bar, and then it's called for each tick.

So for indicators if you call the Server.Time during historical bars it should return the current time not the time of that bar, and that's the correct behavior not a bug.

>>>"The close time of a bar is the open time of next bar" 
Yes, this is true for historical bars, but not for the Last Bar (when IsLastBar == true). If I have set a time frame of lets say 1 hour, there is a time delay of max. 1 hour until I get the current time.  

>>>and then it's called for each tick.
Exactly! And I just need the accurate time of this "each tick". 

So again my question:
How do I get the accurate current back test time on an indicator for each tick after IsLastBar == true which is Corresponding to Bars.ClosePrices[index]???

 

Hi,

This issue will be resolved in cTrader 4.2.


@amusleh

amusleh
10 Jan 2022, 15:00

Hi,

Sorry, I misunderstood you, I thought you want to get the current back test time on a cBot.

The close time of a bar is the open time of next bar, so there is no need for an extra data collection.

For indicators, the calculate method is called once for each historical bar, and then it's called for each tick.

So for indicators if you call the Server.Time during historical bars it should return the current time not the time of that bar, and that's the correct behavior not a bug.


@amusleh

amusleh
10 Jan 2022, 11:09

Hi,

I just tested with our QuickFIX console sample and it didn't got disconnected at all after waiting for more than an hour.


@amusleh

amusleh
10 Jan 2022, 08:36

RE: Can I backtest strategy with daily data?

duongphuongtrinh92 said:

Hi Spotware,

I would like to backtest a swing trading strategy using Daily Close Price. And the problem is I do not have 1-minute data csv file, I only have daily data. Can I backtest the strategy using this daily csv file?

No, you can't.

You can only import M1 bars data or use the server data.


@amusleh

amusleh
10 Jan 2022, 08:35

Hi,

Try this:

using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

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

        private RelativeStrengthIndex diffRSI;

        private IndicatorDataSeries nasdow;

        private Bars _nasdaqSeries, _dowjonesSeries;

        protected override void OnStart()
        {
            _nasdaqSeries = MarketData.GetBars(TimeFrame, "US TECH 100");
            _dowjonesSeries = MarketData.GetBars(TimeFrame, "US 30");

            nasdow = CreateDataSeries();

            diffRSI = Indicators.RelativeStrengthIndex(nasdow, Periods);
        }

        protected override void OnTick()
        {
            var index = Bars.Count - 1;

            var dowjonesSeriesIndex = _dowjonesSeries.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
            var nasdaqSeriesIndex = _nasdaqSeries.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);

            nasdow[index] = _dowjonesSeries.ClosePrices[dowjonesSeriesIndex] - _nasdaqSeries.ClosePrices[nasdaqSeriesIndex];
        }
    }
}

The "nasdow" series contains the subtraction result of two other series, and you can use it on any indicators.


@amusleh

amusleh
10 Jan 2022, 08:24

Hi,

You can always get the current time by using Server.Time: cAlgo API Reference - IServer Interface (ctrader.com)


@amusleh

amusleh
07 Jan 2022, 15:07 ( Updated at: 07 Jan 2022, 15:08 )

RE: RE:

lukas.ourada said:

amusleh said:

Hi,

Did you tried to uninstall/re-install cTrader?

Hi, thanks for you reply.

Yes a try uninstall all version ctrader (roboforex, icm) and instal now clean version. I try too reinstall visual studio 2019, but still not work :-( 

Hi,

Try to uninstall/re-install the Visual Studio cBots/Indicators extension: cBots and Custom Indicators - Visual Studio Marketplace

Guide: Find and install extensions - Visual Studio (Windows) | Microsoft Docs


@amusleh

amusleh
07 Jan 2022, 11:37

Hi,

We are aware of this issue and it will be fixed very soon.

In meantime please use our new .NET library and samples: spotware/OpenAPI.Net: Spotware Open API .NET Rx library (github.com)


@amusleh

amusleh
07 Jan 2022, 07:34

Hi,

Try to restart cTrader, see if that helps.

Most probably something is wrong with your cBot code, sending a troubleshoot report might will help us to find the issue, write the forum thread link on the report comment.


@amusleh

amusleh
07 Jan 2022, 07:31

Hi,

Did you tried to uninstall/re-install cTrader?


@amusleh

amusleh
07 Jan 2022, 07:30

Hi,

You can't do that now, but if you want to you can write each cBot pass statistics and parameters on a file when OnStop method is called, so you have to code it by your self.


@amusleh

amusleh
07 Jan 2022, 07:27 ( Updated at: 07 Jan 2022, 07:28 )

Hi,

You should use different values for your cBot "Instance Name" parameter for each instance, otherwise all the instances will only open one position.

Or you should change the code at:

        private void OpenPosition(string Label, TradeType TradeDirection)
        {
            //Calculate Trade Amount base on the ATR

            var PrevATR = Math.Round(atr.Result.Last(1) / Symbol.PipSize);
            var PerTradeadjust = PerTrade / 100;
            var TradeAmount = (Account.Equity * PerTradeadjust) / (PrevATR * Symbol.PipValue);
            TradeAmount = Symbol.NormalizeVolumeInUnits(TradeAmount, RoundingMode.Down);
            ///var cBotPositions = Positions.FindAll(InstanceName); not used
            if (Positions.Count(x => x.Label == InstanceName) == 0)
            {
                ExecuteMarketOrder(TradeDirection, SymbolName, TradeAmount, InstanceName, null, null);
            }
        }

 


@amusleh

amusleh
07 Jan 2022, 07:24

Hi,

No, you can't do that, please open a thread for this under suggestions section.


@amusleh

amusleh
07 Jan 2022, 07:23 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE:

TheNiatpac said:

Hi Panagiotis,

I just reinstalled my system and started to use Visual Studio 2022. Would you consider supporting the new version soon? or any advice please

Thanks

PanagiotisCharalampous said:

Hi FireMyst,

No ETA at the moment but it should be in one of the upcoming upcoming updates.

Best Regards,

Panagiotis

 

Hi,

You can use Visual Studio 2022 on cTrader 4.2 which is the next major version of cTrader.


@amusleh

amusleh
07 Jan 2022, 07:22

Hi,

You can use Visual Studio 2022 after we released cTrader 4.2, right now you can't use it.


@amusleh

amusleh
07 Jan 2022, 07:21

Hi,

Not sure exactly what you are looking for, but when you change a chart time frame the indicator is re-initialized, so cTrader will call the indicator Initialize method and everything is recalculated.

If you want to get one candle before just minus one the index, if you have date time then first change it to index by using "Bars.OpenTimes.GetIndexByTime" then minus one the result.


@amusleh

amusleh
07 Jan 2022, 07:17

Hi,

What do you mean by using Quick Trade Buttons with automate?

If you open a position/order with quick trade button or with create new order window, you can access both of them on your cBot/Indicator.


@amusleh

amusleh
06 Jan 2022, 08:51

RE: Diffenence of multiple positions

budda_dan2020 said:

Hi Amusleh,

if an order partially filled by multiple positions, and the positions have same order ID and position IDs, what are difference of these positions? How can I differentiate them? Are there any other IDs which differ from each other?

 

Hi,

Each order is linked to a single position, it doesn't matter by how many deals it gets filled.

You can use the filled volume in ExecutionEvent or deals to differentiate between them, an order can be filled by one or more deals but it will always have one position ID.


@amusleh