Topics
27 Mar 2021, 05:38
 919
 2
26 May 2020, 14:49
 3300
 5
20 Mar 2020, 22:59
 874
 2
25 Feb 2020, 10:43
 1038
 2
05 Jan 2020, 23:41
 1298
 3
30 Nov 2019, 11:04
 1048
 3
Replies

douglascvas
13 Apr 2023, 10:18

Sorry, ignore what I said. It turns out it was a problem in an indicator that I was using and the message was not clear. It would be very helpfull if cTrader logged the stacktrace when an exception happens.


@douglascvas

douglascvas
04 Sep 2022, 13:21

RE: RE:

firemyst said:

douglascvas said:

Could cTrader go back to 1 single process, please? It is so hard to debug algos when the process keeps changing on each run.

Yes, it is a little bit more of a hassle.

Perhaps this will help:

https://help.ctrader.com/ctrader-automate/debugging/#debugging-a-cbotindicator

 

 

Thank you so much mate, that helped me a lot!


@douglascvas

douglascvas
03 Aug 2022, 00:58

RE:

userUser said:

If cTrader would offer a dialog window on whether to update now or later, would be good. We could wait to update until all the bugs are fixed.

It does have that but is does not help that much because you only see the problems after you did the upgrade.


@douglascvas

douglascvas
02 Aug 2022, 11:02 ( Updated at: 02 Aug 2022, 13:24 )

Same issue here. cTrader automate was slow before and now is way worse.

I have a Java platform which I created for myself, then I created a simple bot which uses multiple currencies. I translated the bot to c# as a cTrader robot to compare and check results.

Running a backtest on tick based data from January 2016 till now, my platform takes about 12 minutes to run while cTrader is currently taking around 2 days on the same bot (not counting the time to download the data).


@douglascvas

douglascvas
01 Aug 2022, 15:19

RE:

PanagiotisCharalampous said:

Hi there,

Does this still happen?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi Panagiotis, I'm not sure. That happened in the ctrader web url from icMarkets. Today I tried same URL and it seems their certificate is not valid, so I haven't tried again from there.

But from https://ct.spotware.com/ which is the generic spotware ctrader the login works fine; which is good because from that one I can see all my accounts.

Cheers,

Douglas.


@douglascvas

douglascvas
28 Mar 2022, 13:38

RE:

PanagiotisCharalampous said:

Hi douglascvas,

For Buy positions stop loss is calculated from the ask price and for Sell positions from the bid price. What you see is correct.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi Panagiotis. Are you sure? Does that make sense?

I mean, If a sell position is triggered on BID and closes on ASK, doesn't it make more sense that the stop loss is calculated on ASK as well? Otherwise it risks setting the stop loss inside of the spread, which means the position would either be immediatelly closed if the stop loss pips is lower than the spread or it simply won't have a SL. 


@douglascvas

douglascvas
28 Mar 2022, 10:51

RE:

amusleh said:

Hi,

Which type of data you were using for your back test? Tick data or m1 bars open prices?

I'm using Tick data


@douglascvas

douglascvas
20 Oct 2021, 13:26

RE:

amusleh said:

Hi,

Can you post the logs of what you sent to server? Maybe something is wrong with the data you are sending to server.

Post all the parameters that you sent for creating order, and which broker you were using?

 

Ahh I think I found the problem.

This is the payload that is being sent to the server:

com.xtrader.protocol.openapi.v2.ProtoOANewOrderReq
symbolId: 3   (EURJPY)
orderType: STOP
tradeSide: SELL
volume: 3100000
stopPrice: 132.874
timeInForce: GOOD_TILL_DATE
expirationTimestamp: 1800000
comment: "0||0||2b6a0cd8389d74b1660f70d509a103e4ebb7b238|59ca75e7-e503-4ba1-bbdd-758489b2d2e5"
label: "a83ffb14-5731-4ccc-894f-ae35c0b898f0"
relativeStopLoss: 434977
relativeTakeProfit: 9167142
guaranteedStopLoss: false
stopTriggerMethod: TRADE

 

-------

I noticed that if I send 434.977 it does not work, but if I send 434.9 it does. The problem is that I was multiplying by 100000 before rounding. But it looks like the server is only happy if I multiply after the rounding (what kinda makes sense).

pipSize = 0.01

symbolDigits = 3

stopLossPips = 434.977

pipSizeInPrice = 0.01 * 434.977 = 4.34977

 

Before:

round(4.34977 * 100000, 3) = 434977

 

After:

round(4.34977, 3) * 100000 = 4349

 

Thank you, @amusleh

 

 


@douglascvas

douglascvas
19 Oct 2021, 01:02

RE: RE: RE:

amusleh said:

douglascvas said:

 amusleh said:

Hi,

The decimal places of your stop price must much with symbol digits.

You can get the symbol digits from ProtoOASymbol.

As I said, that's weird because the value is a double, so I don't understand why I need to round it before sending. Anyway, using bigdecimal fixes that one problem:

request.setStopPrice(BigDecimal.valueOf(order.getTargetPrice())
                    .setScale(symbol.getDigits(), RoundingMode.HALF_UP)
                    .doubleValue());

 

Now I get another one in the relative price. And that one I can't see how to fix

request.setRelativeStopLoss((long) (stopLossPips * symbol.getPipSize() * 100000));

That gives me this error:

Error:Relative stop loss has invalid precision

How can that be if the field is a Long? There is absolutely no way to set decimal precision. I don't understand what is going on.

The .proto file states this:

optional int64 relativeTakeProfit = 20; // Relative Take Profit that can be specified instead of the absolute one. Specified in 1/100000 of unit of a price. For BUY takeProfit = entryPrice + relativeTakeProfit, for SELL takeProfit = entryPrice - relativeTakeProfit.​

 

Hi,

You should round the multiplication result before converting it back to long, ex:

        public static long GetRelativeFromPips(this ProtoOASymbol symbol, double pips)
        {
            var pipsInPrice = pips * symbol.GetPipSize();

            return (long)Math.Round(pipsInPrice * 100000, symbol.Digits);
        }

If you pass 10 pips for above method it will first multiply it by symbol pip size, for example EURUSD pip size is 0.0001, then it will multiply it to 100000 and then it rounds the multiplication result back to symbol digits.

I tried that, but it did not work. Same problem. And it does not make sense to work anyway because the value is rounded when we convert to long.

I don't get though how can it complain about invalid precision on a int64/long number.


@douglascvas

douglascvas
15 Oct 2021, 10:54 ( Updated at: 15 Oct 2021, 10:56 )

RE:

 amusleh said:

Hi,

The decimal places of your stop price must much with symbol digits.

You can get the symbol digits from ProtoOASymbol.

As I said, that's weird because the value is a double, so I don't understand why I need to round it before sending. Anyway, using bigdecimal fixes that one problem:

request.setStopPrice(BigDecimal.valueOf(order.getTargetPrice())
                    .setScale(symbol.getDigits(), RoundingMode.HALF_UP)
                    .doubleValue());

 

Now I get another one in the relative price. And that one I can't see how to fix

request.setRelativeStopLoss((long) (stopLossPips * symbol.getPipSize() * 100000));

That gives me this error:

Error:Relative stop loss has invalid precision

How can that be if the field is a Long? There is absolutely no way to set decimal precision. I don't understand what is going on.

The .proto file states this:

optional int64 relativeTakeProfit = 20; // Relative Take Profit that can be specified instead of the absolute one. Specified in 1/100000 of unit of a price. For BUY takeProfit = entryPrice + relativeTakeProfit, for SELL takeProfit = entryPrice - relativeTakeProfit.​

 


@douglascvas

douglascvas
28 May 2020, 16:07

RE:

PanagiotisCharalampous said:

Hi douglascvas,

The deals are from a year ago. How do you know what the swap rate was at that time?

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi Panagiotis. True, that might have changed as I am using the current swap rate that comes in the Symbol in cTrader Open API. But judging by the swap rates from other brokers, which are always close in value to these, I don't believe there is such a huge difference for the swap from one year ago. But in fact is one possibility. I will check most recent trades.


@douglascvas

douglascvas
23 Feb 2020, 04:04

RE:

PanagiotisCharalampous said:

Hi douglascvas,

Timestamp 1 is 1577428963249 + (-100)

Best Regards,

Panagiotis 

Join us on Telegram

 

Awesome! Thank you Panagiotis


@douglascvas

douglascvas
20 Feb 2020, 12:10

Sorry I am not 100% sure I got it. 

 

0 timestamp:1577428963249 tick:10950900 
1 timestamp:-100 tick:-100 
2 timestamp:-6035 tick:-100 
 

So timestamp 1 is 1577428963249 + (-100) or 1577428963249 - (-100)?

 


@douglascvas

douglascvas
26 Jan 2020, 02:53

RE:

PanagiotisCharalampous said:

Hi Douglas,

Symbol leverage is not available via Open API at the moment. If you need it to calculate the expected margin, you can use ProtoOAExpectedMarginReq.

Best Regards,

Panagiotis 

Join us on Telegram

 

 

Thank you @Panagiotis. I am trying to implement a backtesting mechanism though, so I wouldn't be able to call the server to calculate this. Would there be some other way?


@douglascvas

douglascvas
15 Jan 2020, 12:07

RE: RE:

kerrifox19 said:

What exactly do you want?

Exactly what I explained... I just want to know what is the best way to fetch tick history data from the server.

I am currently splitting the period by hour, if I get a "hasMore" flag then I try fetching again from the next millisecond after the last tick I got. I think that is good enough.


@douglascvas

douglascvas
19 Nov 2019, 13:30

4 years and still no news there?


@douglascvas

douglascvas
16 Nov 2019, 01:08

RE:

srubtsov said:

At first look, in the cBot you call it only once at the beginning of a bar. So you have the close value with which bar started. The indicator takes completed bars in that case.

 

You mean "MarketSeries.Close.Count - 2"? The same happens.


@douglascvas

douglascvas
04 Nov 2019, 23:24

Ah I think it has just been answered in https://ctrader.com/forum/indicator-support/16617


@douglascvas

douglascvas
19 Oct 2019, 02:07 ( Updated at: 21 Oct 2019, 10:01 )

Hi Pagagiotis. This post :)


@douglascvas

douglascvas
18 Oct 2019, 13:38 ( Updated at: 21 Oct 2019, 10:01 )

Delete post

Can I delete a post from mine here?


@douglascvas