النتائج 1 إلى 1 من 1
  1. #1
    الصورة الرمزية Forex TP
    Forex TP غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Aug 2015
    الإقامة
    المملكة العربية السعودية
    المشاركات
    66

    14 اصلاح اكسبرت بسيط

    السلام عليكم

    السادة المبرمجين ممكن التعدل على هذا الاكسبرت بأضافة التريلنق استوب و بريك ايفن و حصاد الارباح بالدولار

    الاكسبرت بالمرفقات و هنا الكود :

    كود PHP:
    //+------------------------------------------------------------------+
    //|                                                martingle-RSI.mq4 |
    //|                               Copyright © 2011, kourosh Davallou |
    //|                                            [email protected] |
    //+------------------------------------------------------------------+
    #property copyright "Copyright © 2011, kourosh Davallou"
    #property link      "[email protected]"
    #include <stderror.mqh>
    #include <stdlib.mqh>
    //---- input parameters
    extern int       MaxOpenTrades=7;
    extern int       TotalStep=20;
    extern bool      ClassicMartingle=True;
    extern bool      AutoLot=true;
    extern double    lot=0.01 ;
    extern int       MagicNum=1347;
    extern string    MComment=" Step is PIP between to trade ";
    extern int       Step=15;
    extern int       slippage 5;
    extern string    TradeComment=" Trade takeproft and loss is $ ";
    extern int       TakeProfit=30;
    extern int       Loss 50;

    extern string    RSIcomment=" RSI SETTING";
    extern int       RSI=4;
    extern int       LevelRSIbuy=10;
    extern int       LevelRSIsell=70;
    extern int       AppliedPrice=PRICE_TYPICAL;
    extern string    MAcomment=" MA SETTING";
    extern bool      UsedMA=true;
    extern int       MA=50;
    extern string    MACDcomment=" MACD SETTING";
    extern bool      UsedMACD=true;
    extern int       MACD=50;



    extern color     BuyColor=Green;
    extern color     SellColor=Red;
    double   Lot[20];
    int      Error;
    int      BuyCycle=1,SellCycle=1,BuyClose=1,SellClose=1,tries=3;
    bool     Trade=true,BuyOk,SellOk;
    int      DayofTrade=0;
     
    double StartPriceBuy,StartPriceSell,CurrentPip;
     
    int    BuyTicket[26],SellTicket[26],Ticket
    //+------------------------------------------------------------------+
    //| expert initialization function                                   |
    //+------------------------------------------------------------------+
    int init()
      {
    //----
        
    double  MinLot;
        
        
    MinLot=MarketInfo(Symbol(),MODE_MINLOT);
        if ( 
    AutoLot==true)
           {
            
    Comment(" Warning AutoLot select min lot ",MinLot);
            
    lot=MinLot;
            
            }
       if(
    Digits == || Digits == 5) {
     
    //    TakeProfit*=10;
           
    slippage *= 10;
           
    Step*=10;
       
          }
         
    BuyCycle=1;
         
    SellCycle=1
         
    Loss*=-1;
          for(
    int i=1;i<=TotalStep;i++)
             
    Lot[i]= lot MathPow(2,i-1);
        
    //----
       
    return(0);
      }
    //+------------------------------------------------------------------+
    //| expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    int deinit()
      {
    //----
       
    //----
       
    return(0);
      }
    //+------------------------------------------------------------------+
    //| expert start function                                            |
    //+------------------------------------------------------------------+
    int start()
      {
    //----  BUY
      
       
    if( iRSI(NULL,0,RSI,AppliedPrice,1)>iRSI(NULL,0,RSI,AppliedPrice,2) && 
             
    iRSI(NULL,0,RSI,AppliedPrice,1)<LevelRSIbuy 
             
    && iRSI(NULL,0,RSI,AppliedPrice,0)>LevelRSIbuy )
                 { 
                   
    Trade=false;
                    if (
    UsedMA==true )
                       {
                         if ( 
    iMA(NULL,0,MA,0,MODE_SMMA,PRICE_MEDIAN,0) < Open[0]) 
                           
    Trade=true;
                       }
                    else
                         
    Trade=true;
                                
                      if (
    Trade==true)
                        {
                         if (
    BuyCycle ==)
                              {
                                
    DayofTrade=DayOfYear();
                                
    StartPriceBuy=Ask;

                                 
    BuyOk=BuyOrder(Symbol(),Lot[1],Ask,MagicNum," First Buy ",BuyColor);
                        
                                 if (
    BuyOk)
                                   
    BuyCycle++;
                            
                              }    
                          }
                   }        
             if(
    iRSI(NULL,0,RSI,AppliedPrice,1)<iRSI(NULL,0,RSI,AppliedPrice,2) && 
             
    iRSI(NULL,0,RSI,AppliedPrice,1)>LevelRSIsell 
             
    && iRSI(NULL,0,RSI,AppliedPrice,0)<LevelRSIsell 
                {
                  
    Trade=false;
                  if (
    UsedMA==true )
                      {
                       if ( 
    iMA(NULL,0,MA,0,MODE_SMMA,PRICE_MEDIAN,0) > Open[0]) 
                           
    Trade=true;
                       }
                  else 
                      
    Trade=true;
                               
                      if (
    Trade==true)
                        {
                         if ( 
    SellCycle== 1)
                              {
                                
    DayofTrade=DayOfYear();
                                
    StartPriceBuy=Bid;

                                 
    SellOk=SellOrder(Symbol(),Lot[1],Bid,MagicNum," First sell ",SellColor);
                          
                             
                                if (
    SellOk)
                                   
    SellCycle++;    
                              }    
                           }               
                 }          
           
    CurrentPip= (AskStartPriceBuy)*MathPow(10,Digits); 
            if (
    MathAbs(CurrentPip) >= Step)
              {                  
              if(
    iRSI(NULL,0,RSI,AppliedPrice,1)>iRSI(NULL,0,RSI,AppliedPrice,2)&&
              
    iRSI(NULL,0,RSI,AppliedPrice,1)<LevelRSIbuy 
             
    && iRSI(NULL,0,RSI,AppliedPrice,0)>LevelRSIbuy 
               if ( 
    BuyCycle <MaxOpenTrades )
                  {
                   
    BuyOk=BuyOrder(Symbol(),Lot[BuyCycle],Ask,MagicNum,"Buy ",BuyColor);
                    if (
    BuyOk)
                      
    BuyCycle++;
                      
    StartPriceBuy=Ask;
                  }   
                  
          
    CurrentPip= (AskStartPriceSell)*MathPow(10,Digits); 
         if (
    MathAbs(CurrentPip) >= Step)  
          if(
    iRSI(NULL,0,RSI,AppliedPrice,1)<iRSI(NULL,0,RSI,AppliedPrice,2)&&
              
    iRSI(NULL,0,RSI,AppliedPrice,1)>LevelRSIsell 
             
    && iRSI(NULL,0,RSI,AppliedPrice,0)<LevelRSIsell 
        
               if ( 
    SellCycle <MaxOpenTrades)
                  {
                   
    SellOk=SellOrder(Symbol(),Lot[SellCycle],Bid,MagicNum,"Sell ",SellColor);
                    if (
    SellOk)
                      
    SellCycle++;
                      
    StartPriceSell=Bid;
                  } 
                  
           }    
                          
         if( 
    CheckProfit(Symbol(),MagicNum) >= TakeProfit )
           {
             
                 
                    
    Tradecloseall(Symbol(),MagicNum);
                    
    SellCycle=1;
                    
    BuyCycle=;
               
                 
                
            }    
         if( 
    CheckProfit(Symbol(),MagicNum) <= Loss )
           {
             
                 
                    
    Tradecloseall(Symbol(),MagicNum);
                    
    SellCycle=1;
                    
    BuyCycle=;
               
                 
                
            }              
                    
                 
    //----


      
    return(0);
      }
    //+------------------------------------------------------------------+
    double CheckProfit(string symbol,int magic)
        {
         
    double NetProfit=;
                      
           for(
    int i=OrdersTotal()-1;i>=0;i--)
           {
              
    OrderSelect(iSELECT_BY_POS);          
            if(
    OrderSymbol()==symbol && OrderMagicNumber()==magic )  
               {
               
               
    NetProfit+= OrderProfit();
               }
           }
           return(
    NetProfit);
     }
     
    bool BuyOrder(string symbol,  double BuyLot,double price,int Magic string Comm,color Col)
      {
        
    int ticket  ;
         
    price=NormalizeDouble(price,Digits);
        for (
    int i=0itries;i++)
          {
          
    ticket OrderSend(Symbol(), OP_BUYBuyLotpriceslippage,00CommMagic 0Col);
           
    BuyTicket[BuyCycle]=ticket;
           if ( 
    ticket == -1){  
            Print(
    "Error",ErrorDescription(GetLastError()));
            
            }
            
    Sleep(400);
            if (
    price+5*Point >= OrderOpenPrice() ||price+5*Point <= OrderOpenPrice() )
              {
      
               return(
    True);
               }
          }
          Print(
    "BUY K.O at ",price);
          return(
    False);
       } 
     
    bool SellOrder(string symbol,  double BuyLot,double price,int Magic ,string Comm,color Col)
      {
        
    int ticket  ;
        
    price=NormalizeDouble(price,Digits);
        for (
    int i=0itries;i++)
          {
          
    ticket OrderSend(Symbol(), OP_SELLBuyLotpriceslippage,00CommMagic 0Col);
          
    SellTicket[SellCycle]=ticket;
          if ( 
    ticket == -1){  
            Print(
    "Error",ErrorDescription(GetLastError()));
            }
             
    Sleep(400);
            if (
    price+5*Point >= OrderOpenPrice() ||price+5*Point <= OrderOpenPrice() )
              {
       
               return(
    True);
               }
          }
          Print(
    "SEll K.O at ",price);
          return(
    False);
       }  
       
       
       
    bool closeorder(int mode,string symbol,int magic,int tic )
        {
        
          
    double price_0;
            
     
         
           for(
    int i=OrdersTotal()-1;i>=0;i--)
           {
              
    OrderSelect(iSELECT_BY_POS);

              if(
    OrderSymbol()== symbol && OrderMagicNumber()==magic && OrderType()==mode &&  OrderTicket()==tic)
              {
                 
                       for(
    int c=0;c<tries;c++)
                       {
                          
    RefreshRates();
                               if(
    mode==OP_SELLprice_0=Ask;
                          else if(
    mode==OP_BUY)  price_0=Bid
                          
                          if (
    OrderClose(OrderTicket(),OrderLots(),price_0,slippage,Pink)){  break;}
                          else
                          {
                             
    ErrorGetLastError();
                             Print(
    "error(",Error,"): ",ErrorDescription(Error)+"Errorors Closing order ");
                             if( 
    Error==|| Error==136 || Error==137 || Error==138 || Error==146
                             { 
    Sleep(5000); continue; }  
                          }
                       } 
              }  
            } 
            
            return(
    0);          
        } 
        
        
    bool closeall(string symbol,int magic )
        {
        
          
    double price_0;
          
    int count =1  ;
          
    int  minute=0;
    //   count  
       
    minute=Minute();
       for(
    int i=OrdersTotal()-1;i>=0;i--)
       
    //    for(int i=0;i<=OrdersTotal()-1;i++)
           
    {
               
              
    OrderSelect(iSELECT_BY_POS);
        
    //    Print(" count",count,"i",i);
             
          //  Sleep(CloseSec*1000);
              
    if(OrderSymbol()==symbol && OrderMagicNumber()==magic )
              {
                 
                       for(
    int c=0;c<tries;c++)
                       {
                          
    RefreshRates();
                               if(
    OrderType()==OP_SELLprice_0=Ask;
                          else if(
    OrderType()==OP_BUY)  price_0=Bid
                          
                          if (
    OrderClose(OrderTicket(),OrderLots(),price_0,slippage,Pink)){  break;}
                          else
                          {
                             
    ErrorGetLastError();
                             Print(
    "Error(",Error,"): ",ErrorDescription(Error)+"Errors Closing order ");
                             if( 
    Error==|| Error==136 || Error==137 || Error==138 || Error==146
                             { 
    Sleep(5000); continue; }  
                          }
                       } 
              } 
              
    count++; 
            } 
       
    /// count      
           
            
    return(0);          
        } 
    الملفات المرفقة الملفات المرفقة
    آخر تعديل بواسطة Forex TP ، 13-04-2018 الساعة 04:54 PM


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17