Job finished
Specification
Hi
You have to convert/ rewrite my Mql4 code into Mql5 code.
Back testing enable required.
you have to explain me that how i can enable and disable buy or sell in it ( Trade opening criteria is already in my Mql4 code)
It should work with Grid=.002 and Grid=.2 ( already in my Mql4 code)
Arrange all steps as in my code, put the trading function Buy or Sell in the last if possible or let me know how to able and disable trading function.
Here is the code below
----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//| Grid 2021 New.mq4 |
//| Smile |
//| https://www.mql5.com/en/signals/author/tahirabbas |
//+------------------------------------------------------------------+
#property copyright "Smile"
#property link "https://www.mql5.com/en/signals/author/tahirabbas"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double OrderPirice,OrderSize,Lot,rsi,ReSize
,Grid=0.002,Profit,otp;
string symbol,csymbol;
int ticket,Type,result;
int i =(OrdersTotal()-1);
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
OrderPirice=OrderOpenPrice();
OrderSize=OrderLots();
Type=OrderType();
symbol=OrderSymbol();
otp=OrderTakeProfit();
}
if (OrdersTotal()<4){ReSize=1;}
if (OrdersTotal()<3){Profit=300;}
if (OrdersTotal()>2&&OrdersTotal()<6){Profit=400;}
if (OrdersTotal()==4){ReSize=1.5;}
if (OrdersTotal()==5){ReSize=2;}
if (OrdersTotal()>5){Profit=500;}
if (OrdersTotal()==11){ReSize=1.5;}
if (OrdersTotal()==10){ReSize=1.3;}
if (OrdersTotal()==9){ReSize=1.5;}
if (OrdersTotal()==8){ReSize=1.5;}
if (OrdersTotal()==7){ReSize=2;}
if (OrdersTotal()==6){ReSize=.7;}
//Print("Symbol",OrderSymbol());
csymbol=ChartSymbol();
if (symbol==csymbol&&OrdersTotal()<12&&OrderPirice-Ask>=Grid)
{
if (Type==OP_BUY==true)
{
Lot=(OrderSize*ReSize);
MathRound (Lot);
ticket=OrderSend(symbol,OP_BUY,Lot,Ask,300,0,0,"",0,0,Green);
for(int Kb = 0; Kb < OrdersTotal(); Kb++)
{
if(OrderSelect(Kb, SELECT_BY_POS, MODE_TRADES) == true)
OrderModify(OrderTicket(),OrderOpenPrice(),0,Ask+Point*Profit,0,CLR_NONE);
}
}
}
csymbol=ChartSymbol();
if (symbol==csymbol&&OrdersTotal()<12&&Bid-OrderPirice>=Grid)
{
if (Type==OP_SELL==true)
{
Lot=(OrderSize*ReSize);
MathRound (Lot);
ticket=OrderSend(symbol,OP_SELL,Lot,Bid,300,0,0,"",0,0,Red);
for(int Ks = 0; Ks < OrdersTotal(); Ks++)
{
if(OrderSelect(Ks, SELECT_BY_POS, MODE_TRADES) == true)
OrderModify(OrderTicket(),OrderOpenPrice(),0,Bid-Point*Profit,0,CLR_NONE);
}
}
}
if (symbol==csymbol&&OrdersTotal()==1&&otp==0)
{
if (Type==OP_BUY==true)
{
for(int Kb = 0; Kb < OrdersTotal(); Kb++)
{
if(OrderSelect(Kb, SELECT_BY_POS, MODE_TRADES) == true)
OrderModify(OrderTicket(),OrderOpenPrice(),0,Ask+Point*Profit,0,CLR_NONE);
}
}
}
if (symbol==csymbol&&OrdersTotal()==1&&otp==0)
{
if (Type==OP_SELL==true)
{
for(int Kb = 0; Kb < OrdersTotal(); Kb++)
{
if(OrderSelect(Kb, SELECT_BY_POS, MODE_TRADES) == true)
OrderModify(OrderTicket(),OrderOpenPrice(),0,Bid-Point*Profit,0,CLR_NONE);
}
}
}
rsi=iRSI(NULL,0,14,PRICE_CLOSE,0);
if (OrdersTotal()<1)
{
if (rsi<50)
{
ticket=OrderSend(NULL,OP_BUY,0.02,Ask,300,0,Ask+300*Point,"WhatsApp",0,0,Green);
}}
rsi=iRSI(NULL,0,14,PRICE_CLOSE,0);
if (OrdersTotal()<1)
{
if (rsi>50)
{
ticket=OrderSend(NULL,OP_SELL,0.02,Bid,300,0,Bid-300*Point,"WhatsApp",0,0,Red);
}}
}
//------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
}
//+------------------------------------------------------------------+
//| Tester function |
//+------------------------------------------------------------------+
double OnTester()
{
//---
double ret=0.0;
//---
//---
return(ret);
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+