... in this part of code is a problem with new compilation (error ---> 'MarketInfo' - illegal switch expression type) perhaps it was all OK until the update to MT4 build 600+ ... but since then it doesn't work any longer.
So, could you please post some newer version ... if of course you're still around.
I think if you change
switch ( MarketInfo( strSymbol, MODE_DIGITS ) )
to
int dig=MarketInfo( strSymbol, MODE_DIGITS ) ;
switch ( dig )
... in this part of code is a problem with new compilation (error ---> 'MarketInfo' - illegal switch expression type) perhaps it was all OK until the update to MT4 build 600+ ... but since then it doesn't work any longer.
So, could you please post some newer version ... if of course you're still around.
"The values of Expression and of Parameters can only be the values of int type. The Expression can be a constant, a variable, a function call, or an expression. Each variation 'case' can be marked by an integer constant, a character constant, or a constant expression. A constant expression cannot include variables or function calls."
Sebastien Pelle: In my different EA, it's write like this :
double lot = MathCeil(AccountFreeMargin() * Risk_Percent / 1000) /
Free margin has nothing to do with your risk. It is your brokers stop loss (50% of your account.)
You should have read the entire thread and not posted. Summarized:
You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
... in this part of code is a problem with new compilation (error ---> 'MarketInfo' - illegal switch expression type) perhaps it was all OK until the update to MT4 build 600+ ... but since then it doesn't work any longer.
So, could you please post some newer version ... if of course you're still around.
I think if you change
switch ( MarketInfo( strSymbol, MODE_DIGITS ) )to
It will compile ok
... in this part of code is a problem with new compilation (error ---> 'MarketInfo' - illegal switch expression type) perhaps it was all OK until the update to MT4 build 600+ ... but since then it doesn't work any longer.
So, could you please post some newer version ... if of course you're still around.
https://book.mql4.com/operators/switch
"The values of Expression and of Parameters can only be the values of int type. The Expression can be a constant, a variable, a function call, or an expression. Each variation 'case' can be marked by an integer constant, a character constant, or a constant expression. A constant expression cannot include variables or function calls."
Once again, you come up with a simpler and better solution.
In my different EA, it's write like this :
extern double Risk_Percent = 3;
extern int StopLoss = 50;
//+------------------------------------------------------------------+
{
double lot = MathCeil(AccountFreeMargin() * Risk_Percent / 1000) / 100;
if(lot<MarketInfo(Symbol(),MODE_MINLOT))lot=MarketInfo(Symbol(),MODE_MINLOT);
if(lot>MarketInfo(Symbol(),MODE_MAXLOT))lot=MarketInfo(Symbol(),MODE_MAXLOT);
return (MathMin(NormalizeDouble(lot,PipMultiplier),MaxLotSize));
}
//+------------------------------------------------------------------+
if(_Digits==5 || _Digits==3)PipMultiplier=10;
else PipMultiplier=1;
slippage=Slippage*PipMultiplier;
if(_Digits<4)
{
point=0.01;
}
else
{
point=0.0001;
}
return(0);
//+------------------------------------------------------------------+
double lot = MathCeil(AccountFreeMargin() * Risk_Percent / 1000) /