Topics
Replies
firemyst
16 Apr 2023, 05:35
RE: RE: RE: RE: RE: RE: RE: RE:
Shares4us said:
@firemyst
But you still havne't posted sample code that "doesn't build" so others cna try reproducing the issue?
?????? What use has code when the problem is not syntactical or in the logic but in the dev environment itself!
If it was I'd posted (as many times before) a test code to prove the problem.
Please look at the images I posted in my inital post. Think about it and you will come to the conclusion it has NOTHING to do with code!Best rgds,
All I'm suggesting is nobody else appears to be experiencing any issues running various versions of cTrader and building numerous indicators/cbots.
So to encourage people to further help you, you'll have to give people something else to go on.
That means code, the .sln file, the .csproj file, the .algo file, or everything.
Or some sampling that reproduces the issue so others can see what's happening, investigate, and perhaps give you an answer.
If you're not willing to do that, then you might be on your own.
@firemyst
firemyst
14 Apr 2023, 02:51
RE: RE: RE: RE: RE: RE:
Shares4us said:
@firemyst
Thnks for the effort!
But sadly it does not change the fact it still builds no .algo file
That's unfortunate.
But you still havne't posted sample code that "doesn't build" so others cna try reproducing the issue?
According to your logs, it does build the calgo, but into the various C:\Users\Admin\Documents\cAlgo\Sources\Indicators\ [name of indicator] \bin\Release subfolders.
@firemyst
firemyst
13 Apr 2023, 14:24
I understand what you mean.
While the API is a good start, there's definitely lots of things that can be improved.
What annoys me the most so far is the API's for the indicators aren't standardized. For instance, there's a lot of indicators that do not accept a data series as a parameter; or other indicators like the MA's where some have the "shift" parameter, and others that use MA's don't.
And we still don't have an option to programmatically turn on/off any "cloud" attribute.
Go figure. :-/
@firemyst
firemyst
13 Apr 2023, 10:17
RE: RE:
yaghouti said:
i want to check some parameters on each tick and change the period1 from calculate,
would you mind please explain me how to do this task?
firemyst said:
It won't change unless you create a new MovingAverage with the new setting or overwrite the previous one.
So after you change "period1", you should do this again:
param1 = Indicators.MovingAverage(param2, period1, MovingAverageType.Simple);
The Initialize method will only run again if you display the parameters window and change it that way.
If you programmatically change values, then you need to programmatically create new movingaverage objects with those new parameters.
Not knowing everything you want to do, it's not that complicated. In a nutshell, it'll be similar to the following:
protected override void Calculate(int index)
{
// do some stuff or whatever you want to do
//check and change
if ( [whatever condition] == true)
{
//set the new period1
period1 = 12; //or whatever
//update the MA
param1 = Indicators.MovingAverage(param2, period1, MovingAverageType.Simple);
}
//do whatever else you need to
}
@firemyst
firemyst
13 Apr 2023, 03:49
What do you have for your "Period" setting?
According to the API documentation, the "HasCrossed" should look back the number of bars equal to "period" and see if the values have crossed during that time:
So if you have a period of 1, it should look back over the last 1 bars to see if the values have crossed. If you set period to 2, it should look over the last 2 bars to see if the values have crossed, etc etc.
If not, then please post sample code showing the issue so everyone can see what you're doing and how.
Thank you.
@firemyst
firemyst
13 Apr 2023, 03:44
It won't change unless you create a new MovingAverage with the new setting or overwrite the previous one.
So after you change "period1", you should do this again:
param1 = Indicators.MovingAverage(param2, period1, MovingAverageType.Simple);
The Initialize method will only run again if you display the parameters window and change it that way.
If you programmatically change values, then you need to programmatically create new movingaverage objects with those new parameters.
@firemyst
firemyst
12 Apr 2023, 12:54
RE: RE: RE: RE:
Shares4us said:
@firemyst
Yes i'm on the automate tab (see the post on 30 Mar 2023, 19:36)
Yes it's an indicator, the problem is the same for an indicator or a Robot.
The problem is not in the use of the cTrader native build but in building with vs2022.
The build in vs2022 runs OK
Build started...
1>------ Build started: Project: Test3, Configuration: Debug Any CPU ------
1>Test3 -> C:\Users\xxx\Documents\cAlgo\Sources\Indicators\Test3\Test3\bin\Debug\net6.0\Test3.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 10:53 AM and took 01.701 seconds ==========but the
C:\Users\xxx\Documents\cAlgo\Sources\Indicators\Test3.algo
is not updated.
therefor debugging is not possible.
So the question is:
What 'extentions/procedures' does cTrader append to vs2022 to create/update the Test3.algo file and what makes it not working anymore.
If you have anything specified in VS 2022 like preferred framework, target platform, target OS, etc etc, it's going to build it in those local subfolders under "Bin" and "release/debug".
To stop this, you need to edit your VS Project file (via Notepad or some other text editor) and insert the following within the <PropertyGroup> tags:
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
For example, here's mine from one project using .Net6:
<PropertyGroup>
<TargetFramework>net6.0-windows10.0.20348.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
@firemyst
firemyst
11 Apr 2023, 06:55
( Updated at: 11 Apr 2023, 06:56 )
protected override void Initialize()
{
// How to debug:
// https://help.ctrader.com/ctrader-automate/debugging/#debugging-a-cbotindicator
#if DEBUG
var result = System.Diagnostics.Debugger.Launch();
#endif
// ...
// ...
}
Sample code above.
Link below:
@firemyst
firemyst
10 Apr 2023, 15:53
( Updated at: 21 Dec 2023, 09:23 )
RE:
algorithmic.trading.eu_gmail.com said:
Hi
I created a very profitable cBot. When I didn't have a free testing version (with the Expiration date in the code) for the user to try it out first, I was getting emails from programmers. They said they can help me add the code for expiration date and so on. I did that. Then I gave my cBot to them WITHOUT THE SOURCE CODE.
The Expiration date code works. It is in the OnStart and in the OnTick section.
Now they are reverse engineering my very profitable cBot and making fun of me.
Can someone please help me make my cBot more difficult for reverse engineering? Please. Thanks.
I tried to find this in cTrader but I couldn't find it :
To obfuscate your cBot code in cTrader, you can use the built-in obfuscation tool provided by the platform. To access it, open your cBot project and go to the "Tools" menu, then select "Obfuscate code". This will open a dialog box where you can select the options for obfuscating your code, such as renaming variables and functions, removing comments, and compressing the code.
Once you have selected the options you want, click the "Obfuscate" button to start the process. The obfuscated code will be saved in a new file, which you can use instead of the original code. Keep in mind that while obfuscation can make it harder to reverse engineer your code, it is not foolproof and determined attackers may still be able to understand your code with enough effort.
This is why I downloaded www.gapotchenko.com/eazfuscator.net Eazfuscator.NET (I also tried with the .NET reactor but I can't add the cbots file)
I hope this is correct and now it will be more difficult to reverse engineer my cBot ? Can someone reply to me and help me out?
The first question is are .algo files still "encrypted" regardless of the platform (eg, .Net Framework or .Net 6)?
Last time I spoke and asked @PanagiotisChar about obfuscation in compilation, he said it wasn't possible. So if that's still the case, you'd have to build your source code, then copy/paste it into another project, obfuscate it there within the editor, and then build it to a .algo file.
Read this thread for more information:
@firemyst
firemyst
10 Apr 2023, 15:42
( Updated at: 21 Dec 2023, 09:23 )
RE: RE:
Shares4us said:
please provide me with a 'something' to create the .algo file
And just to confirm, you are looking under the "Automate" tab (since your screen capture from earlier shows it to be an indicator and not a cbot) and you have everything being shown?
@firemyst
firemyst
10 Apr 2023, 15:39
( Updated at: 10 Apr 2023, 15:43 )
RE: RE:
Shares4us said:
please provide me with a 'something' to create the .algo file
Can you post your Indicator code, or some sort of sampling there of, that's causing the issue? So someone else can try building your code to see if it works?
@firemyst
firemyst
09 Apr 2023, 07:19
RE:
ctid5083541 said:
I get the 'new' expression can be simplified to the following line of code:
private List<double> myPrices = new List<double>();
It works fine in .NET Framework 4x (Legacy) but I want my code to work in .NET 6.0 as well.
How do I resolve this?
Any help appreciated.
Many thanks.
You don't have to. It can be simplified doesn't mean it has to be simplified.
If you simplify it, the syntax may not be compatible with .net framework 4.x.
If you are using Visual Studio, just hover the issue in the actual code and then in the pop up window select "show potential fixes".
@firemyst
firemyst
08 Apr 2023, 05:13
Of course it does :-)
That's because each time you draw the number, you call the object on the chart the same name, so it replaces the one that was there previously with the same name, with the new values. You need to make the name of your object more "unique" -- the part highlighted in bold below:
ChartObjects.DrawText("Your Number", "1", Bars.Count-1, Bars.HighPrices[Bars.Count-1] + (Symbol.PipValue * 10), VerticalAlignment.Center, HorizontalAlignment.Center, Colors.GreenYellow);
So I would do one of 2 things:
1) append the current bar index onto the end of the name
2) append the current datetime it's drawn onto the end of the name
The "index" option would be easier if you ever have to go back and delete a particular object
Example if you're in the calculate method:
protected override void Calculate (int index)
{
ChartObjects.DrawText("Your Number" + index, "1", Bars.Count-1, Bars.HighPrices[Bars.Count-1] + (Symbol.PipValue * 10), VerticalAlignment.Center, HorizontalAlignment.Center, Colors.GreenYellow);
}
@firemyst
firemyst
06 Apr 2023, 08:23
Are you wanting to check for each "tick", or only the previous bar?
It sounds like you're wanting to check each tick, but am not 100% sure.
If you want to check the previous bar when a new bar is formed, if you are on Renko charts it'll be a bit more complex than any of the other kinds of charts since cTrader doesn't keep track of Renko "tails" for bar related data.
Otherwise, pseudo business logic:
1) get current bar's open
2) check if open is initially above/below the MA
3) if open was below MA, then on each tick:
a) get the MA's current value
b) get the Symbol Ask/Bid/Closing price (whatever you want to consider has touched the MA)
c) check if the above price is >= MA current value
4) if open was above MA, then:
a) repeat steps 3a/3b
b) check if the price is <= MA current value
Hope that helps and is what you're after?
@firemyst
firemyst
05 Apr 2023, 04:04
The API isn't that great for what you want to do if you have a position and change the volume along the way.
The easiest way I've found is to create a variable in my cBots to keep track of each entry.
I use a Dictionary<int,DateTime> object with the int key being the position number (starting with 1 and increasing each time I add to my position size) and the value being the datetime the position was successfully modified/updated.
Hope that helps.
@firemyst
firemyst
29 Mar 2023, 16:27
RE:
Spotware said:
Dear firemyst,
Is it possible to check your Event Viewer and send us the exact message you receive there?
Best regards,
cTrader Team
Sure. All my instances are running Renko charts. Here's a few distinct ones from the Event Viewer -> Windows Logs -> Application:
Faulting application name: cTrader.exe, version: 4.6.4.13909, time stamp: 0x6406f01d
Faulting module name: KERNELBASE.dll, version: 6.3.9600.20876, time stamp: 0x6400576c
Exception code: 0xe0434352
Fault offset: 0x000000000001804c
Faulting process id: 0xd14
Faulting application start time: 0x01d962211908bc00
Faulting application path: C:\Users\Administrator\AppData\Local\Spotware\cTrader\abb70432efbee65d18af69e79fe8efe1\cTrader.exe
Faulting module path: C:\windows\system32\KERNELBASE.dll
Report Id: 0e81d030-ce24-11ed-811f-8509a194ebd8
Faulting package full name:
Faulting package-relative application ID:
///////////////////////////////////////////////
Application: cTrader.exe
CoreCLR Version: 6.0.21.52210
.NET Version: 6.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
at cTrader.Automate.TargetProcess.TargetProcessBase.Stop()
at cTrader.Automate.Runtime.OutProc.OutProcRuntimeHost.Stop()
at cTrader.Automate.AutomateRuntimeSessionProvider.TryStopHost(AutomateId automateId)
at cTrader.Automate.Instances.AutomateInstance.Dispose()
at cTrader.Automate.ChartAutomation.AutomateChartAutomation.Dispose()
at cTrader.Chart.Infrastructure.Automation.ChartAutomationRepository.Dispose()
at Autofac.Core.Disposer.Dispose(Boolean disposing)
at Autofac.Util.Disposable.Dispose()
at Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing)
at Autofac.Util.Disposable.Dispose()
at cTrader.Infrastructure.Lifetime.LifetimeScopeService.Remove(Guid identity)
at cTrader.Chart.Infrastructure.TradeChartRepository.Dispose()
at Autofac.Core.Disposer.Dispose(Boolean disposing)
at Autofac.Util.Disposable.Dispose()
at Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing)
at Autofac.Util.Disposable.Dispose()
at Autofac.Core.Container.Dispose(Boolean disposing)
at Autofac.Util.Disposable.Dispose()
at cTrader.CTraderBootstrapper.OnShutdownFinished(Object sender, EventArgs e)
at System.Windows.Threading.Dispatcher.ShutdownImplInSecurityContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.Dispatcher.ShutdownImpl()
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at cTrader.App.Main()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at cTrader.AppHostEndpoint.ExecuteStaticMethod(Assembly assemblyProxy, String typeName, String methodName)
at cTrader.AppHostEndpoint.RunApplication(String productDirectory)
at cTrader.AppHostEndpoint.Launcher.Main(IntPtr arg, Int32 argLength)
////////////////////////////////////////////////////
The description for Event ID 0 from source Application cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Error occurred in frmDetails.RDPTimer_Tick
The parameter 'addresses' cannot be an empty string.
Parameter name: addresses
the message resource is present but the message is not found in the string/message table
////////////////////////////////////////////////////
Fault bucket , type 0
Event Name: APPCRASH
Response: Not available
Cab Id: 0
Problem signature:
P1: cTrader.exe
P2: 4.6.4.13909
P3: 6406f01d
P4: KERNELBASE.dll
P5: 6.3.9600.20876
P6: 6400576c
P7: e0434352
P8: 000000000001804c
P9:
P10:
Attached files:
These files may be available here:
C:\Users\Administrator\AppData\Local\Microsoft\Windows\WER\ReportArchive\AppCrash_cTrader.exe_a0ee1be6efe6301dd91763eb5318a7e6572d8c88_4f91f2c9_3343768b
Analysis symbol:
Rechecking for solution: 0
Report Id: 58df2e07-cdf5-11ed-811f-8509a194ebd8
Report Status: 2048
Hashed bucket:
///////////////////////////////////////////////
@firemyst
firemyst
16 Apr 2023, 05:52
I can see a potential issue on this line with sell orders:
You probably mean to use the following like you do under buy orders:
since the issue you have always only happens with sell orders.
@firemyst