Topics
22 May 2024, 04:57
 482
 4
27 Dec 2023, 08:49
 1
 407
 1
17 Jul 2021, 11:38
 26
 2554
 8
28 May 2020, 13:03
 7
 1168
 1
24 Sep 2019, 16:57
 7
 1749
 3
04 Feb 2019, 19:33
 2021
 3
17 Dec 2018, 12:46
 1658
 1
12 Oct 2018, 08:30
 2510
 2
24 Aug 2018, 11:04
 1908
 2
Replies

ctrader.guru
15 Jun 2021, 08:47

RE:

Spotware said:

Dear traders,

The winner of the cTrader Community Member of the Month award for May is Leonardo Ciaccio (@LeonardoCiaccio)! Leonardo Ciaccio is the owner of cTrader Guru, a company specialized on cTrader cBots and Indicators. At the same time Leonardo manages his own Telegram channel which focuses on providing trading signals and engaging with Italian speaking cTrader users. Leonardo is also a frequent contributor of custom cBots and Indicators as well as a participant in other community channels.

Congratulations to Leonardo!


@ctrader.guru

ctrader.guru
07 Jul 2020, 10:16

 This project work fine 

 


@ctrader.guru

ctrader.guru
06 Dec 2019, 16:12 ( Updated at: 21 Dec 2023, 09:21 )

cTrader Guru

Hi all,

we are the first and only Italian reference for cTrader, we offer assistance in Italian and English for cTrader and for all our paid and open source products.

 

 


@ctrader.guru

ctrader.guru
03 Sep 2019, 10:20 ( Updated at: 21 Dec 2023, 09:21 )

Thanks !

 


@ctrader.guru

ctrader.guru
03 Sep 2019, 10:06 ( Updated at: 21 Dec 2023, 09:21 )


@ctrader.guru

ctrader.guru
02 Feb 2019, 23:53

Use Account.PreciseLeverage instead of Symbol.DynamicLeverage[0].Leverage obviously adapt the method to your needs :

double marginEURUSD = _calculateMargin("EURUSD", 1, Account.Currency, Account.PreciseLeverage);

if the symbol is not managed, zero is returned


@ctrader.guru

ctrader.guru
01 Feb 2019, 12:22

RE: RE: Best way for me ...

ctrader.guru said:

ctrader.guru said:

Hi all,

some of our customers asked us how to correctly calculate the required margin, this is an example to follow


        private bool _symbolExist(string symbolCode) {

            return MarketData.GetSymbol(symbolCode) != null;

        }

        private double _symbolRate(string symbolCode)
        {

            return (_symbolExist(symbolCode)) ? MarketData.GetSymbol(symbolCode).Bid : 0;

        }

        private double _calculateMargin( string symbolCode, double lots, string currency, double leverage ) {

            double margin = 0.0;

            if (!_symbolExist(symbolCode) || symbolCode.Length != 6) return margin;

            currency = currency.ToUpper();

            double symbolRate = _symbolRate(symbolCode);
            if (symbolRate == 0) return margin;

            string baseCurrency = symbolCode.Substring(0, 3).ToUpper();
            string subaCurrency = symbolCode.Substring(3, 3).ToUpper();

            if (currency.Equals(baseCurrency)) 
            {

                margin = lots * 100000 / leverage;

            }
            else if (currency.Equals(subaCurrency)){ 

                margin = lots * 100000 / leverage * symbolRate;

            }
            else { 

                symbolRate = _symbolRate(baseCurrency + currency);
                if (symbolRate == 0)
                {

                    symbolRate = _symbolRate(currency + baseCurrency);
                    if (symbolRate == 0) return margin;

                    symbolRate = 1 / symbolRate;

                }                

                margin = lots * 100000 / leverage * symbolRate;

            }

            return (margin > 0) ? Math.Round( margin, 2 ) : 0;

        }

 

 

Like this :

protected override void OnStart()
{

            // --> TEST

            double marginEURUSD = _calculateMargin("EURUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginGBPUSD = _calculateMargin("GBPUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginAUDUSD = _calculateMargin("AUDUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginUSDJPY = _calculateMargin("USDJPY", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginCADJPY = _calculateMargin("CADJPY", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);

            _printExcep("EURUSD : " + marginEURUSD.ToString());
            _printExcep("GBPUSD : " + marginGBPUSD.ToString());
            _printExcep("AUDUSD : " + marginAUDUSD.ToString());
            _printExcep("USDJPY : " + marginUSDJPY.ToString());
            _printExcep("CADJPY : " + marginCADJPY.ToString());

            Stop();

}

 

 

Sorry _printExcep is my method

protected override void OnStart()
{
 
            // --> TEST
 
            double marginEURUSD = _calculateMargin("EURUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginGBPUSD = _calculateMargin("GBPUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginAUDUSD = _calculateMargin("AUDUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginUSDJPY = _calculateMargin("USDJPY", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginCADJPY = _calculateMargin("CADJPY", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
 
            Print("EURUSD : " + marginEURUSD.ToString());
            Print("GBPUSD : " + marginGBPUSD.ToString());
            Print("AUDUSD : " + marginAUDUSD.ToString());
            Print("USDJPY : " + marginUSDJPY.ToString());
            Print("CADJPY : " + marginCADJPY.ToString());
 
            Stop();
 
}

 

Admin, why can't edit post ?


@ctrader.guru

ctrader.guru
01 Feb 2019, 12:19

RE: Best way for me ...

ctrader.guru said:

Hi all,

some of our customers asked us how to correctly calculate the required margin, this is an example to follow


        private bool _symbolExist(string symbolCode) {

            return MarketData.GetSymbol(symbolCode) != null;

        }

        private double _symbolRate(string symbolCode)
        {

            return (_symbolExist(symbolCode)) ? MarketData.GetSymbol(symbolCode).Bid : 0;

        }

        private double _calculateMargin( string symbolCode, double lots, string currency, double leverage ) {

            double margin = 0.0;

            if (!_symbolExist(symbolCode) || symbolCode.Length != 6) return margin;

            currency = currency.ToUpper();

            double symbolRate = _symbolRate(symbolCode);
            if (symbolRate == 0) return margin;

            string baseCurrency = symbolCode.Substring(0, 3).ToUpper();
            string subaCurrency = symbolCode.Substring(3, 3).ToUpper();

            if (currency.Equals(baseCurrency)) 
            {

                margin = lots * 100000 / leverage;

            }
            else if (currency.Equals(subaCurrency)){ 

                margin = lots * 100000 / leverage * symbolRate;

            }
            else { 

                symbolRate = _symbolRate(baseCurrency + currency);
                if (symbolRate == 0)
                {

                    symbolRate = _symbolRate(currency + baseCurrency);
                    if (symbolRate == 0) return margin;

                    symbolRate = 1 / symbolRate;

                }                

                margin = lots * 100000 / leverage * symbolRate;

            }

            return (margin > 0) ? Math.Round( margin, 2 ) : 0;

        }

 

 

Like this :

protected override void OnStart()
{

            // --> TEST

            double marginEURUSD = _calculateMargin("EURUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginGBPUSD = _calculateMargin("GBPUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginAUDUSD = _calculateMargin("AUDUSD", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginUSDJPY = _calculateMargin("USDJPY", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);
            double marginCADJPY = _calculateMargin("CADJPY", 1, Account.Currency, Symbol.DynamicLeverage[0].Leverage);

            _printExcep("EURUSD : " + marginEURUSD.ToString());
            _printExcep("GBPUSD : " + marginGBPUSD.ToString());
            _printExcep("AUDUSD : " + marginAUDUSD.ToString());
            _printExcep("USDJPY : " + marginUSDJPY.ToString());
            _printExcep("CADJPY : " + marginCADJPY.ToString());

            Stop();

}

 


@ctrader.guru

ctrader.guru
01 Feb 2019, 12:14

Best way for me ...

Hi all,

some of our customers asked us how to correctly calculate the required margin, this is an example to follow


        private bool _symbolExist(string symbolCode) {

            return MarketData.GetSymbol(symbolCode) != null;

        }

        private double _symbolRate(string symbolCode)
        {

            return (_symbolExist(symbolCode)) ? MarketData.GetSymbol(symbolCode).Bid : 0;

        }

        private double _calculateMargin( string symbolCode, double lots, string currency, double leverage ) {

            double margin = 0.0;

            if (!_symbolExist(symbolCode) || symbolCode.Length != 6) return margin;

            currency = currency.ToUpper();

            double symbolRate = _symbolRate(symbolCode);
            if (symbolRate == 0) return margin;

            string baseCurrency = symbolCode.Substring(0, 3).ToUpper();
            string subaCurrency = symbolCode.Substring(3, 3).ToUpper();

            if (currency.Equals(baseCurrency)) 
            {

                margin = lots * 100000 / leverage;

            }
            else if (currency.Equals(subaCurrency)){ 

                margin = lots * 100000 / leverage * symbolRate;

            }
            else { 

                symbolRate = _symbolRate(baseCurrency + currency);
                if (symbolRate == 0)
                {

                    symbolRate = _symbolRate(currency + baseCurrency);
                    if (symbolRate == 0) return margin;

                    symbolRate = 1 / symbolRate;

                }                

                margin = lots * 100000 / leverage * symbolRate;

            }

            return (margin > 0) ? Math.Round( margin, 2 ) : 0;

        }

 


@ctrader.guru

ctrader.guru
17 Dec 2018, 12:49 ( Updated at: 21 Dec 2023, 09:21 )

New dashboard here


@ctrader.guru

ctrader.guru
06 Sep 2018, 14:33 ( Updated at: 21 Dec 2023, 09:20 )

 


@ctrader.guru

ctrader.guru
24 Aug 2018, 11:06 ( Updated at: 21 Dec 2023, 09:20 )

RE:

ctrader.guru said:

Amazing Price Action absolutely free download now and start your strategy with good direction

 

Two Amazing Price Action red for 7 period and blue for 8 period


@ctrader.guru

ctrader.guru
23 Jul 2018, 18:44

great work, thanks ...


@ctrader.guru