wait4signal / sharing-is-caring

MetaTrader 5 trade copier
GNU General Public License v3.0
26 stars 15 forks source link

[SAME_AS_PROVIDER] receiver order 1 lot when provider only 0.01 #4

Closed batara666 closed 1 year ago

bgabela commented 2 years ago

The lot calculation takes the leverage as well as minimum size configured on receiver broker side so this would be trickier to troubleshoot without that additional info. Below is the code snippet that does the calculation:

double volume = prRecord.positionVolume;
         if(PROPORTIONAL_TO_BALANCE == LOT_SIZE) {
            double receiverAvailableFunds = balance;
            volume = volume * (receiverAvailableFunds/prAccountBalance);
         }

         //Check leverage
         double marginInit;
         double marginMaint;
         SymbolInfoMarginRate(positionSymbol,(prRecord.positionType == 0 ? ORDER_TYPE_BUY : ORDER_TYPE_SELL),marginInit,marginMaint);
         int positionLeverage = 1/(NormalizeDouble(marginInit,3));
         double receiverLeverage = AccountInfoInteger(ACCOUNT_LEVERAGE);

         volume = volume * ((receiverLeverage*positionLeverage)/(prAccountLeverage*prRecord.positionLeverage));
bgabela commented 1 year ago

Lot calculation fixed added and deployed to mql5 market. Also added option to not use leverage when calculating lot size. Please check if your issue is sorted.