Topics
02 Aug 2024, 08:40
 324
 8
14 Jul 2024, 19:24
 1
 275
 0
10 Jul 2024, 20:06
 1
 281
 0
14 Jun 2024, 20:33
 303
 2
Replies

ncel01
27 Jul 2023, 08:24

Dear cTrader Team,

There is no “my case”.

As you might have noticed, the code sample provided above was only intended to report an issue.

My question was obviously generic.

Thanks for clarifying the community on this by providing an effective answer. It would be also of value to see documentation on this available.


@ncel01

ncel01
25 Jul 2023, 08:39

Dear cTrader Team,

Thanks for informing.

However, what I really wanted to know is how priority on execution is assigned (by the API) to the price related events, in case these are triggered at the exact same moment.

For instance: 

  1. OnTick()
  2. OnBar()
  3. PendingOrders_Filled()
  4. Positions_Opened()
  5. Positions_Closed() 
  6. Positions_Modified()
  7. Positions_Cancelled()
  8. PendingOrders_Created()
  9. PendingOrders_Modified()
  10. PendingOrders_Cancelled()
  11. Etc.

Callback functions: will these be triggered right ater their respective event or, only after all the main events have been called?

Please note that it is important to be aware of this to properly manage execution, especially when using asynchronous operations.

Thank you!


@ncel01

ncel01
25 Jul 2023, 05:22

Dear Spotware team,

Thanks for clarifying the above or, alternatively, for sharing any available documentation regarding this.


@ncel01

ncel01
19 Jul 2023, 20:52

RE:

PanagiotisChar said:

Hi there,

Read below

Aieden Technologies

Need help? Join us on Telegram

 

Hi Panagiotis,

Thanks for sharing!
However, in the meantime, I noticed that the API MessageBox class contains enough options for the purpose.


@ncel01

ncel01
17 Jul 2023, 13:26

Dear Spotware team,

Great. Thanks for the prompt action/feedback!


@ncel01

ncel01
17 Jul 2023, 12:55

Dear Spotware team,

Same with Varianse, and probably many other brokers, I have no idea. Please include them all in the calculation.

Thanks.


@ncel01

ncel01
17 Jul 2023, 12:06 ( Updated at: 17 Jul 2023, 12:33 )

Yes, I can confirm that swaps have not been included for indices when backtesting.

Unfortunately, this is just another example where, unlike forex, indices have been overlooked.

@Spotware

Why do you need the cBot code here?

Just run a backtest with any indice and you will get to the same conclusion. As simple as that. 


@ncel01

ncel01
14 Jul 2023, 10:26

Hi Panagiotis,

No, I don't think so. This was the first option I've checked, I guess.

It returns NullReference since no order/position took place. This is the problem here. Apparently, there is no way to access to the operation parameters when trade result is not successful.


@ncel01

ncel01
14 Jul 2023, 09:49

firemyst,

Thanks for your reply.

What I really need is to identify the respective trade operation when trade result is not successful.

I have an auxiliary variable aux[i] that will be set to true before ExecuteMarketOrderAsync(), and I want it to be false in case trade result is not successful. However, I need to exactly know what is the applicable index "i", which can only be taken from the operation label.

I am affraid that the only way to get this done is to create several callback functions from 0 to i_max, and define multiple ExecuteMarketOrderAsync() inside a switch case, each of these with its own callback function as argument.


@ncel01

ncel01
13 Jul 2023, 20:13

firemyst,

Not really. That's simply the error description.

What I want is to access to the trade operation ExecuteMarketOrderAsync() parameters, in this case to the label.
The goal is to know, exactly, which operation has failed: "Position #1" vs "Position #2".


@ncel01

ncel01
30 Jun 2023, 19:34

Hi,

That should be related to the instructions you're providing inside the conditionals.

It is hard to help without looking at the remaining code.


@ncel01

ncel01
30 Jun 2023, 18:54

Hello,

The most likely reason why no trades are being placed:

When there are no open positions, Account.MarginLevel == null, which has a logic value eqivalent to !Account.MarginLevel.HasValue, as it assumes an infinite (NaN) value, therefore, both the conditionals Account.MarginLevel >= MarginRequirement and Account.MarginLevel.HasValue are false.

Try one of the following options, they must be equivalent:

if (Account.MarginLevel >= MarginRequirement || Account.MarginLevel == null)
  // place a trade
}
else
{
  // do not place a trade
}

Alternative:

if (Account.MarginLevel >= MarginRequirement || !Account.MarginLevel.HasValue)
  // place a trade
}
else
{
  // do not place a trade
}

 


@ncel01

ncel01
28 Jun 2023, 16:39

RE:

Dear Spotware team,

That was not expected but it's clear.

Thanks for informing!

 

Spotware said:

Dear ncel01,

At the moment market hours and margin are not consider. Both features will be added in a future release. In the meanwhile, please add manual checks before placing a trade.

Best regards,

cTrader Team

 


@ncel01

ncel01
28 Jun 2023, 10:28

firemyst,

That doesn't answer to my question.

The above has nothing to do with my cBot code. It is only meant to report the issues described.

why aren't you testing margin levels in your code _before_ sending the execute order?

I could also always check if market is open before I place a trade, however that's not the point here.

The order execution is instantaneous when backtesting, but not in real time, while dynamics apply to both cases. However, in the last case, a position will never open if the calculated account margin level after it opens is <100% and, the same should apply to the backtesting.

The requirements to place an order, among other, when backtesting should be exactly the same as when you're running your code in real time. Uniformity between these cases is not something you must code.

In fact, margin and market hours are the most basic requirements in training when it comes to open a trade. Therefore, it gets hard to understand why these are dismissed when backtesting.


@ncel01

ncel01
23 Jun 2023, 09:23

Dear Spotware team,

Kind request to advise on the above or, alternatively, to share any available documentation regarding this.

Thank you.


@ncel01

ncel01
22 Jun 2023, 14:34

Hello,

1. The limits are per trader connection.

Per cTrader ID (user) or, per cTrader running instance/account? This is not clear to me.

2. The limits have not been imposed on live trading accounts yet but they might be imposed if deemed necessary.

Right. In such a case will this be explicitly announced? In advance?

As far as I can see, restrictions are completely unbalanced with regard to their the purpose, where the allowed rate for very likely operations is only 5% ( max. of 100 vs 2000 requests per min.) of that for not so likely operations.

Example:

ModifyPendingOrder(): Very likely to be used more that 100x/min. when managing multiple pending orders OnBar()/OnTick() to avoid any market orders.

ClosePosition()/ModifyPosition(): Not likely at all to be called 2000x/min.

3.

Is in Spotware's plans to effectively improve it's applications performance in parallel with such restrictions?

I believe that such restrictions can remediate any existing problem but will not solve it.

 

Thanks for informing.


@ncel01

ncel01
21 Jun 2023, 16:55 ( Updated at: 21 Jun 2023, 16:59 )

Dear Spotware team,

Thanks for arranging this info. It is important for traders to be aware of such limitations.

As far as I can see, these limits are only applicable to demo accounts.

1. Are these the overall (cTrader ID) limits or, are these the limits per trading account?

2. Do any limits apply to live accounts?

Thank you.


@ncel01

ncel01
20 Jun 2023, 10:56

Dear Spotware team,

Could you please provide further details as this seems to be a high limitation regarding automated trading?

Why are cBots treated as "hackers" by the server(s) and how to prevent this?

Thank you.


@ncel01

ncel01
19 Jun 2023, 13:11

Hi firemyst,

I suppose that your account currency is AUD and that's for currency conversion purposes.


@ncel01

ncel01
19 Jun 2023, 10:17

Dear Spotware team,

You're welcome!

Please be aware that, most probably, this is not the only case for which visual and non-visual backtest are providing different results.

Question:

What priority is given, by the the API, to the events when this occur at the exact same moment?

In my case, I need to be aware of this so that the correct cBot logic can be implemented.

Thanks.


@ncel01