Page 1 of 5 123 ... LastLast
Results 1 to 10 of 46
 8 Attachment(s)    

Thread: Add a martingale

  1. #1
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default Add a martingale

    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 :

    After extern parameters, add :

    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
    After start(){, add :

    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. #2
    Senior Member
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    631

    Default

    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. #3
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Updated.

    I have added the InitalLots.

  4. #4

    Default

    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. #5
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by BillR View Post
    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. #6

    Default

    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. #7

    Default

    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.
    Last edited by ElectricSavant; 02-07-2009 at 03:11.

  8. #8
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by BillR View Post
    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.

    Quote Originally Posted by ElectricSavant View Post
    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. #9

    Default

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


    Quote Originally Posted by funyoo View Post
    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. #10
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by ElectricSavant View Post
    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
    ...

Similar Threads

  1. RSI + martingale
    By noiahei in forum Ideas for expert advisors
    Replies: 1
    Last Post: 06-21-2010, 17:01
  2. (REQ) Martingale
    By 626mx in forum Ideas for expert advisors
    Replies: 2
    Last Post: 05-05-2010, 01:40
  3. New Martingale EA
    By shaya in forum Scripts and other tools
    Replies: 0
    Last Post: 06-24-2009, 06:50
  4. ATR MA Martingale EA
    By funyoo in forum Expert advisors live statements
    Replies: 0
    Last Post: 02-19-2009, 22:40

Tags for this Thread

add, change, color, demo, expert, expert advisor, experts, forex, guide, hedge, high, how to, ilan, index, learn, macd, magic, martingale, metatrader, mq4, online, profit, programmer, programming, real, simple, stop, strategies, strategy, system, thank you, time, trader, trading, trading forex, trailing

Posting Permissions

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