Note that this martingale is not conventionnal. The lots size is increased when there is a loss, and decreased when the is a profit. While it should start again at initial lots when the last serie of consecutive loss finishes on a win.

If you have a function for a basic martingale, don't hesitate to post :

Code:
```extern double Lots=0.01;//|----------------------lots
extern bool Martingale=false;//|-----------------martingale
extern double Multiplier=2.0;//|-----------------multiplier martingale
extern double MinProfit=50;//--------------------minimum profit to apply the martingale```

Code:
`   if(Martingale)CalculateMartingale();Balance=AccountBalance();`
At the end of the code, add :

Code:
```void CalculateMartingale()
{
double InitalLots=0.01;
double MinLots=MarketInfo(Symbol(),MODE_MINLOT);
double MaxLots=MarketInfo(Symbol(),MODE_MAXLOT);
if(Balance!=0.0)
{
if(Balance>AccountBalance())Lots=Multiplier*Lots;
else if((Balance+MinProfit)<AccountBalance())Lots=InitalLots;
else if((Balance+MinProfit)>=AccountBalance())Lots=Lots;
if(Lots<MinLots)Lots=MinLots;
if(Lots>MaxLots)Lots=MaxLots;
}
return(0);
}```

2. The problem i have found with Martingale when you get lots of losses in a row it can blow ones account. I have found the best approach to fix this problem would simply be widen the pips before the next order is placed, but dont add more lots keep the lots the same but just adjust the take profit in accordance to the new lot.

Ok you dont make the losses back as fast, however you also dont blow the account up!

3. Updated.

4. Hi Funyoo,
Thanks for all your great work. I've been using Ilan1.4 and was making a killing until 800 pip fall on EURAUD today....Cut the account in half....(I'm very happy half is still there!!) I downloaded Ilan 1.42 today and will be looking at ALL the Loss Control parameters.....I was doing a good job controlling risk with PipStep...and Take Profit...but 800 Pip drop was too much... I'm now a BIG believer in avoiding account blow out. Do you have the code described here in the "Martingale" thread already working in an EA? Have you ever considered adding code that would automatically close losing positions as the T/P goes beyond the entry value when additional orders with larger Lot Exponent are created? It might be a nice addition to Ilan 1.43..
Should this post be in the Ilan thread?? Thanks Bill

5. Originally Posted by BillR
Hi Funyoo,
Thanks for all your great work. I've been using Ilan1.4 and was making a killing until 800 pip fall on EURAUD today....Cut the account in half....(I'm very happy half is still there!!) I downloaded Ilan 1.42 today and will be looking at ALL the Loss Control parameters.....I was doing a good job controlling risk with PipStep...and Take Profit...but 800 Pip drop was too much... I'm now a BIG believer in avoiding account blow out. Do you have the code described here in the "Martingale" thread already working in an EA? Have you ever considered adding code that would automatically close losing positions as the T/P goes beyond the entry value when additional orders with larger Lot Exponent are created? It might be a nice addition to Ilan 1.43..
Should this post be in the Ilan thread?? Thanks Bill
Hi BillR and welcome,

No I have not yet enabled this martingale in a code. But I have already tried it and it works fine.

I don't understand your other question.

6. Hi Funyoo,
I'll try to explain...with Martingale when a buy order is entered
a T/P is also set.... higher. When the value of the currency changes it either closes the order at a profit (the T/P) or goes down the Pip Step value and a second order is entered with a new T/P (and bigger lot size). The T/P of the first order is also changed to the new T/P value of the second order. As a third order is entered all the orders are modified to change their T/P values to the T/P value of the third order. But now depending on your EA T/P and/or Pipstep "Input" values when the value of the currency finally goes up to the T/P point the first order will be closed at a small loss while the 2nd and 3rd orders, which have larger lot sizes, will close at a profit. (If you have many open orders you could also have multiple losing orders). Could order "One" be closed at a small loss when order three is created? As the loss from Order one only gets larger as additional orders are created. This way we can avoid the growing additional loses as additional orders are created. Kind of like a Stop loss triggered by the T/P value. Once an order goes on the losing side of the T/P.... close it automatically instead of letting it turn into a bigger loss.
Thanks again Bill

7. What does it mean by the last series? doesn't it always decrease on a win? I am confused...

Say I start with 0.01...then lose....so the next is 0.02....then I win...then it goes back to 0.01....right?

uhhh err...wait....lets say I start with 0.01 and I lose...then 0.02....then I lose again....0.04....then I lose again....0.08....then I win...so it goes to 0.04...THEN IT WINS AGAIN AND STARTS OVER TO 0.01...or does it go down to 0.02 first?

ES

The lots size is increased when there is a loss, and decreased when the is a profit.

While it should start again at initial lots when the last serie of consecutive loss finishes on a win.

8. Originally Posted by BillR
Hi Funyoo,
I'll try to explain...with Martingale when a buy order is entered
a T/P is also set.... higher. When the value of the currency changes it either closes the order at a profit (the T/P) or goes down the Pip Step value and a second order is entered with a new T/P (and bigger lot size). The T/P of the first order is also changed to the new T/P value of the second order. As a third order is entered all the orders are modified to change their T/P values to the T/P value of the third order. But now depending on your EA T/P and/or Pipstep "Input" values when the value of the currency finally goes up to the T/P point the first order will be closed at a small loss while the 2nd and 3rd orders, which have larger lot sizes, will close at a profit. (If you have many open orders you could also have multiple losing orders). Could order "One" be closed at a small loss when order three is created? As the loss from Order one only gets larger as additional orders are created. This way we can avoid the growing additional loses as additional orders are created. Kind of like a Stop loss triggered by the T/P value. Once an order goes on the losing side of the T/P.... close it automatically instead of letting it turn into a bigger loss.
Thanks again Bill
Hi BillR,

Ok I see, interesting.

I don't know how to code that. I could use a hidden TP, but it would be quite complicated to develop. Maybe another programmer will help.

Originally Posted by ElectricSavant
What does it mean by the last series? doesn't it always decrease on a win? I am confused...

Say I start with 0.01...then lose....so the next is 0.02....then I win...then it goes back to 0.01....right?

uhhh err...wait....lets say I start with 0.01 and I lose...then 0.02....then I lose again....0.04....then I lose again....0.08....then I win...so it goes to 0.04...THEN IT WINS AGAIN AND STARTS OVER TO 0.01...or does it go down to 0.02 first?

ES
Correct, it is not the last, but the previous. If you win at the end of a serie, then you start again at 0.01, etc...

9. I am not real clear on this....could you give some different scenarios going up to 0.08....

Originally Posted by funyoo
Hi BillR,

Ok I see, interesting.

I don't know how to code that. I could use a hidden TP, but it would be quite complicated to develop. Maybe another programmer will help.

Correct, it is not the last, but the previous. If you win at the end of a serie, then you start again at 0.01, etc...

10. Originally Posted by ElectricSavant
I am not real clear on this....could you give some different scenarios going up to 0.08....
enter with 0.01
loss > enter with 0.02
loss > enter with 0.04
loss > enter with 0.08
win > enter with 0.01
loss > enter with 0.02
...

enter with 0.01
loss > enter with 0.02
loss > enter with 0.04
loss > enter with 0.08
win > enter with 0.01
win > enter with 0.01
loss > enter with 0.02
...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•