Topics
Replies

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
01 Dec 2024, 14:30 ( Updated at: 02 Dec 2024, 06:51 )

On every bar, try redrawing the indicator at the “LastVisibleBarIndex”.

Documented here:

https://help.ctrader.com/ctrader-algo/references/Chart/Chart/#lastvisiblebarindex

 


@firemyst

firemyst
01 Dec 2024, 14:26

You can run a cbot on Renko charts. However, how well it runs and performs will obviously depend if its logic is built to handle the way Renko charts work. 

For example, the open price isn't fixed until the current renko bar closes. 


@firemyst

firemyst
01 Dec 2024, 14:24

What's the error you receive?


@firemyst

firemyst
27 Nov 2024, 10:41

Me too. Seems like most of the brokers that offer cTrader, only allow MT4/5 copy trading, and not actual cTrader copy trading.

 


@firemyst

firemyst
27 Nov 2024, 00:15

Why don't you post the code that you have, along with what you'd like it to do, so people can look at it and help you as appropriate?


@firemyst

firemyst
26 Nov 2024, 00:58

Exactly. I'm always having to change the setting to “last added” before viewing anything in the forums


@firemyst

firemyst
26 Nov 2024, 00:57

I don't know what the issue is from looking at the files you posted.

However, brute force way to try and fix it (no guarantees!) – take a backup copy of your actual C# code.

Delete the indicator/cbot from cTrader.

Once deleted, go back and create a new indicator/cbot, adding references as appropriate.

Build it in cTrader.

Then select to edit in Visual studio.

Paste in your C# code from your backup.

hopefully it'll then build successfully.

The only drawback with this approach is if you have anything saved in a “template”, it may have to be readded.


@firemyst

firemyst
25 Nov 2024, 13:21 ( Updated at: 25 Nov 2024, 14:02 )

Here's the basic logic you'll need to try coding yourself:

Use the Timer object (code samples in the link) :

https://help.ctrader.com/ctrader-algo/references/Timer/Timer/#timertick

Set the interval to 1 second.

Then in the timerTick method, count the number of seconds (essentially each time the event method is called)

When it equals 4, run code to set your SL;

When it equals 10, run code to set your TP.

After both have been set, stop the timer.

 


@firemyst

firemyst
25 Nov 2024, 07:21

RE: Deposits-withdrawals collections / events

 

Do you want to add something else here, maybe? What about being pragmatic?

I never said I wanted a solution not involving cBots. What I don't want is a “solution” that can be only achieved if/while a cBot is running. Can't you really understand the difference?
I suggest that you read my previous reply, again.

 

I do understand the difference perfectly. You haven't specified this requirement until now, so you're handicapping people who are reading and wanting to help. 

Please screen capture your post where you explicitly stated this requirement of not wanting a solution while a cbot is running prior to this response if you believe otherwise. 

It's not here:

 

I don't see anything here indicating you want such a solution:

 

It's not here either. Even after your point 2 below, you haven't clarified. In fact, point 3 you explicitly ask how to get this info when starting a cbot: 

 

And it's not in this response that I'm responding to.

So you're criticizing my replies of not understanding the difference between things, when somehow, you expect me to know all your ‘requirements’ that you haven't clearly stated.

 


@firemyst

firemyst
24 Nov 2024, 09:40

Open up the Visual Studio “.csproj” file.

You'll see a section similar to:

<ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="1.*" />
 </ItemGroup>

Or maybe even:

 <ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="*" />
 </ItemGroup>

In previous incarnations, I think the version was hard coded like such:

 <ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="1.1" />
 </ItemGroup>


@firemyst

firemyst
23 Nov 2024, 09:39

RE: RE: RE: Order Execution Error : Nothing to change

PanagiotisCharalampous said: 

firemyst said: 

Below is some sample code you can run on a forex symbol like EURJPY to demonstrate the lack of information.

The output from the log is:

Note that it doesn't say, “Nothing to Change” in the error reported, the symbol name, or anything. Just says, “invalid request”, which to me makes no sense when someone's looking for the actual error message in log files. “invalid request” can happen for any number of reasons, and means we have to keep bothering our broker to find out what and why was an “invalid request”.

 

Ok so at least you get a response and a message. I will suggest to the team to enhance the message.

 

Would you be able to suggest to them they enhance this message too in addition to the one “Nothing to change”? 

This is an example where I had to write the broker because “invalid request” in the logs didn't match with what's actually happening. In this message, it says, “Nothing to amend”, but “nothing to amend” isn't printed out in the error message returned in the calgo logs. 

 

 


@firemyst

firemyst
22 Nov 2024, 06:16

RE: RE: RE: Order Execution Error : Nothing to change

Panagio

 

Ok so at least you get a response and a message. I will suggest to the team to enhance the message.

I suppose the question for the team to consider is - should it even throw an error message if there's nothing to change? As opposed to, say, a warning? (depending on how the server side captures/responds to different severity levels)

 


@firemyst

firemyst
22 Nov 2024, 02:11 ( Updated at: 22 Nov 2024, 05:59 )

RE: Order Execution Error : Nothing to change

PanagiotisCharalampous said: 

Hi firemyst,

Nor does it seem to be returned when checking a TradeResult object for error messages (unless I'm doing that wrong).

Can you share the code you are using so that we can see what you are doing? The below should work

Print("Error: {0}", TradeResult.Error);

Best regards,

Panagiotgis

Below is some sample code you can run on a forex symbol like EURJPY to demonstrate the lack of information.

The output from the log is:

Note that it doesn't say, “Nothing to Change” in the error reported, the symbol name, or anything. Just says, “invalid request”, which to me makes no sense when someone's looking for the actual error message in log files. “invalid request” can happen for any number of reasons, and means we have to keep bothering our broker to find out what and why was an “invalid request”.

Code to reproduce:

using System;
using cAlgo.API;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TokyoSessionStrategy : Robot
    {
        private Position _p;
        private int _tickCount;

        protected override void OnStart()
        {
            _p = null;
            _tickCount = 0;
        }

        protected override void OnTick()
        {
            TradeResult r;
            if (_p == null)
            {
                r = ExecuteMarketOrder(TradeType.Buy, SymbolName, 1000, "TESTBOT");
                if (!r.IsSuccessful)
                {
                    Print("Order not successful. Please restart bot. Error message {0}", r.Error.Value.ToString());
                }
                else
                {
                    _p = Positions.Find("TESTBOT");
                }
            }

            Print("TICK COUNT {0}", _tickCount.ToString());
            
            if (_tickCount % 5 == 0 && _p != null)
            {
                Print("Modifying order");
                r = _p.ModifyStopLossPrice(_p.StopLoss.GetValueOrDefault());
                if (!r.IsSuccessful)
                {
                    Print("Order not successful. Error message:");
                    Print("1 {0}", r.Error);
                    Print("2 {0}", r.Error.Value.ToString());
                }
            }
            _tickCount++;
        }

        protected override void OnStop()
        {
            if (_p != null)
            {
                _p.Close();
            }
            base.OnStop();
        }
    }
}

 

 


@firemyst

firemyst
22 Nov 2024, 01:06 ( Updated at: 22 Nov 2024, 05:59 )

@PanagiotisCharalampous and/or @Spotware?


@firemyst

firemyst
22 Nov 2024, 01:02

RE: RE: RE: RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

PanagiotisCharalampous said: 

 

We do not have an ETA unfortunately. It will be released in one of the following updates

I didn't see any release notes for 5.0.46. 

Is this issue resolved in 5.0.46?


@firemyst

firemyst
22 Nov 2024, 00:54

Are you going to post release notes for 5.0.46?


@firemyst

firemyst
22 Nov 2024, 00:26

RE: RE: RE: RE: Deposits-withdrawals collections / events

ncel01 said: 

 

  1. Balance/equity are not only affected by deposit/withdrawals.

You're initial post only referred to “balance”, not “equity”. 

An account balance either increases in funds available, or decreases. Those could be caused by transfers, positions being closed, or something else. But at the end of the day, an account balance is either going to “increase” or “decrease”, either from funds being deposited into the account, or withdrawn from the account. 

So genuinely asking, what else is “balance” affected by in your situation? 

 

  1. Why do you assume that a cBot is running when a deposit/withdrawal takes place?

I haven't assumed a cbot has to be running when a deposit/withdrawal takes place. 

However, your initial post said you need to access the information via API. Code can only access an API when code is executed. Now, since your post is in the “calgo” forum, which is primarily for bots/indicators/plugins, even by Spotware's own definition: “cTrader Algo is an all-in-one solution that gives users the opportunity to use various automated trading tools including custom indicators, cBots and plugins.”

Couple that with the fact an API can only be access when code is executed, …. that's the reasoning. Whether it's a bot running, or even something simple like dragging/dropping an object on the screen, code has to be executed for an API to be accessed.

If it's for another reason not related to a bot/indicator/plugin, like you're creating your own trading interface or application, or calling a web service or something else, then perhaps you should have posted in either the “Fix API” or “Open API” forums?

 

Moreover, withdrawal and deposits are basic properties of an account. It shouldn't be necessary to convince anyone about this.

No disagreement about this. :-)

I would suggest putting these into the “Suggestions” forum if you want to see Spotware possibly implement them in the future.

 

 


@firemyst