Martingale

 
anyone can help me?
I want to code an EA with martingal,and I want that the martingal will be applied for the lost pair only not for all pairs.
Eg: 
The ea place an order buy at GBPUSD and sell at EURUSD
The GBPUSD was closed at a profit first but the EURUSD was closed at a loss secondly.
For the next trade,the martingal will be applied if the next order is EURUSD,if not(EURJPY for instance) the martingal will not be applied(initial lot size)
 
Post your request as a job in the Freelance section.
 
  1. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11

    Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11

  2. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

 
William Roeder:
  1. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11

    Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11

  2. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

Please help me
 

Forum on trading, automated trading systems and testing trading strategies

Please fix this indicator or EA

Sergey Golubev, 2017.03.24 07:23

And this is my other suggestion (which came from tsd 2010 and from tsd 2008):

----------------

Just to remind:

Coders (any coder) are coding for free:

  • if it is interesting for them personally, or
  • if it is interesting for many members of this forum.

----------------

and Freelance section of the forum should be used in most of the cases.


 
tabadany19: Please help me

What part of “Help you with what? You haven't stated a problem, you stated a want,” was unclear to you?

 
Try this... https://www.mql5.com/en/code/32299
Simple Martingale Template
Simple Martingale Template
  • www.mql5.com
A simple but fully functional program that demonstrate how a martingale can work for you. Just change the entry analysis using your own scalping strategy and your personal money management style, then optimize. If your goal is a...
 
William Roeder:

What part of “Help you with what? You haven't stated a problem, you stated a want,” was unclear to you?

ok sir; This is the code for martingal; it should be like this: for eg: when the last profit of gbpusd was lost; the martingal should be applied for gbpusd only

Another eg: Those are the history of the account(intial lot 0.01, and multiplier x2)

GBPUSD -5


So if the next pair is not GBPUSD, there is no martingal applied; but if the next signal is GBPUSD the martingal is applied

Like this: 

 

1st GBPUSD -5  lot 0.01

2nd GBPUSD 11 lot 0.02


OR


1st GBPUSD -5 lot 0.01

2nd EURUSD 7 lot 0.01 //no martingal here because it is not a gbpusd

3rd GBPUSD 13 lot 0.02 //the martingal is applied because there is a GBPUSD


So help me please because my code do not work like this condition

extern double Lot=0.01; 

extern bool Martingale=true; //martingale

extern double Multiplier=2; //multiplier

int MagicNumber=1234567890;

double last_profit,last_lot;
string last_tip,last_pair;



int start(){



double lot;

if( TotalOrdersCount()==0 ) {

//martingale

if(Martingale=true){

if(last_profit>=0){

lot=Lot;}

if(last_profit<0){

lot=Lot*Multiplier;}

}
else if(Martingale=false)
 {

   lot=Lot;

  }

}

}



int TotalOrdersCount()

{

  int result=0;

  for(int i=0;i<OrdersTotal();i++)

  {

     OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);

     if (OrderMagicNumber()==MagicNumber) result++;

   }

  return (result);

}

 

double last_history_profit()

   {

   double cpte_profit = 0; //int Magik_No = -1;

        if( OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) )    

          {

           if( OrderMagicNumber() == MagicNumber ) {

           last_profit  = OrderProfit();

           last_lot = OrderLots();

           last_tip = OrderType();
           
           last_pair= OrderSymbol();

          } 

       }

  return(1);

 }
 

Please edit your post and

use the code button (Alt+S) when pasting code

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

 

Do not double post!

I have deleted your duplicated topic!

 
Keith Watford:

Do not double post!

I have deleted your duplicated topic!

ok sir

Reason: