Documentation example doesn't work
Documentation example doesn't work
25 May 2023, 09:18
I've been trying to make the documentation example from this page work. Unfortunately, it doesn't: the ScrollViewer won't appear on the chart. (Even after waiting for 5 minutes.)
Does the example from that page work for you on cTrader 4.6.7?
When I change the for loop of that example to the following, the ScrollViewer does appear:
for (int iSymbol = 1; iSymbol < Symbols.Count; iSymbol++)
{
string symbolName = Symbols[iSymbol];
grid.AddChild(new TextBlock
{
Text = symbolName,
Margin = 5,
ForegroundColor = Color.Black,
FontWeight = FontWeight.ExtraBold
}, iSymbol, 0);
grid.AddChild(new Button
{
Text = "hello",
Margin = 5,
ForegroundColor = Color.Black,
FontWeight = FontWeight.ExtraBold
}, iSymbol, 1);
}
So without the code that uses the symbol (such as its description) the ScrollViewer does render. But that's somewhat of the core of the example.
Thanks,
Replies
coffeedarkmatter
26 May 2023, 18:39
Thanks Pick! That code works. And I now also understand how cTrader operates a bit better. I much appreciate your reply and the time taken. :)
How did you know the code did work, but needed threading to give a visual result earlier? I looked at the chart and indicator and didn't notice a spinning wheel or loading sign. And in the Task Manager the cTrader's CPU usage was very low. So I mistakenly assumed the code didn't do anything.
@coffeedarkmatter
pick
30 May 2023, 11:22
RE:
coffeedarkmatter said:
Thanks Pick! That code works. And I now also understand how cTrader operates a bit better. I much appreciate your reply and the time taken. :)
How did you know the code did work, but needed threading to give a visual result earlier? I looked at the chart and indicator and didn't notice a spinning wheel or loading sign. And in the Task Manager the cTrader's CPU usage was very low. So I mistakenly assumed the code didn't do anything.
Sorry for the delayed response. I'm glad that you could reproduce a working sample! I initially just reduced the number of iterations in the loop to 5 and it populated. Then, I just removed the graphical side of it and began logging with the timings to find the culprit.
@pick
coffeedarkmatter
30 May 2023, 17:07
Thanks for the reply Pick. It's not delayed from my perspective, I'm just happy to get insights from people with a lot more experience in cTrader than me. :)
I appreciate you listing the steps you've took. This is going to help me in the future with cTrader. Thanks!
@coffeedarkmatter
pick
25 May 2023, 13:24
It works, but it takes a long time - mainly due to the Symbols.GetSymbol call (which must be done on the main thread) combined with how many symbols there are to load.
You can reduce the number of loops and it will populate faster, but if you want all symbols, below is a solution that I just quickly wrote up. It will populate the symbol names, then move on to filling in the descriptions.
Keep in mind that this is only a quick implementation and that it could probably be made more efficient:
@pick