Download MetaTrader 5
To add comments, please log in or register
Do you need OpenCL? MQL5 can provide it!
gidione silva fontes
30
gidione silva fontes 2014.12.31 01:47 
I would put, linear Martingale 1, 2, 3, 4.

could help me in this code I determine a price, and this price is as start and stop it have to do to stop the manual or TP or TrailingStop order.

Can anyone help me how to do this?

 

 

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
extern double TakeProfit=10000;
extern double timeframe=0; //0=atual / 1=1M / 60=1H / 240=4H / 1440=1D / 10080=1Semana / 43200=1MES
extern double Lots=0.01;
extern double TrailingStop=0;
extern double Stop_loss_buy=0;
extern double Stop_loss_sell=0;
extern double Price_buy1=0;
extern double Price_sell1=0;
extern double Price_buy2=0;

//---
string lastSignalUsed="No signal";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   
   double Price1,Price2;
   int cnt,ticket,total;
   

   Price1=iMA(NULL,timeframe,1,0,MODE_SMA,0,1);         //PREÇO atual
   Price2=iMA(NULL,timeframe,1,0,MODE_SMA,0,2);         //PREÇO anterior
   
   total=OrdersTotal();
   if(total<1)
     {

      if(AccountFreeMargin()<(1*Lots))
        {
         Print("Account Free Margin = ",AccountFreeMargin());
         return(0);
        }

      if(    
              (Price1>Price_buy1 && Price2<Price_buy1)
              
     
      
      
      
      
      )
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Stop_loss_buy,Ask+TakeProfit*Point,"EA SKY TRADE",123456,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) 
               {
               Print("BUY : ",OrderOpenPrice());
               lastSignalUsed="Buy";
               }
           }
         else Print("BUY Error: ",GetLastError());
         return(0);
        }

      if(            
                      (Price1<Price_sell1 && Price2>Price_sell1)
                     
      
      
      
      )
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Stop_loss_sell,Bid-TakeProfit*Point,"EA SKY TRADE",123456,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) 
               {
               Print("SELL : ",OrderOpenPrice());
               lastSignalUsed="Sell";
               }
           }
         else Print("SELL  Error: ",GetLastError());
         return(0);
        }
      return(0);
     }

   for(cnt=0;cnt<total;cnt++)
     {
      if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
        {
         Print("OrderSelect() failed with error :  "+GetLastError());
        }
      if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
        {
         if(OrderType()==OP_BUY)
           {

            if(   //CLOSE BUY
            
                    
                   (Price1<Price_sell1 && Price2>Price_sell1) 
                  
                   
                             
            ) 
              {
               if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,Red))
                 {
                  Print("OrderClose() failed with error :  "+GetLastError());
                  return(0);
                 }
              }

            if(TrailingStop>0)
              {
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Gray))
                       {
                        Print("OrderModify() failed with error :  "+GetLastError());
                       }
                     return(0);
                    }
                 }
              }
           }
         else
           {
            if(        //CLOSE SELL
            
            
                                 
                             (Price1>Price_buy1 && Price2<Price_buy1) 
                            
            
            ) 
            
              {
               if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,Lime))
                 {
                  Print("OrderClose() failed with error :  "+GetLastError());
                  return(0);
                 }
              }
            if(TrailingStop>0)
              {
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Gray))
                       {
                        Print("OrderModify() failed with error :  "+GetLastError());
                        return(0);
                         }
                       }
                    }
                 }
              }
           }
         }
   return(0);
  }
//+------------------------------------------------------------------+
Files:
manual_sr.zip 246 kb
gidione silva fontes
30
gidione silva fontes 2015.01.04 10:47  
someone help me?
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2015.01.04 10:53  
Please ask here ... https://www.mql5.com/en/job
whroeder1
13641
whroeder1 2015.01.04 14:24  
sky6nove: someone help me?
You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
/
To add comments, please log in or register