MaxVolume

Created at 28 Apr 2015, 17:42
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
KA

kamol

Joined 03.02.2015

MaxVolume
28 Apr 2015, 17:42


Hi

It would be good if someone writes MaxLot (MaxVolume) indicator for cTrader

input parameters

MinLot (0.1)

CapitalUse (50) // in percent

Algorithm: MaxLot = (FreeMargin-(Equity*(1-CapitalUse/100)))*Leverage/MarginRequiredForPerLot

MaxLot should be normalized till MinLot

Indicator should show 2 things

1. MaxVolume which can be added to existing positions

2. Reversal MaxVolume - MaxVolume in case of closing all existing positions and opening reversal positions

Thanks all who tries to write

 

 

 


@kamol
Replies

kamol
06 May 2015, 16:11

I wrote it as follows. But there is something wrong. Please, help me correct it

 

       private long MAXLOT(double ml, double cap)
        {
            var lvr = Account.Leverage;
            var FM = Account.FreeMargin;
            var AE = Account.Equity;
            long xx = 0;
            double ER = AE * (1 - (CapUse / 100));
            double EU = FM - ER;
            var MaxLot = EU * lvr / (Symbol.Ask * Symbol.LotSize);
            if (MaxLot > ml)
            {
                var lot = Symbol.NormalizeVolume(MaxLot, RoundingMode.ToNearest);
                xx = Symbol.QuantityToVolume(lot);
            }
            return (xx);
        }


 


@kamol

Spotware
17 Jun 2015, 17:49

Dear Trader,

You use “CapUse” in your method which is not defined somewhere. Maybe you wanted to write “cap” instead. Please note that we do not provide coding assistance services. We more than glad to assist you with specific questions about cAlgo.API. You also can contact one of our Partners or post a job in Development Jobs section for further coding assistance.


@Spotware