Why this code block not calculated the lot size correctly?

 

I use this code block to calculate the lot size. but when it comes to indices the calculation is very different.

as an example, this code block calculates lot size for 10,000$ account with 1:500 leverage is around 3.0 lots. but when it comes to balance 6,000$ with 1:100 leverage, the code is calculated the lot size same as 3.0 lots. but it too big to place and order with that lot size for 6,000$ with 1:100 leverage. 

What kind a modification should I do this to work in all different pairs and different brokers with different leverages.  


#include <Trade\Trade.mqh>
CTrade trade;

double LotSize;
double ask;
double Stoploss = 2000.0; // SL in Points
double Risk = 1; // Risk % of Account

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {

  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   Stoploss = NormalizeDouble(ask - (Stoploss * Point()),_Digits);

   double Balance = AccountInfoDouble(ACCOUNT_BALANCE);
   double RiskOnBalance = NormalizeDouble((Balance * Risk) / 100,2);

   double LotSize = NormalizeDouble(RiskOnBalance / (Stoploss * Point()),2);

// Open Trade.
   trade.Buy(LotSize,NULL,ask,Stoploss,0,NULL);

  }
//+------------------------------------------------------------------+
 

Search for this

ENUM_SYMBOL_CALC_MODE

there is the Description inside

Reason: