Thursday, November 19, 2020

MT4 One Million Idea Unify


https://drive.google.com/file/d/1VUWBV2PmoQuWoiEzHb64ZT3aFb5_295W/view?usp=sharing

https://drive.google.com/file/d/1GmaHP1_6FPJFMaMoe1-vs58sIK38F8CI/view?usp=sharing

https://drive.google.com/file/d/1D1O06vllskz7O6ksk84GVUg79IOkJeSl/view?usp=sharing

This is an MT4 Forex robot made by me. The robot alone opens and closes ALMOST all transactions. If the transaction remains open, it must be closed manually immediately to avoid any further loss. It can be installed on as many pairs as possible to maximize the gain. Remember, close any transaction that is not closed at the end of the day immediately. 

For YEN you have to use other parameters, you can find them in file no. 3 to download.

//+------------------------------------------------------------------+
//|                                             AAOneMillionIdea.mq4 |
//|                            Copyright 2014, Tiberiu Adrian Farcas |
//|                                      http://phpfreetutorials.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Tiberiu Adrian Farcas"
#property link      "http://phpfreetutorials.com"
#property version   "1.00"
#property strict

//--- input parameters
// marimea candelei japoneze folosita ca punct de referinta pentru deschiderea unei tranzactii
input int  lung_candela=300;
// enumeration of named constants
input ENUM_TIMEFRAMES interval_deschidere=PERIOD_M30;
input ENUM_TIMEFRAMES interval_inchidere=PERIOD_M5;
input double zecimal=0.00001;
input double zecimal_EURO_OR_YEN=0.0001;

input float  lot_siz=4.0;
input int nr_de_tranzactii=5;
input int nr_de_tranzactii_SELL=5;
input float  buy_profit=10.0;
input double TrailingStop = 50;

//--- input parameters
// marimea candelei japoneze folosita ca punct de referinta pentru deschiderea unei tranzactii
input int  lung_candela_SELL=250;
// enumeration of named constants
input ENUM_TIMEFRAMES interval_deschidere_SELL=PERIOD_M30;
input ENUM_TIMEFRAMES interval_inchidere_SELL=PERIOD_M5;
input float  buy_profit_SELL=10.0;
input double margin_level_STOP=200;

enum CURRENCY_OK_FOR_TRADING
{
OpenCurrency=1,
CloseCurrency=0,
};

input CURRENCY_OK_FOR_TRADING faza_de_trading=OpenCurrency;

//input float pierdere=-7;

/*   {
      PERIOD_CURRENT,
      PERIOD_M1,
      PERIOD_M2,
      PERIOD_M3,
      PERIOD_M4,
      PERIOD_M5,
      PERIOD_M6,
      PERIOD_M10,
      PERIOD_M12,
      PERIOD_M15,
      PERIOD_M20,
      PERIOD_M30,
      PERIOD_H1,
      PERIOD_H2,
      PERIOD_H3,
      PERIOD_H4,
      PERIOD_H6,
      PERIOD_H8,
      PERIOD_H12,
      PERIOD_D1,
      PERIOD_W1,
      PERIOD_MN1
   };
*/

//int faza_de_trading=0;  // 0 - asteptare
                        // 1 - tranzactie deschisa
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+

//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
   int count_orders=0;
   int count_orders_SELL=0;
   
   int count_orders_FRAME=0;
   int count_orders_SELL_FRAME=0;
   
   string simbol=Symbol();
   int total=OrdersTotal();
   bool close_op=0;
   
   // write open orders
    for(int pos=0; pos<total; pos++)
      {
         if(OrderSelect(pos,SELECT_BY_POS)==false) continue;
         
         if(OrderType()==OP_BUY && OrderSymbol()==simbol) count_orders_FRAME=count_orders_FRAME+1;
         
         if(OrderType()==OP_BUY) count_orders=count_orders+1;
         //if(OrderType()==OP_BUY && OrderProfit()<pierdere) close_op=OrderClose(OrderTicket(),OrderLots(),Bid,0,White);
         
         if(OrderType()==OP_SELL && OrderSymbol()==simbol) count_orders_SELL_FRAME=count_orders_SELL_FRAME+1;
         if(OrderType()==OP_SELL) count_orders_SELL=count_orders_SELL+1;
         //if(OrderType()==OP_SELL && OrderProfit()<pierdere) close_op=OrderClose(OrderTicket(),OrderLots(),Ask,0,White);
       
       //Print("Last operation",close_op);  
      }
   double margin_level_REAL=0;
   
   if(AccountEquity()!=AccountFreeMargin()) margin_level_REAL=AccountEquity()*100/(AccountEquity()-AccountFreeMargin());
   else margin_level_REAL=AccountEquity()*100;
   
     
   if(count_orders>0 || count_orders_SELL>0) Comment(count_orders, " BUY orders available TOTAL.", "\n",
   count_orders_SELL, " SELL orders available TOTAL.", "\n",
   "Account free margin = ",AccountFreeMargin(), "\n",
   "Margin level = ",margin_level_REAL,"%","\n",
   count_orders_FRAME, " BUY orders available for ", simbol,"\n",
   count_orders_SELL_FRAME, " SELL orders available for ", simbol);
   else Comment("No orders available.","\n","Account free margin = ",AccountFreeMargin(), "\n", "Margin level = ",margin_level_REAL,"%");
   
   // Print("Account free margin = ",AccountFreeMargin());
   if(faza_de_trading==1 && count_orders_SELL_FRAME<nr_de_tranzactii_SELL && margin_level_REAL>margin_level_STOP)
   {
    deschide_tranzactie_SELL();
    deschide_tranzactie_SELL();
    deschide_tranzactie_SELL();
    deschide_tranzactie_SELL();
    deschide_tranzactie_SELL();
   }
   //else Alert("Real Margin Level: ", margin_level_REAL);
   
   if(faza_de_trading==1 && count_orders_FRAME<nr_de_tranzactii && margin_level_REAL>margin_level_STOP)
   {
    deschide_tranzactie();
    deschide_tranzactie();
    deschide_tranzactie();
    deschide_tranzactie();
    deschide_tranzactie();
   }
       
  }
//+------------------------------------------------------------------+

int deschide_tranzactie_SELL()
{
int trend_actual=0;

double valoare_bara_1=iClose(NULL,interval_inchidere_SELL,1)-iOpen(NULL,interval_inchidere_SELL,1);

if(valoare_bara_1==0) return 0;
if(valoare_bara_1>0) trend_actual=1;
if(valoare_bara_1<0) trend_actual=-1;

if(trend_actual==-1)
{
if(iClose(NULL,interval_deschidere_SELL,1)-iOpen(NULL,interval_deschidere_SELL,1)<0) return 0;
}

double rezultat_bara_1=iClose(NULL,interval_deschidere_SELL,1)-iOpen(NULL,interval_deschidere_SELL,1);
double rezultat_bara_2=iClose(NULL,interval_deschidere_SELL,2)-iOpen(NULL,interval_deschidere_SELL,2);
double rezultat_bara_3=iClose(NULL,interval_deschidere_SELL,3)-iOpen(NULL,interval_deschidere_SELL,3);

if(trend_actual==-1)
{

if( (rezultat_bara_1 > lung_candela_SELL*zecimal) || (rezultat_bara_1+rezultat_bara_2 > lung_candela_SELL*zecimal))
{
//if(rezultat_bara_2>0 && rezultat_bara_2>lung_candela*zecimal) return 0;
//if(rezultat_bara_3>0 && rezultat_bara_3>lung_candela*zecimal) return 0;

double tp=Bid-zecimal_EURO_OR_YEN*buy_profit_SELL;
int ticket= OrderSend(Symbol(),OP_SELL,lot_siz/100,Bid,0,0,tp);
if(ticket<0)Print("OrderSend failed with error #",GetLastError());
   else Print("OrderSend placed successfully");
//---

}
else return 0;
}

return 1;
}
///////////////////////////////////////////////////////
int deschide_tranzactie()
{
int trend_actual=0;

double valoare_bara_1=iClose(NULL,interval_inchidere,1)-iOpen(NULL,interval_inchidere,1);

if(valoare_bara_1==0) return 0;
if(valoare_bara_1>0) trend_actual=1;
if(valoare_bara_1<0) trend_actual=-1;

if(trend_actual==1)
{
if(iClose(NULL,interval_deschidere,1)-iOpen(NULL,interval_deschidere,1)>0) return 0;
}

double rezultat_bara_1=iClose(NULL,interval_deschidere,1)-iOpen(NULL,interval_deschidere,1);
double rezultat_bara_2=iClose(NULL,interval_deschidere,2)-iOpen(NULL,interval_deschidere,2);
double rezultat_bara_3=iClose(NULL,interval_deschidere,3)-iOpen(NULL,interval_deschidere,3);

if(trend_actual==1)
{

if( (MathAbs(rezultat_bara_1) > lung_candela*zecimal) || ((MathAbs(rezultat_bara_1+rezultat_bara_2)) > lung_candela*zecimal))
{
if(rezultat_bara_2>0 && rezultat_bara_2>lung_candela*zecimal) return 0;
if(rezultat_bara_3>0 && rezultat_bara_3>lung_candela*zecimal) return 0;
double tp=Ask+zecimal_EURO_OR_YEN*buy_profit;
int ticket= OrderSend(Symbol(),OP_BUY,lot_siz/100,Ask,0,0,tp);
if(ticket<0)Print("OrderSend failed with error #",GetLastError());
   else Print("OrderSend placed successfully");
//---

}
else return 0;
}

return 1;
}

YEN - parameters

lung_candela=300
interval_deschidere=30
interval_inchidere=5
zecimal=0.001
zecimal_EURO_OR_YEN=0.01
lot_siz=4
nr_de_tranzactii=5
nr_de_tranzactii_SELL=5
buy_profit=10.0
TrailingStop=50.0
lung_candela_SELL=250
interval_deschidere_SELL=30
interval_inchidere_SELL=5
buy_profit_SELL=10.0
 

0 comments:

Post a Comment