![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
tell me is there a test system on the EA programing to show you step for step what happens when this EA runs
no, there is no stepping ftn for testing ; use Print to display values for checking and various parts of yr programs
I like your code for the Lots Optimisation ; I tweaked it to increase lot volume as losses increases
I like your code for the Lots Optimisation ; I tweaked it to increase lot volume as losses increases
show me please
or send me your EA
show me please
or send me your EA
it give me an error
Function "CalculateCurrentOrders" is not referenced and will be removed from exp-fileit give me an error
Function "CalculateCurrentOrders" is not referenced and will be removed from exp-filejust ignore this error; all it is saying is you have a function called CalculateCurrentOrders which you are not using; so either u delete it or levea; it will not cause any harm; the system is saying that is will remove this function from your compiled file ex4
show me please
or send me your EA
under the function LotOptimization change your code to something like this
lot=lot*MulltiplyingFactor*losses
where MulitplyFactor = 2 or 3 or 4 etc, similar to your DecreaseFactor which is to decrease yr lot sizes as kosses mount
having said that, increasing yr lot size as losses increased is dangerous to yr EA, so use with care
under the function LotOptimization change your code to something like this
lot=lot*MulltiplyingFactor*losses
where MulitplyFactor = 2 or 3 or 4 etc, similar to your DecreaseFactor which is to decrease yr lot sizes as kosses mount
having said that, increasing yr lot size as losses increased is dangerous to yr EA, so use with care
do you mean something like this
//+------------------------------------------------------------------+//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots*Multiplying*losses;
int orders=HistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//---- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
//----
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
}
//---- return lot size
if(lot<0.1) lot=0.1;
return(lot);
}
do you mean something like this
//+------------------------------------------------------------------+
//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots*Multiplying*losses;
int orders=HistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//---- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
//----
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1) lot=NormalizeDouble(Lots*Multiplying*losses;,1);}
//---- return lot size
if(lot<0.1) lot=0.1;
return(lot);
}
no, put it after the if(losses>1)
no, put it after the if(losses>1)
it gives me an error
'Multiplying' - variable not defined C:\Program Files\Interbank FX Trader 4\experts\jbtest4.mq4 (57, 44)
where do i defined it
it gives me an error
'Multiplying' - variable not defined C:\Program Files\Interbank FX Trader 4\experts\jbtest4.mq4 (57, 44)
where do i defined it
ok i have int multiplying=2;