Topics
Replies
firemyst
14 Dec 2024, 05:59
( Updated at: 14 Dec 2024, 06:22 )
RE: RE: Error with Arrays - Beware!!
PhoenixCapital said:
Perhaps, this is new. Older versions of ctrader didnt do this at all. I have been doing this for 2 years.
It has always been like this. This is how C# has been working since it was first introduced back in early 2000's - even before Spotware's time.
If you want evidence, download a copy of Visual Studio 2015:
https://visualstudio.microsoft.com/vs/older-downloads/
Create a basic C# console application, set the .Net framework to either 2.0 or 3.5 (if possible) and put your code in there.
:-)
@firemyst
firemyst
13 Dec 2024, 00:42
( Updated at: 13 Dec 2024, 06:34 )
This is not a Spotware issue.
The solution is you need to better understand how arrays and objects are copied in C#.
When you say “prices = PriceList”, you're assigning the underlying reference of PriceList to prices, meaning whatever you change in one, changes in the other.
If you want to copy the actual values, you need to either:
- use a loop to copy each value in the array
- Google search and learn how to do it other ways, such as : https://stackoverflow.com/questions/14651899/create-a-copy-of-integer-array
@firemyst
firemyst
13 Dec 2024, 00:31
Nearly 9 years on and since Spotware still hasn't provided this functionality, here's a suggestion if you don't program up your own, you can always do the math to compensate.
For instance, if you have a 20 period ema on the M1 chart, on the M30 chart change the period 600 (30 minutes * 20 period length on m1 chart)
@firemyst
firemyst
11 Dec 2024, 06:11
( Updated at: 11 Dec 2024, 06:14 )
If you put your request in the correct forum, Spotware might consider it.
THis is a technical support forum. As such, Spotware doesn't come here, more or less looking for suggestions for improvement.
https://ctrader.com/forum/suggestions/
@firemyst
firemyst
09 Dec 2024, 23:44
You can find the logs in the “algo” tab:

I'm not sure how you expect anyone to help you otherwise when you haven't posted any screen captures showing your back-testing settings, or describing what your back-testing settings are.
you should also post your code logic so people can see what may be going on.
@firemyst
firemyst
06 Dec 2024, 09:18
( Updated at: 06 Dec 2024, 09:30 )
What do you mean not available through the API?
It's right here:
https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Position/#modifyvolume
and you use it like so, where “_p” is your position object:
TradeResult r = _p.ModifyVolume(newVolume);
@firemyst
firemyst
03 Dec 2024, 00:31
RE: indicator.Count is 0 when referenced in cBot's first OnBar and changes to correct 201 if referenced again without doing anything else
martins said:
Further tests with Print(DateTime.Now.ToString("HH:mm:ss.ffff") + …) & some System.Threading.Thread.Sleep calls in both an indicator & a cbot shows that making a reference, in the first OnBar call, to the .Count of a NON-DISPLAY IndicatorDataSeries (one WITHOUT a "[Output …] attribute) DOES NOT trigger the indicator to start making Calculate calls - the Calculate calls for the 200 history Bars seem only to be triggered by the first reference to the .Count of any DISPLAY IndicatorDataSeries (one WITH [Output…]) but even then, the initial zero count is returned to the cBot and incorporated into a Print buffer before the Calculates happen.
Then the OnBar pauses while the 200 or so history Calculates happen for the Bars prior to the backtest start time, then the buffer gets put into log.txt and the Log screen, and subsequent references in the first OnBar to .Count of any display or non-display IndicatorDataSeries give correct values (because all the history Calculates have been run).
It seem in we have to make 2 references in a cBot's first OnBar (when index=0) to an indicator's IndicatorDataSeries having the [Output…] clause (making it, if the indicator were run independently, a display line not just a calculated series) in order to get a proper value - is this correct and documented or is it a bug?
I know this means nothing, but I applaud your research in trying to figure it all out and am looking forward to updates.
@firemyst
firemyst
18 Dec 2024, 06:33
Change their color?
By default the text is white:
@firemyst