Results 1 to 1 of 1
 1 Attachment(s)    

Thread: Unica função Martingale que aumente após lucro e duplique após perdas.

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    1

    Default Unica função Martingale que aumente após lucro e duplique após perdas.

    Hello gentlemen.
    I created a function with two external variables of the bool type, they are: [COLOR = "# 800000"] margingale_lucro [/ COLOR] (adds +1 to the lot each time profit> 0) and [COLOR = "# 800000"] martingale_perda [/ COLOR] (multiplies the lot by the factor externally (which is another external variable) defined by the user eg: 2).

    so far everything ok, I managed to make everything work while the [COLOR = "# 800000"] margingale_lucro [/ COLOR] and [COLOR = "# 800000"] martingale_perda [/ COLOR] variables are all set to "false "&&" false "or" false "&&" true ".
    So when set to "true" and "true" I am unable to make it work the way I want.
    And taking advantage of the opportunity, I ask for the help of adding a loop that is explained below.

    Which should be:
    Case 1: if profit then [COLOR = "# 800000"] margingale_lucro [/ COLOR] adds +1 up to the number of 3 cycles, starting the cycle again and starting with the initial batch.
    Ex .: initial batch 0.01 if profit changes to batch 0.02, if profit changes to batch 0.03, and here, regardless of profit, it returns to the initial batch. And if you lose with lot 0.03 he will do the [COLOR = "# 800000"] martingale_perda [/ COLOR] and winning, returns to the initial lot to start the recount of the profit cycle.

    Case 2: if loss then [COLOR = "# 800000"] martingale_perda [/ COLOR] multiplies by the factor defined by the user. Ex .: (factor 2) lot starts 0.01 if loss 0.02 if loss 0.04 and if it wins the lot must return to the initial lot and only from there the calculation of the definition of true of the variable [COLOR = "# 800000"] margingale_lucro [/ COLOR] should start and maintain the cycle up to 3 times and return.

    I mention that this function will return these values ​​for a single variable to be inserted into the "OrderSend" in the parameter corresponding to "batch".

    Thank you very much in advance.

    Here is the function:

    Code:
    double gale_mais( double lote_inicial, double fator_incremento, double fator_aumento, int Magicma_n ){
    
    /* lote_inicial = 0.01, fator_incremento = 1.4, fator_aumento = 0.01, 1234 */
    
       double tamanho_lote = 0 ;     // 0.01
       int    maior_ticket = 0 ;     // 
       double lote = 0 ; 
       double maior_lote= 0 ;
       double profit= 0 ;
       
           for ( int i= 0 ; i< OrdersHistoryTotal(); i++) 
           {  
           
                 if ( OrderSelect (i,SELECT_BY_POS,MODE_HISTORY)== false )
                 break ;
             
                   if ( (OrderSymbol()== Symbol ()) && (OrderMagicNumber()== Magicma_n)) 
                   {
                         if (OrderTicket() > maior_ticket) //  pega o maior tiket
                         {
                           maior_ticket = OrderTicket();
                           maior_lote = NormalizeDouble ( OrderLots(), 2 );  
                           profit = OrderProfit();
                         }
                  }
           }  
     
          //  como ja se sabe o maior ticket, agora pega o lote inicial
          if ( OrderSelect (maior_ticket,SELECT_BY_TICKET,MODE_HISTORY)== false )
          return (lote_inicial);
       
          // agora verifica o maior lote
           if (maior_lote == 0 )
           tamanho_lote = lote_inicial;  // lote 0.01
    //-------------
            
              
             if( (gale_perca==false) && (gale_lucro==false)){
                if((profit>0) || (profit<0) )
                tamanho_lote=lote_inicial;
             }  
             
                if( (gale_perca==false) && (gale_lucro==true)){ 
                   if(profit>0)
                   tamanho_lote=maior_lote+fator_lot; //
                      else if(profit<0) tamanho_lote = lote_inicial;
                   
                 } 
             
                   if( (gale_perca==true) && (gale_lucro==false)){ 
                       if(profit<0)
                       tamanho_lote=maior_lote*fator_incremento; //
                          else if(profit>0) tamanho_lote = lote_inicial;
                   
                   }
            //------------------------------------------------------------------//
                       if( (gale_perca==true) && (gale_lucro==true)){ 
                         
                          if(profit<0){
                          tamanho_lote=maior_lote*fator_incremento; //
                          
                          }
                       
                          if((profit>0) && (lote_inicial==0.01)){
                          
                          tamanho_lote=maior_lote+fator_lot; //
                             if(profit<0) tamanho_lote = lote_inicial;
                            
                          }
                        }
                   
                   
                 lote = NormalizeDouble (tamanho_lote, 2 );
                 return (lote);
     
    }
    Unica função Martingale que aumente após lucro e duplique após perdas.-imag_martingale-png
    Last edited by VCARNEIRO2; 10-22-2020 at 21:06.

Similar Threads

  1. Add a martingale
    By funyoo in forum MQL programming
    Replies: 45
    Last Post: 05-02-2013, 03:58
  2. MA martingale ea
    By surtoday in forum Ideas for expert advisors
    Replies: 2
    Last Post: 07-30-2012, 08:20
  3. RSI + martingale
    By noiahei in forum Ideas for expert advisors
    Replies: 1
    Last Post: 06-21-2010, 17:01
  4. ATR MA Martingale EA
    By funyoo in forum Expert advisors live statements
    Replies: 0
    Last Post: 02-19-2009, 22:40

Posting Permissions

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


GadgetVersus GadgetVersus France W3Ask W3Ask Brasil W3Ask Deutschland W3Ask Espaa W3Ask France W3Ask Italia W3Ask Nederland