Topics
Replies
PhoenixCapital
13 Dec 2024, 12:13
( Updated at: 13 Dec 2024, 14:37 )
RE: Error with Arrays - Beware!!
firemyst said:
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
Hi Firemyst,
Thanks for your comment.
Perhaps, this is new. Older versions of ctrader didnt do this at all. I have been doing this for 2 years.
I am assigning "prices = PriceList", not PriceList = prices". So I wouldnt think change "prices" would change "PriceList" because I am not assigning "prices" to "PriceList" after the changes. I know other programming languages as well and it doenst work that way. It doesnt make logical sense really.
But yes, I will try the copy to method.
Thanks,
@PhoenixCapital
PhoenixCapital
13 Dec 2024, 12:10
( Updated at: 13 Dec 2024, 14:37 )
RE: Error with Arrays - Beware!!
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
@PhoenixCapital
PhoenixCapital
13 Dec 2024, 12:09
( Updated at: 13 Dec 2024, 14:37 )
RE: Error with Arrays - Beware!!
PanagiotisCharalampous said:
Hi there,
That's how C# works. When you assign a list to another list, then you actually reference the previous. If you want to copy a list, use CopyTo method.
Best regards,
Panagiotis
Hi Panagiotis,
Thanks for your reply.
I am not sure you fully understand. Yes, if I assign a list to another list say list B to list A, List A will take all the references from List B. However, if I change anything in List A, it should not change anything in List B because I only assigned List B to List A, not the other way round i.e. List A to List B.
Just to break it down:
List B is assigned to List A
List A is NOT assigned to List B.
Any changes to List A should NOT affect List B. They are independent of each other after the change to List A.
This is how I have been doing it for 2 years and there was no issues. If you look at previous versions, it worked seamless without any issues.
I will try the Copy.To Method as well.
Thanks,
@PhoenixCapital
PhoenixCapital
21 Aug 2023, 12:00
Yea, I am having issues with the backtest as well on the new version. Too many changes and no enough testing. How do I go back to the previous version on ctrader?
@PhoenixCapital
PhoenixCapital
19 Aug 2023, 13:46
( Updated at: 21 Dec 2023, 09:23 )
It works on live trading, but not on backtest. Backtesting is the issue.
This is the image for live trading with the test count at 1 million.
@PhoenixCapital
PhoenixCapital
19 Aug 2023, 13:42
I am having a similar issue as well. The backtest just stops during a for loop after 50,000 entry. The new update is very buggy. I dont have an answer yet, but i will let you know when I do.
@PhoenixCapital
PhoenixCapital
19 Aug 2023, 13:07
( Updated at: 21 Dec 2023, 09:23 )
Here is a simple code for testing.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class NewcBot : Robot
{
public int testCount = 60000;
protected override void OnStart()
{
for (int i = 0; i < testCount; i++)
{
Print(i);
}
}
protected override void OnTick()
{
// Handle price updates here
}
protected override void OnStop()
{
// Handle cBot stop here
}
}
}
Here is the image. It just stops at 50,000 entries on the log.
@PhoenixCapital
PhoenixCapital
17 Mar 2021, 05:37
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi quantumtrading,
We do not have an ETA at the moment.
Best Regards,
Panagiotis
Hi Panagiotis,
I am having a similar issues as well.
Also with the ROI which is based on equity figures, not balance/gains figures which is misleading.
Strategy is https://ct.icmarkets.com/copy/account/1189401-icmarkets
@PhoenixCapital
PhoenixCapital
10 Aug 2020, 11:50
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi findseun08,
There is no difference in coding for renko charts. It is the same as for time based charts. What examples are you looking for?
Best Regards,
Panagiotis
Hi Panagiotis,
Thank you for your quick response.
What I mean is that I want to be able to code with the Renko like I can on a minute chart (i.e. Bar, Minute10, Min3 etc), but there is no method or reference for using renko to code (i.e. Renko Method)
Do you know when this will be available?
Thanks,.
Seun
@PhoenixCapital
PhoenixCapital
09 Aug 2020, 20:32
RE:
PanagiotisCharalampous said:
Hi ghcaplan,
Thanks for posting in our forum. No this is still not possible.
Best Regards,
Panagiotis
Hi Panagiotis,
Can Renko be used in the code?
If so how? It doesnt seem that there is a method to utilize the Renko that is on the chart.
Thanks.
@PhoenixCapital
PhoenixCapital
01 May 2020, 21:21
RE:
tinker.this said:
Can someone help me with a code snippet that will:
Find position with biggest loss and close it
Thanks
Its:
var position = Positions.OrderByDescending(i => (i.NetProfit)).Where(i => i.Label == "Label").LastOrDefault();
@PhoenixCapital
PhoenixCapital
13 Dec 2024, 12:19 ( Updated at: 13 Dec 2024, 14:37 )
Thanks guys. ToArray() is the best solution.
@PhoenixCapital