Results 1 to 1 of 1
 0 Attachment(s)    

Thread: Help my code

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

    Default Help my code

    Code:
    extern double TakeProfit = 100,StopLoss = 50;
    extern double Lots = 0.2;
    extern double TrailingStop = 50;
    
    extern double MATrendPeriod=50;
    
    
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    int start()
      {
       double MacdCurrent, MacdPrevious, SignalCurrent ;
       double SignalPrevious, MaCurrent, MaPrevious , PRECIOACTUAL = Bid;
       int cnt, ticket, total, C, Totalbarras;
       double MinimoPrecio=Bid, Maximum=Bid; 
          double  pips2points,    // slippage  3 pips    3=points    30=points
            pips2dbl, StopLossPips, Slippage.Pips;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
       
               
    
       if(TakeProfit<10)
         {
          Print("TakeProfit less than 10");
          return(0);  // check TakeProfit
         }
    // to simplify the coding and speed up access
    // data are put into internal variables
    
       
      MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_LWMA,PRICE_HIGH,0);
      MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_LWMA,PRICE_LOW,1);
       int counted_bars=IndicatorCounted();
       C=Bars-counted_bars;
    
    
       total=OrdersTotal();
       
     //  if(total<1) 
     //    {
         
          // no opened orders identified
          if(AccountFreeMargin()<(1000*Lots))
            {
             Print("We have no money. Free Margin = ", AccountFreeMargin());
             return(0);  
            }
          // check for long position (BUY) possibility
          
          // numero de barras
       
     
     Alert("PRECIO ACTUAL= ",PRECIOACTUAL," DIGITOS= ",PRECIOACTUAL ," 1MEDIA= ",MaCurrent," 2MEDIA= ",MaPrevious," bars Min= ",MinimoPrecio," Max= ",Maximum);  
         
          if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    
          
          // check for short position (SELL) possibility
          if(PRECIOACTUAL ==  MaCurrent )
     
            {
                
    
              
              ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",TimeCurrent(),0,Green);
             
               {
                if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
               }
             else Print("Error opening SELL order : ",GetLastError()); 
           
            }
             if(MaPrevious==  PRECIOACTUAL  )
    
            {
      
          
             ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid+TakeProfit*Point,"macd sample",TimeCurrent(),0,Red);
            
             if(ticket>0)
               {
                if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
               }
             else Print("Error opening SELL order : ",GetLastError()); 
             
             }
         //   }
          return(0);
         
       }
    1 - Al backtesting make very few positions open, why is this happening?
    Last edited by fellargasi; 10-27-2010 at 19:48.

Similar Threads

  1. Can anyone Code this EA?
    By pret1102 in forum Softwares
    Replies: 1
    Last Post: 03-21-2012, 04:26
  2. Need Code for S/L and some more
    By Monkesy in forum Ideas for expert advisors
    Replies: 0
    Last Post: 04-05-2011, 11:30
  3. Please help me to code this EA
    By sshirbhate in forum MQL programming
    Replies: 2
    Last Post: 03-21-2011, 13:03
  4. Help with code
    By fxwealth in forum MQL programming
    Replies: 1
    Last Post: 03-25-2010, 18:10
  5. How to code MA on RSI in an EA ?
    By funyoo in forum MQL programming
    Replies: 0
    Last Post: 11-17-2008, 20:03

Tags for this Thread

100, backtesting, brokers, coding, high, low, money, pips, sample, slippage, stoploss, trailingstop

Posting Permissions

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