Topics
Replies
ncel01
25 Nov 2022, 15:15
RE:
PanagiotisChar said:
Hi there,
No it's $50 and it's something like a stop out.
Need help? Join us on Telegram
Need premium support? Trade with us
Hi Panagiotis,
Thanks for your reply.
What's the purpose of having a stop out which is not function of the available margin/ initial funds?
And why is this set automatically and can't be changed?
Thanks.
@ncel01
ncel01
16 Nov 2022, 09:55
RE:
Hi Panagiotis,
Could you please share the output?
I'd like to compare your results with mine.
Thanks.
PanagiotisChar said:
Hi there,
I ran the cBot but I cannot see any problem. Open and close times seem in line with what the broker has configured.
@ncel01
ncel01
15 Nov 2022, 15:51
RE: RE:
Hi Panagiotis,
Is there any update on this?
ncel01 said:
Hi Panagiotis,
Thanks for your reply!
You can try, for instante: US500, Pepperstone, Jan 2021-Today.
PanagiotisChar said:
Hi there,
Any examples so that we can reproduce? Index, broker, backtesting dates?
Need help? Join us on Telegram
Need premium support? Trade with us
@ncel01
ncel01
10 Nov 2022, 10:01
RE:
Hi Panagiotis,
Thanks for your reply!
You can try, for instante: US500, Pepperstone, Jan 2021-Today.
PanagiotisChar said:
Hi there,
Any examples so that we can reproduce? Index, broker, backtesting dates?
Need help? Join us on Telegram
Need premium support? Trade with us
@ncel01
ncel01
17 Oct 2022, 22:50
RE:
xabbu said:
Hey ncel01,
You can try an onTimer with
Symbol.MarketHours.TimeTillClose() <= _afterSessionOpen
and before define
afterSessionOpen = "22:" + Convert.ToString(minutesAfter) + ":00";
TimeSpan.TryParse(afterSessionOpen, CultureInfo.InvariantCulture, out _afterSessionOpen);So with that logic my trades are only executed if the time to market close is smaller 22 hours and x minutes, which means I don't trade between 23 pm and 1 am (my time) broker dependend - but you got the idea.
xabbu
Hi xabbu,
Thanks for your reply.
I thought of implementing something similar or even defining a time period based on the current hours only.
However, I am more into trading indices and the working hours is not as "standard" as for FX and more "broker dependent". Also, there are some exceptions to this during the year, for which the time schedule is different.
In fact, and to make things easier, I was expecting a method similar to MarketHours.TimeTillClose() (i.e. MarketHours.TimeAfterOpen()) to be available.
This way, it was possible to automate (based on the hours defined by the broker) a time interval that covers both market close and opening.
I am afraid that, without this method available, it won't be possible to get to an 100% accurate solution.
Sometimes I notice that similar methods/properties are not available, although these are very basic/intuitive..
Some other example: Account.Asset.Name
This is not available for a symbol. However, the currency is a basic/important attribute not only for an account but also of any instrument.. moreover, this can be needed for currency conversion and risk management purposes, which is for sure not a detail when trading. Although I found a solution for this, once again, it was not the most effective one.
Last but not least, thanks for your help. I really appreciate it!
ncel01
@ncel01
ncel01
14 Oct 2022, 08:16
RE:
Hello,
Thanks for informing.
Could you please help with the following thread as well?
https://ctrader.com/forum/calgo-support/39110
Thank you.
@ncel01
ncel01
29 Sep 2022, 22:46
RE:
Hi Panagiotis,
Yes, it solved the problem! In fact, I was expecting that only the closed trades with a label defined would be part of targetTrades.
I've also noticed that no exception was thrown when backtesting since History collection will only contain the backtest trades.
Thanks for helping with this!
@ncel01
ncel01
27 Sep 2022, 22:46
( Updated at: 21 Dec 2023, 09:22 )
RE:
Hi Panagiotis,
Thanks for your reply.
Below is a screenshot taken from VS when debugging. Unfortunately, I don't think this helped a lot.
Given this, could you please provide more details on what can be a reson for this issue?
This happens when runnning the cBot in real-time but not when backtesting. Wasn't the outcome suppose to be the same for both the cases?
As far as I know, History is a property for the Account and I am using the same account when running both tests. Moreover, there is no variable other than targetTrades here defined.
It is also not clear to me why you get no exceptions, considering the exact same code, while I get the following:
Thank you once again!
@ncel01
ncel01
25 Jul 2022, 13:58
RE:
ncel01 said:
Hello,
How to get the margin calculation type applied by the broker (max, net, sum)? I needed this to be considered by the cBot.Apparently there's nothing similar to Account.MarginCalculationType available.
Thank you!
Hello,
Is there any update on this?
Thank you.
@ncel01
ncel01
21 Jul 2022, 22:59
RE:
PanagiotisCharalampous said:
Hi ncel01,
On the other hand, lowering the account leverage should not be dependent on any broker decision as it is only about risk management and it's not up to any broker to (somehow) control this on traders' behalf.
Well we cannot enforce this on the brokers, it's their business and its their choice what they will offer to their clients. On the other side nothing prevents you from not utilizing the given leverage and trade less.
On the other hand, it seems "impossible" to code if considering currency conversion applied to multiple cBot instances, since "position.MarginUsed" is not available in API.
Account.FreeMargin is available so you can start from there and with simple maths calculate the margin based on the leverage you want to use.
Best Regards,
Panagiotis
Hi Panagiotis,
Well we cannot enforce this on the brokers, it's their business and its their choice what they will offer to their clients. On the other side nothing prevents you from not utilizing the given leverage and trade less.
In my opinion it is not about enforcing anything but not providing brokers with this option. I also don't see it as their business but traders' own money, when it comes to risk management. A point of view fully compliant with a Traders First policy, I believe.
Yes, trading less is always possible, however for some reason financial authorities define a maximum leverage to be used. In any case, this wouldn't help with the automated solution I would like to implement.
Account.FreeMargin is available so you can start from there and with simple maths calculate the margin based on the leverage you want to use.
Yes indeed, but I am afraid this won't be a simple calculation if the traded instruments are given different leverage levels.
However, I think I possibly found a solution for this. Not as effective as reducing the account leverage, of course, but still feasible, I believe.
Also not as effective as reducing the account leverage, get the position.MarginUsed would help a lot in such a case. I really think that adding this wouldn't be redundant but an improvement.
Last but not least:
Mentioning for extra features/ API solutions doesn't really mean cTrader is (somehow) limited but it does mean it is great!
And believe me, I really appreciate the work you all have been doing!
Thank you once again.
@ncel01
ncel01
21 Jul 2022, 12:08
RE:
PanagiotisCharalampous said:
Hi ncel01,
As far as know, you can ask your broker for the leverage you want for your account. Also cTrader offers the option to traders to change their leverage but in needs to be enabled by the broker.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
Hi Panagiotis,
I've checked this across a lot of brokers and the account leverage is fixed and equal to the maximum allowed by the applicable jurisdiction.
Maybe some brokers offered this option in the past, when they could apply 500:1 to the European residents, but now, with a maximum of 30:1, it looks like lowering the leverage has become an impossibility.
Yes, "need to be enabled by the broker". That's exactly the issue here. As I mentioned brokers do not provide this feature, making it useless.
Maximum account leverage shall be controlled by the broker as this is a legal requirement, that's okay.
On the other hand, lowering the account leverage should not be dependent on any broker decision as it is only about risk management and it's not up to any broker to (somehow) control this on traders' behalf.
My intention (cBot):
I would like to normalise the account margin/margin level for a lower leverage (10:1) across a range of different instruments (to which different max. leverages apply).
This could be easily achieved by simply decrease the account leverage to this amount.
On the other hand, it seems "impossible" to code if considering currency conversion applied to multiple cBot instances, since "position.MarginUsed" is not available in API.
It would be great to have position.MarginUsed available since the account currency and any possible conversion ratio is already considered.
There's a simple formula to get to position.MarginUsed, however this is not the case when currency conversion is involved if working with multiple cBot instances, since the conversion price on opening, would need to be shared between them for all the account active positions.
Do you have any suggestion how to have this implemented?
Thank you!
@ncel01
ncel01
18 Jul 2022, 13:56
RE:
PanagiotisCharalampous said:
Hi ncel01,
in such case, currency conversion ratio is a constant (equal to 1).
That's not the case and as I explained it is an issue that needs to be fixed :) What you describe is how it should work, but it doesn't work like that at the moment.
Best Regards,
Panagiotis
Hi Panagiotis,
I see. Now it's clear that the issue it is not only about the current ratio and the historical one but also the above.
Still, this looks to be an issue for indices but not for currency pairs. However, when currencies match, Symbol.TickValue/Symbol.TickSize always equals to 1 for both backtest and real time, regardless of the instrument.
@ncel01
ncel01
15 Jul 2022, 14:15
RE:
PanagiotisCharalampous said:
Hi ncel01,
The explanation is the same. The conversion logic applies even if the base asset and the account currency are the same.
Best Regards,
Panagiotis
Hi Panagiotis,
Considering backtest (same currency for both account and instrument):
I understand it applies since it is considered in the margin calculation formula. However, what I don't really understand is how this can affect margin calculation considering that, in such case, currency conversion ratio is a constant (equal to 1).
It is also not clear to me why the this looks okay for currency pairs but not for indices.
Did you have the opportunity to check this?
Thank you!
@ncel01
ncel01
15 Jul 2022, 08:54
( Updated at: 21 Dec 2023, 09:22 )
RE: RE:
ncel01 said:
PanagiotisCharalampous said:
Hi ncel01,
Just tried on live execution this and looks fine
On backtesting there is an issue indeed because margin is calculated based on the current rate and not the historical one, hence the discrepancy. It will be fixed in a future version of the application.
Best Regards,
Panagiotis
Hello Panagiotis,
Thank you for your reply!
Yes, indeed. In real time it looks okay.
However, to make it more simple, and so that no currency conversion is applicable, I have only tested this using an account of the same currency as the instrument. This way, I was really expecting these values to match.
I see you're using a USD account while buying in EUR. If you check this using (for instance) a US indice, you notice that this mismatch still remain when backtesting, although there's no currency conversion involved.
Thank you once again!
Hello,
Is there any update on this?
Apparently there is no issue when backtesting currency pairs.
@ncel01
ncel01
06 Jul 2022, 21:39
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi ncel01,
Just tried on live execution this and looks fine
On backtesting there is an issue indeed because margin is calculated based on the current rate and not the historical one, hence the discrepancy. It will be fixed in a future version of the application.
Best Regards,
Panagiotis
Hello Panagiotis,
Thank you for your reply!
Yes, indeed. In real time it looks okay.
However, to make it more simple, and so that no currency conversion is applicable, I have only tested this using an account of the same currency as the instrument. This way, I was really expecting these values to match.
I see you're using a USD account while buying in EUR. If you check this using (for instance) a US indice, you notice that this mismatch still remain when backtesting, although there's no currency conversion involved.
Thank you once again!
@ncel01
ncel01
28 Nov 2022, 14:04 ( Updated at: 21 Dec 2023, 09:23 )
RE:
Hello,
Is there any update on this issue?
Thanks.
ncel01 said:
@ncel01