MQL5 To MQL4 Simple Condition How can i Be Change

 
  //--- Include standard libraries
#include <Trade\AccountInfo.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\Trade.mqh>
#include <Indicators/Trend.mqh>
 
//Declared Valuation
double Ask_price;
double Bid_price;
CTrade trade;
CPositionInfo positionInfo; 
int MACD_handle ;
double MACD_close[],Signal_Close[];



int OnInit()
  {
   MACD_handle = iMACD(_Symbol,PERIOD_H1,12,6,2,PRICE_CLOSE);
   return(INIT_SUCCEEDED);
  }
void OnTick()
{
   CopyBuffer(MACD_handle,6,0,3,Signal_Close);
   ArraySetAsSeries(Signal_Close,true);
   
   CopyBuffer(MACD_handle,5,0,3,MACD_close);
   ArraySetAsSeries(MACD_close,true);


   //Buy Sell Trade Conditions

   Ask_price=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),Digits());
   Bid_price=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),Digits());

    if(PositionSelect(_Symbol) == false)
   {
      //BUY
      if(

         MACD_close[0] > Signal_Close[0] &&
         MACD_close[1] < Signal_Close[1] &&
         )
          {
           trade.Buy(0.1,_Symbol);
          }

      //SELL
     if(

         MACD_close[0] > Signal_Close[0] &&
         MACD_close[1] < Signal_Close[1] &&
         )
          {
           trade.Sell(0.1,_Symbol);
          }



    //CONDITION Close  BUY AND SELL
  if(PositionSelect(_Symbol) == true)
   {
      if(positionInfo.PositionType()==POSITION_TYPE_BUY)
      {
         //STOP LOSS For Buy POSITION
         if(MACD_close[0] < Signal_Close[0] && MACD_close[1] > Signal_Close[1] && MACD_close[0] > 0)
         {
            trade.PositionClose(_Symbol);
            
         } 

       }
       if(positionInfo.PositionType()==POSITION_TYPE_SELL)
       {
         //STOP LOSS For SELL POSITION
         if(MACD_close[0] > Signal_Close[0] && MACD_close[1] < Signal_Close[1] && MACD_close[0] < 0 )
         {
            trade.PositionClose(_Symbol);
            
         }      
 
       }       
   } 
}      
 
Pruthviraj6212: MQL5 To MQL4 Simple Condition How can i Be Change

Mql4 does not have handles, positions, or CopyBuffer. It must be rewritten.

 
William Roeder #:

Mql4 does not have handles, positions, or CopyBuffer. It must be rewritten.

PositionSelect how can i use in mql4 ?
 
Pruthviraj6212 #: PositionSelect how can i use in mql4 ?

I will repeat what William wrote—MT4 does not have positions.

It only has orders, be they market orders or pending orders. It does not have positions (nor deals), only orders.

Please read the documentation ... Trade Functions - MQL4 Reference

EDIT: Also, MQL4 does not have a "Trade" Standard Library.

Trade Functions - MQL4 Reference
Trade Functions - MQL4 Reference
  • docs.mql4.com
Trade Functions - MQL4 Reference