Replies

lukas.ourada
07 Jan 2022, 13:03

RE:

amusleh said:

Hi,

Did you tried to uninstall/re-install cTrader?

Hi, thanks for you reply.

Yes a try uninstall all version ctrader (roboforex, icm) and instal now clean version. I try too reinstall visual studio 2019, but still not work :-( 


@lukas.ourada

lukas.ourada
19 Jan 2021, 12:25

Hi, I needed something similar. I don't know why it can't be automated in the cTrader API, but I think the broker probably changes these rates and they are not in the historical data between Ticks. I solved temporarily by creating my own configurable parameter swapLong , swapShort and to OnTimer () write this code:

 

if (Time.Hour == 23 && Time.Minute == 0 && Time.Second == 0)
 {
   if (Time.DayOfWeek == DayOfWeek.Wednesday)
   {
    ZjistiObjemObchodu();

    double a = selllots / 100000 * SwapShort * PipValue* 3;
    double b = buylots / 100000 * SwapLong * PipValue* 3;
    double ab = a + b;

    SwapCelkem += ab;

    Print("Today was a three-day swap, the total is now paid " + Math.Round((SwapCelkem), 2) + Account.Currency);
                       

    }
    else if (Time.DayOfWeek == DayOfWeek.Saturday)
    {
        Print("--------------- Today is Saturday ---------------");

    }
    else if (Time.DayOfWeek == DayOfWeek.Sunday)
    {
         Print("--------------- Today is Sunday ---------------");
    }
    else
    {

    ZjistiObjemObchodu();

    double a = selllots / 100000 * SwapShort * HodnotaPipu;
    double b = buylots / 100000 * SwapLong * HodnotaPipu;
    double ab = a + b;

    SwapCelkem += ab;

    Print("Swap total is: " + Math.Round((SwapCelkem), 2) + Account.Currency);

   
    }



}


void ZjistiObjemObchodu()
        {
            buylots = 0;
            selllots = 0;

            foreach (var position in Positions)
            {
                if (position.SymbolCode == Symbol.Code)
                {
                    double lot = position.VolumeInUnits;

                    if (position.TradeType == TradeType.Buy)
                    {
                        buylots += lot;
                    }

                    if (position.TradeType == TradeType.Sell)
                    {
                        selllots += lot;
                    }
                }
            }


        }

it calculates the total swap which you set in the parameters according to your broker (its in cTrader/trade/ panel symbol details) and writes it to the console. At the same time, it is also in the SwapTotal variable, so you can use it to get the actual real account equity and balance by subtraction it.

maybe it will help

Sorry for my bad english :-)

Lukas

 

 


@lukas.ourada

lukas.ourada
17 May 2019, 16:11

RE:

Panagiotis Charalampous said:

Hi Lukas,

It is not possible to have an array as an input parameter. You can get the values as string and use string.Split() to make the separation into an array.

Best Regards,

Panagiotis

 

ok thank you

i try it


@lukas.ourada

lukas.ourada
30 Mar 2019, 11:53 ( Updated at: 21 Dec 2023, 09:21 )

RE: RE:

alexander.n.fedorov said:

lukas.ourada said:

 

Hi, i have problem with run optimization for my cBot. Backtesting works good, but if i run optimization not have any result, not position open and is end while 3sec.

what is wrong? Its bug?

I try change parameters, unchecked it and try my two other cBot and same result...

 

Please help

screenshot

Try to read what log says, just make sure it shows all the information  ("All events")

Hi,

thank you, now is OK. Problem with not supported chartobjects in optimization...


@lukas.ourada

lukas.ourada
25 Mar 2019, 18:06

RE:

lgwsyqnfr said:

           double buylots =0, selllots =0;

           foreach (var position in Positions)
            {
                if (position.SymbolCode == Symbol.Code)
                {
                    double lot = position.VolumeInUnits;

                    if (position.TradeType == TradeType.Buy)
                    {
                        buylots += lot;
                    }

                    if (position.TradeType == TradeType.Sell)
                    {
                        selllots += lot;
                    }
                }
            }

 

Thank you very much, work perfect!


@lukas.ourada

lukas.ourada
23 Mar 2019, 09:22

hi
i use only AUDCAD or XAUUSD. Best solution for my is get total volume by symbol (not all pair together).


@lukas.ourada

lukas.ourada
18 Mar 2019, 14:40

Hi,

thanks for you very speed answer!

Netting account not possible for me, my cBot use hedging. i find solution only for reduction many sell position and many buy position. Example by price range to group for clear graf, median price and close all by group. Merge position would be the ideal solution :-( 

thanks


@lukas.ourada

lukas.ourada
14 Mar 2019, 14:47

hi
firstly thanks, good job.
looks good!

me like grouping parametr and custom enums for input parameters, but style of parametr panel is best in old 3.3! 

I don't like to click on a button every time I want to change something !!!

I would also welcome to add parameters to the imput text area. For example, to set the text of notification emails.

and also the tooltip options so I can write a parameter description in the code, and after hovering the mouse the user could read the comment

and the question: when will 3.5 be officially for brokers?

Thanks


@lukas.ourada