pls help me to Migrating from mql4 to mql5

 

Hi guys,

I fixed some errors..but now i have 15 error in my EA pls help me. thats a trading pannel.


//+------------------------------------------------------------------+
//|                                                   TradePanel.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                          https://www.cafemql.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.cafemql.com"
#property version   "1.00"
#property strict

#include <stderror.mqh>
#include <stdlib.mqh>
#include "Include/Components.mqh"


 int               InpATRperiod=14;         // ATR Periods
 float             InpRisk=1;               // Risk Size %
 float             InpSLfactor=1.5;         // Stop Loss as a factor of ATR
 float             InpTPfactor=1.0;         // Take Profit as a factor of ATR
 float             InpFixedATR=0;

string AccntC=AccountInfoString(ACCOUNT_CURRENCY);                  //Currency of Acount eg USD,GBP,EUR
string CounterC=StringSubstr(Symbol(),3,3);        //The Count Currency eg GBPUSD is USD
string ExC=AccntC+CounterC;                        //Create the Pair for account eg USDGBP


int PointToPip=1;
double pips;



int bar_offset=1;//bar offset to acquire size 
double risk=1;//risk %

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+


int OnInit()
  {
 

   // If the digits are 3 or 5, we normalize multiplying by 10.
   if ((_Digits == 3) || (_Digits == 5)){
      pips =_Point* 10; 
      PointToPip = PointToPip * 10;
   }
   else
      pips=_Point;
//---
  MyPanel();
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnTimer(){


}

void OnDeinit(const int reason)
  {
//---
    TradePanel.Destroy(reason);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 
   
  
    
    double PointToPip = SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE);
   // If the digits are 3 or 5, we normalize multiplying by 10.
   if ((_Digits == 3) || (_Digits == 5)){
      PointToPip = PointToPip * 10;
   }
    
    //double lot=get_lot_by_bar_size_and_risk(bar_offset,risk);
    //double stoplosspips = NormalizeDouble( stoplosspips.Text(lot),_Digits );
    //double lotsizestop = NormalizeDouble( lotsizestop.Text(lot),2);
    CounterC=StringSubstr(Symbol(),3,3);
   double riskedit=( lotedit.Text() );
   int Atrper=( atredit.Text() );
   int stopedit=( stoplossedit.Text() );
   float Atrvalue=iATR(_Symbol,_Period,Atrper,0);
   
   int pipMult=10000;
   if(CounterC=="XAU")
   pipMult=100;
  double ATRpips=MathCeil(pipMult*Atrvalue);
   float showatr=NormalizeDouble(rightatr.Text(Atrvalue),_Digits);
  float showpips=NormalizeDouble(rightpips.Text((pipMult*Atrvalue)*stopedit+" pips"),_Digits);
  showatr=NormalizeDouble(showatr,2);
  float riskbalance=(AccountInfoDouble(ACCOUNT_BALANCE)/100.0)*riskedit;
  
  int showriskbalance=NormalizeDouble(rightrisk.Text(riskbalance),_Digits);
  
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   TradePanel.OnEvent(id,lparam,dparam,sparam);
   

//--- Place Noticable for Buy Position
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="Buy Button")
   {
        int ans = MessageBox("Are you sure to place a BUY order?","Place Order",MB_YESNO | MB_ICONQUESTION);
        
        if(ans == IDYES)
           PlaceOrder(OP_BUY);
   }  

//--- Place Noticable for Sell Position
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="Sell Button")
   {
        int ans = MessageBox("Are you sure to place a SELL order?","Place Order",MB_YESNO | MB_ICONQUESTION);
        
        if(ans == IDYES)
           PlaceOrder(OP_SELL);
   }  
   
//--- Place Noticable for Buy Position
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="Buy limit Button")
   {
        int ans = MessageBox("Are you sure to place a BUY order?","Place Order",MB_YESNO | MB_ICONQUESTION);
        
        if(ans == IDYES)
           PlaceOrder(OP_BUYLIMIT);
   }  

//--- Place Noticable for Sell Position
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="Sell limit Button")
   {
        int ans = MessageBox("Are you sure to place a SELL order?","Place Order",MB_YESNO | MB_ICONQUESTION);
        
        if(ans == IDYES)
           PlaceOrder(OP_SELLLIMIT);
   }   
   
      
   
   
  }
//+------------------------------------------------------------------+
//|  Place Order  Market                                                   |
//+------------------------------------------------------------------+
void PlaceOrder(int type)
{
      
   //--- Initialize Variables (openprice, stoploss, takeprofit)
   float lotsize=( lotedit.Text() );
   int Atrper=( atredit.Text() );
   int stopedit=( stoplossedit.Text() );
   double tpedit=( Rewardedit.Text() );
   double openprice  = 0  ;
   double takeprofit = 0 ; 
   
//      double lotsize = StrToDouble( lotedit.Text() );
//     //double Candleback = StrToDouble( Candleback.Text() );
//   double Padamount = StrToDouble( padamount.Text() );
//   double Rewardprofit = StrToDouble( Rewardprofit.Text() );
//   
//   double StopLoss=StrToDouble( Candleback.Text() );
   //--- Trade Volume



double ExCRate=1;                                            //Assume Account is same as counter so ExCRate=1
   AccntC=AccountInfoString(ACCOUNT_CURRENCY);                                      //Currency of Acount eg USD,GBP,EUR
   CounterC=StringSubstr(Symbol(),3,3);                           //The Count Currency eg GBPUSD is USD
   ExC=AccntC+CounterC;                                           //Create the Pair for account eg USDGBP
   if(AccntC!=CounterC)
      ExCRate= SymbolInfoDouble(ExC,MODE_ASK); 
   if(ExCRate ==0) ExCRate=1.0;
   double Atrvalue=iATR(NULL,0,Atrper,0); 
   double stoplosss   = (Atrvalue*stopedit)  ;  
             
   double riskVAccntC=AccountInfoDouble(ACCOUNT_EQUITY)*(lotsize/100);
   double riskvalue=(ExCRate/1)*riskVAccntC;                      //Risk in Account Currency
   double riskperpoint=(riskvalue/stoplosss)*_Point;
   double lot=riskperpoint;  

   double stoploss=0;
 
 //---BUY Position Checking...
  if(type == OP_BUY)
   {
   //---openprice, stoploss, takeprofit for Buy Position
   MqlTick last_tick;
   SymbolInfoTick(_Symbol,last_tick);
   double Ask=last_tick.ask;
       openprice   = Ask;
       //double PadPercent=Padamount*(StopLoss/100);
      stoploss    = NormalizeDouble(openprice - stoplosss,_Digits);  
      takeprofit  = NormalizeDouble(openprice + (stoplosss*tpedit),_Digits); 
       
   }
 
   //---SELL Position Checking...
   if(type == OP_SELL)
   {
    //---openprice, stoploss, takeprofit for Sell Position
      MqlTick last_tick;
      SymbolInfoTick(_Symbol,last_tick);
      double Bid=last_tick.bid;
      openprice = Bid;
      //double PadPercent=Padamount*(StopLoss/100);
      stoploss    = NormalizeDouble(openprice + stoplosss,_Digits);  
      takeprofit  = NormalizeDouble(openprice - (stoplosss*tpedit),_Digits);     
   }   

   if( OrderSend(_Symbol,type,lot,openprice,30,stoploss,takeprofit) == -1)
        Print("unable to place order due to \"",ErrorDescription(GetLastError()),"\"");
   
}