1. any solotion for balance please ??????????

2. Originally Posted by nabelion
any solotion for balance please ??????????
Hi nabelion,

Here is another guide :

In the extern parameters, add :

Code:
```extern double lots=0.1;
extern bool martingale=false;
extern double multiplier=2.0;
extern double minlot=0.01;
extern double maxlot=10;```
After the extern parameters, add :

Code:
```double lotsfactor=1,ilots;
double initiallotsfactor=1;```
In the init() function, before return(), add :

Code:
```   //|---------martingale initialization

int tempfactor,total=OrdersTotal();
if(tempfactor==0 && total>0)
{
for(int cnt=0;cnt<total;cnt++)
{
if(OrderSelect(cnt,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
tempfactor=NormalizeDouble(OrderLots()/lots,1+(MarketInfo(Symbol(),MODE_MINLOT)==0.01));
break;
}
}
}
}
int histotal=OrdersHistoryTotal();
if(tempfactor==0&&histotal>0)
{
for(cnt=0;cnt<histotal;cnt++)
{
if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
tempfactor=NormalizeDouble(OrderLots()/lots,1+(MarketInfo(Symbol(),MODE_MINLOT)==0.01));
break;
}
}
}
}
if(tempfactor>0)
lotsfactor=tempfactor;```
Before each ordersend() function, add :

Code:
```if(martingale)ilots=NormalizeDouble(lots*martingalefactor(),2);else ilots=lots;
if(ilots<minlot)ilots=minlot;if(ilots>maxlot)ilots=maxlot;```
In the ordersend() function, replace lots by :

Code:
`ilots`
At the end of the code, add :

Code:
```//|---------martingale

int martingalefactor()
{
int histotal=OrdersHistoryTotal();
if (histotal>0)
{
for(int cnt=histotal-1;cnt>=0;cnt--)
{
if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
if(OrderProfit()<0)
{
lotsfactor=lotsfactor*multiplier;
return(lotsfactor);
}
else
{
lotsfactor=initiallotsfactor;
if(lotsfactor<=0)
{
lotsfactor=1;
}
return(lotsfactor);
}
}
}
}
}
return(lotsfactor);
}```

3. Hello funyoo, and thank you for the script.

I try to add it to an ea that i have create with Expert Advisor Builder for MetaTrader 4 .

I make a few of modifications to adapte the script to myine, but it seems that is wrong.

I have search so many time but I find the solution.

Joint, you can find the ea.

If you can help me, it's will be so nice.

Sorry for my English.

4. Hi Dreamfab.
Thanks funyoo for previous postings clearly explaining martingale. There are already several .mq4 running. The best I have seen is Blessing V5.2 . It still suffers suicide occasionally, but you can tune it to minimize losses. When the chart does a long run in one direction, this is bad for martingale. They perform well for choppy and ranging charts. You need to spend a long time tuning (blessing) on Demo accounts before using it on real accounts. You should also learn to operate it, and develop strategies for when suicide is near! You could hedge for example, and if you set a trailing stop on the hedge, make alot of pips if you stay in the trades.
Blessing is kindly donated by several authors who created & updated it. It is in the public domain, but please share settings, etc, don't be selfish !!

Blessing 2 v5.2x2.mq4

5. ## fast & furius martingale

hi all
i try to put code of funyoo in my ea
no double execution

6. A new guide, an easier one :

At the beginning of the code, in the extern parameters add :

Code:
```extern bool martingale=false;          // enable the martingale
extern double multiplier=2.0;          // multiplier used for the martingale
extern double lotdigits=2;             // 1 for minilot, 2 for microlot```
After the extern parameters add :

Code:
```double mlots,ilots,lastprofit,lastlot;

int i,history;```
In the start body add :

Code:
```   history=OrdersHistoryTotal();
if(history>0){
for(i=0;i<history;i++){
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic){
lastprofit=OrderProfit();
lastlot=OrderLots();
}
}
}
mlots=0;
if(martingale && lastprofit<0)mlots=NormalizeDouble(lastlot*multiplier,lotdigits);else mlots=lots;```
In the mm function (if you have one), add :

Code:
` && (martingale==false || (martingale && lastprofit>=0))`
Before each ordersend function, add :

Code:
`if(martingale)ilots=mlots;else ilots=lots;`
Finally, replace lots in the ordersend function by ilots.

7. Originally Posted by funyoo
A new guide, an easier one :

At the beginning of the code, in the extern parameters add :

Code:
```extern bool martingale=false;          // enable the martingale
extern double multiplier=2.0;          // multiplier used for the martingale
extern double lotdigits=2;             // 1 for minilot, 2 for microlot```
After the extern parameters add :

Code:
```double mlots,ilots,lastprofit,lastlot;

int i,history;```
In the start body add :

Code:
```   history=OrdersHistoryTotal();
if(history>0){
for(i=0;i<history;i++){
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic){
lastprofit=OrderProfit();
lastlot=OrderLots();
}
}
}
mlots=0;
if(martingale && lastprofit<0)mlots=NormalizeDouble(lastlot*multiplier,lotdigits);else mlots=lots;```
In the mm function (if you have one), add :

Code:
` && (martingale==false || (martingale && lastprofit>=0))`
Before each ordersend function, add :

Code:
`if(martingale)ilots=mlots;else ilots=lots;`
Finally, replace lots in the ordersend function by ilots.

thanks i will try !!!

8. Originally Posted by NICK35
thanks i will try !!!
i'm at 99%

i have only a small error
magic number .......

9. Originally Posted by NICK35
i'm at 99%

i have only a small error
magic number .......
'magic' - variable not defined
C:\Program Files\FxPro - MetaTrader\experts\F and F v1.0 (Fixed martingale sl).mq4 (53, 60)

10. Originally Posted by NICK35
'magic' - variable not defined
C:\Program Files\FxPro - MetaTrader\experts\F and F v1.0 (Fixed martingale sl).mq4 (53, 60)

Hi NICK35,

You have to replace magic by Magic_Number.