Topics

Forum Topics not found

Replies

amusleh
18 Nov 2021, 10:03

Hi,

To get last four lost trades net profit you can filter the lost trades first then order them, after that take the last four:

var result = History.Where(trade => trade.SymbolName.Equals(SymbolName, StringComparison.OrdinalIgnoreCase) && trade.NetProfit < 0).OrderByDescending(trade => trade.EntryTime).Take(4).Sum(trade => trade.NetProfit);

 


@amusleh

amusleh
18 Nov 2021, 08:40

Hi,

To get the last four values you can use OrderByDescending and Take, but on your posted sequence the values you are looking to get aren't last four.

You can first skip the last 2 values and then use Take to get the last 4 values:

var result = History.Where(trade => trade.SymbolName.Equals(SymbolName, StringComparison.OrdinalIgnoreCase)).OrderByDescending(trade => trade.EntryTime).Skip(2).Take(4).Sum(trade => trade.NetProfit);

 


@amusleh

amusleh
18 Nov 2021, 08:34

Hi,

Right now the cTrader Automate API Visual Studio extension is not supporting Visual Studio 2022, we will start supporting Visual studio 2022 after we migrated to .NET 6.

Please wait for cTrader 4.2 release.


@amusleh

amusleh
17 Nov 2021, 08:04

Hi,

Do you mean Commodity Channel Index? if that's what you meant by CCI then this indicator is available as a built-in indicator of cTrader and you can use it on your cBot like any other indicator.

Check here for an example: cAlgo API Reference - CommodityChannelIndex Interface (ctrader.com)


@amusleh

amusleh
17 Nov 2021, 07:57

Hi,

Did you checked the API references example: cAlgo API Reference - IndicatorDataSeries Interface (ctrader.com)

You have to store your calculation result inside an IndicatorDataSeries, then you can use that data series on your cBots.


@amusleh

amusleh
17 Nov 2021, 07:55

Hi,

I didn't understood your issue, but If you are not using multiple symbols data for taking trading decision then there is no need to use multiple symbols on your cBot.

Just create a new instance of your cBot for each symbol you want to trade.

That way you keep your cBot code simple.


@amusleh

amusleh
17 Nov 2021, 07:46

Hi,

Each symbol has a minimum and maximum volume properties that you can use for checking the symbol minimum and maximum allowed trading volume.

The properties are in in volume units not lots, you can use the symbol VolumeInUnitsToQuantity method to change the volume units to lots.


@amusleh

amusleh
17 Nov 2021, 07:44

Hi,

Can you send us the whole cBot project folder? maybe you made some changes on the cBot project files.


@amusleh

amusleh
05 Nov 2021, 09:56

Hi,

No, there is no API function for getting a symbol category.

You can open a thread on suggestions section for this feature if you want to.


@amusleh

amusleh
05 Nov 2021, 07:39

Hi,

The Symbol property of indicators/cBots is the chart symbol.

To get other symbols use the Symbols collection:

var symbol = Symbols.GetSymbol("EURUSD");

 


@amusleh

amusleh
05 Nov 2021, 07:37

Hi,

The time zone is in your cBot/Indicator time zone that you set on "Robot/Indicator" attribute at the top of your cBot/indicator.


@amusleh

amusleh
05 Nov 2021, 07:35

Hi,

You can use history to sum the net profit of all your closed positions (trades):

var netProfit = History.Sum(trade => trade.NetProfit);

To get net profit of all your open positions you can use Positions:

var netProfit = Positions.Sum(position => position.NetProfit);

 


@amusleh

amusleh
04 Nov 2021, 08:03 ( Updated at: 04 Nov 2021, 08:04 )

Hi,

Your code has several issues, please fix the issues first then we will see if there is any scaling issue or not.

You are using the baseIndex for Bars, the baseIndex is for other time frame, you can't use it for Bars which is from current chart time frame.

For setting indicator outputs you are again using baseIndex, which is not correct, you have to use index for setting outputs not baseIndex.

Use the baseIndex only for getting the other time frame data, not for outputs of current chart time frame Bars.


@amusleh

amusleh
04 Nov 2021, 07:58

RE: RE: RE: RE:

yuval.ein said:

A. What does the Stop method does?

B. If I have several instances of the same cBot and one of them calls the Stop, does it effect the other instances?

 

 

Thanks

 

Hi,

No, it doesn't effect other instances, if you call Stop on a cBot it will only stop the instance that called the method not the other ones.


@amusleh

amusleh
04 Nov 2021, 07:57

Hi,

C# is a different programming language, its a managed programming language with garbage collection that runs on top of .NET runtime.

You can call unmanaged C++ DLL functions on C#, check this tutorial please: How to call a c++ dll in C#.net code - CodeProject


@amusleh

amusleh
03 Nov 2021, 15:25

RE: RE:

swapd0 said:

PanagiotisCharalampous said:

Hi swapd0,

Can you check if you can reproduce this problem using FIX API Sample? If you can connect using the sample, then compare the messages to find what is different.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

I can't test it with FIX API Sample because I have a Mac.

Hi,

You can use these samples on Mac: spotware/quickfixnsamples.net: .NET Samples for QuickFIXn library and Spotware FIX API (github.com)


@amusleh

amusleh
03 Nov 2021, 08:26

Hi,

I tested your code and something is wrong on it, because some of the outputs doesn't continue to the last bar.

Instead of using multiple time frames on a single indicator which makes debugging much harder for you I recommend you to use only one single time frame.

Develop an Ichimoku indicator that get just one time frame and then you can use three instance of that indicator for multiple time frames.

Regarding scaling, Ichimoku lines mostly follow the price and you should not have any scaling issue, the scaling issue occurs if your indicator lines are very far away from price series.


@amusleh

amusleh
03 Nov 2021, 08:19

RE: RE:

yuval.ein said:

Is there any way to determine it using some sort of a parameter or via the app's GUI?

 

Thanks

 

Hi,

No, its not possible, you have to use try/catch block inside your indicator/cBot code.


@amusleh

amusleh
03 Nov 2021, 08:18

Hi,

Field 108 is for heart beat interval and its required, here is a valid logon message that I just tested:

8=FIX.4.4|9=195|35=A|49=demo.ctrader.***|34=1|56=cServer|57=TRADE|50=TRADE|52=20211103-06:04:54.485|98=0|108=30|141=Y|553=***|554=***|10=026|

Are you sure you are connected to Trade end point? please check the host and port, maybe you are using Quotes port instead of Trade port.


@amusleh

amusleh
03 Nov 2021, 08:00

Hi,

OpenAPI only gives you time based bars, not Renko/Tick/Range bars data.

You can calculate the other bar types by using Tick data, you can get the tick data from Open API.

It's not on our roadmap to add the other bar types but you can post a suggestion and we might consider adding it on next versions of API.


@amusleh