Pls I need someone to help me identify the two complaint error from this code.

 
#include<Trade\Trade.mqh>
CTrade trade;
int OnStart()
{
    double g;
    int m,s,k;
    m =Time[0] + Period()*60-TimeCurrent();
    g=m/60.0;
    s=m%60;
    m=(m-s)/60;
    double OPen[];
    double Close[];
    double High[];
    double Low[];
    

void OnTick()
{
    double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
    double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
    string Signal="";
    double myRSIArray[];
    ArraySetAsSeries(myRSIArray,true);
    int myRSIDefinition = iRSI(_Symbol,_Period,7,PRICE_CLOSE);
    CopyBuffer(myRSIDefinition,0,0,3,myRSIArray);
    double myRSIValue=NormalizeDouble(myRSIArray[0],2);
    if(((Open[1]-Close[1])>0 && (Open[0]-Ask)<0 && ((MathAbs(Open[0]-Ask))/(Open[1]-Close[1]))>=2 && m>=58 && myRSIValue<=70 && (Open[0]-Low[0])>(High[0]-Ask)) || 
    ((Open[1]-Close[1])<0 && (Open[0]-Ask)<0 && ((MathAbs(Open[0]-Ask))/(Open[1]-Close[1]))>=2 && m>=58 && myRSIValue<=70 && (Open[0]-Low[0])>(High[0]-Ask)) || 
    ((Open[1]-Close[1])==0 && (Open[0]-Ask)<0 && ((MathAbs(Open[0]-Ask))/(Open[1]-Close[1]))>=2 && m>=58 && myRSIValue<=70))
    {
        Signal="buy";
    }
    if((Open[1]-Close[1])<0 && (Open[0]-Bid)>0 && ((Open[0]-Bid)/(MathAbs(Open[1]-Close[1])))>=2 && m>=58 && myRSIValue>=30 && (High[0]-Open[0])>(Bid-Low[0])) ||
     (Open[1]-Close[1])>0 && (Open[0]-Bid)>0 && ((Open[0]-Bid)/(MathAbs(Open[1]-Close[1])))>=2 && m>=58 && myRSIValue>=30 && (High[0]-Open[0])>(Bid-Low[0])) || 
     (Open[1]-Close[1])==0 && (Open[0]-Bid)>0 && ((Open[0]-Bid)/(MathAbs(Open[1]-Close[1])))>=2 && m>=58 && myRSIValue>=30))
    {
        Signal="sell";
}
    if(Signal="buy" && PositionTotal()<3)     {         trade.Buy(0.001,NULL,Ask,(Ask-1600*_Point),(Ask+10000*_Point),NULL);         CheckTrailingStop(Ask);     }
    if(Signal="buy" && PositionTotal()<3)
    {
        trade.Sell(0.001,NULL,Bid,(Bid+1600*_Point),(Bid-10000*_Point),NULL);
        CheckTrailingStop(Bid);
    }
}

void CheckTrailingStop(double Ask,double Bid)
{
    double SL=NormalizeDouble(Ask-150*_Point,Digits);
    for(int i=PositionsTotal()-1; i>=0; i--)
    {
        string symbol=PositionSymbol(i);
        if(_Symbol==symbol)
        ulong PositionTicket=PositionGetInteger(POSITION_TICKET);
        double CurrentStopLoss=PositionDouble(POSITION_SL);
        int PositionDirection=PositionGetInteger(POSITION_TYPE);
        if(CurrentStopLoss<SL && PositionDirection==POSITION_TYPE_BUY)
        {
            trade.PositionModify(PositionTicket,(CurrentStopLoss+10*_Point),0);
        }
        if(CurrentStopLoss>SL && PositionDirection==POSITION_TYPE_SELL)
        {
            trade.PositionModify(PositionTicket,(CurrentStopLoss-10*_Point),0);
        }
    }
}

 

Why do you have OnStart() AND OnTick()?

Is this supposed to be an EA or a script?

 
  1. You are mixing the concepts of a Script (OnStart) and that of an Expert Advisor (OnTick).
  2. You are mixing concepts from MQL4 and MQL5:
    1. MQL5 does not have the the predefined array variables Open[], High[], Low[], Close[]. Those are only available in MQL4. Use the methods as described in the MQL5 documentation.
    2. MQL5 does not have the the predefined variables Ask or Bid (see below).
  3. Indicator handles should first be obtained in the OnInit() event handler, not in the other event handlers.
  4. Price quotes returned by the terminal are already normalised. Don't normalise them again.
    For calculated price quotes, normalise prices based on the tick size. Don't normalise based on Points or number of Digits (see below).
  5. When scanning through the currently open positions, you need to Select the position first before obtaining its properties. So use the function PositionGetSymbol() to obtain it's symbol and select the position by index as well, for further processing. Or use the class CTrade functionality from the Trade Classes in the Standard Library if you prefer Object Oriented Programming.

    Forum on trading, automated trading systems and testing trading strategies

    Help

    Fernando Carreiro, 2022.04.23 14:09

    Unlike MQL4, MQL5 does not have the predefined variables "Ask" and "Bid". So, you will have to assign them yourself, either by using the SymbolInfoDouble() function or by using the SymbolInfoTick() function.

    Example using SymbolInfoDouble() function (sample code is untested/uncompiled):

    double
       Ask = SymbolInfoDouble( _Symbol, SYMBOL_ASK ),   // Get symbol's current Ask price
       Bid = SymbolInfoDouble( _Symbol, SYMBOL_BID );   // Get symbol's current Bid price

    Example using SymbolInfoTick() function (sample code is untested/uncompiled):

    MqlTick oTick; // Declare variable of MqlTick structure
    
    if( SymbolInfoTick( _Symbol, oTick ) )
    {
       double
          Ask = oTick.ask,   // Get symbol's current Ask price or just use "oTick.ask" directly in your code instead of "Ask"
          Bid = oTick.bid;   // Get symbol's current Bid price or just use "oTick.bid" directly in your code instead of "Bid"
    
       // Rest of your code goes here ...
    };

    If you want to mimic the MQL4 style of predefined variables, then you can use one the following examples (sample code is untested/uncompiled):

    double Ask, Bid; // Globally scoped Ask and Bid prices
    
    void OnTick()
    {
       Ask = SymbolInfoDouble( _Symbol, SYMBOL_ASK ),   // Get symbol's current Ask price
       Bid = SymbolInfoDouble( _Symbol, SYMBOL_BID );   // Get symbol's current Bid price
    
       // Rest of your code goes here
    };
    double Ask, Bid; // Globally scoped Ask and Bid prices
    
    void OnTick()
    {
       MqlTick oTick; // Declare variable of MqlTick structure
    
       if( SymbolInfoTick( _Symbol, oTick ) )
       {
          Ask = oTick.ask,   // Get symbol's current Ask price
          Bid = oTick.bid;   // Get symbol's current Bid price
    
          // Rest of your code goes here ...
       };
    };

    Forum on trading, automated trading systems and testing trading strategies

    Tick size vs Point(), can be a little tricky in Multicurrency EA

    Fernando Carreiro, 2022.03.09 12:11

    Tick Size and Point Size can be very different especially on stocks and other symbols besides forex.

    Always use Tick Size to adjust and align your prices, not the point size. In essence, make sure that your price quotes, are properly aligned to the Tick size (see following examples).

    ...
    double tickSize = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_SIZE );
    ...
    double normalised_price = round( price / tick_size ) * tick_size;
    ...
    // Or use a function
    double Round2Ticksize( double price )
    {
       double tick_size = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_SIZE );
       return( round( price / tick_size ) * tick_size );
    };
    Documentation on MQL5: Standard Library / Trade Classes / CTrade
    Documentation on MQL5: Standard Library / Trade Classes / CTrade
    • www.mql5.com
    CTrade - Trade Classes - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
     
    Dotia2u

    You must create a blank using the MQL5 Wizard program:


     
    Fernando Carreiro #:
    1. You are mixing the concepts of a Script (OnStart) and that of an Expert Advisor (OnTick).
    2. You are mixing concepts from MQL4 and MQL5:
      1. MQL5 does not have the the predefined array variables Open[], High[], Low[], Close[]. Those are only available in MQL4. Use the methods as described in the MQL5 documentation.
      2. MQL5 does not have the the predefined variables Ask or Bid (see below).
    3. Indicator handles should first be obtained in the OnInit() event handler, not in the other event handlers.
    4. Price quotes returned by the terminal are already normalised. Don't normalise them again.
      For calculated price quotes, normalise prices based on the tick size. Don't normalise based on Points or number of Digits (see below).
    5. When scanning through the currently open positions, you need to Select the position first before obtaining its properties. So use the function PositionGetSymbol() to obtain it's symbol and select the position by index as well, for further processing. Or use the class CTrade functionality from the Trade Classes in the Standard Library if you prefer Object Oriented Programming.

      Thanks alot, I really appreciate your contribution. I will send the Code as soon as am done with

       
      Fernando Carreiro #:
      1. You are mixing the concepts of a Script (OnStart) and that of an Expert Advisor (OnTick).
      2. You are mixing concepts from MQL4 and MQL5:
        1. MQL5 does not have the the predefined array variables Open[], High[], Low[], Close[]. Those are only available in MQL4. Use the methods as described in the MQL5 documentation.
        2. MQL5 does not have the the predefined variables Ask or Bid (see below).
      3. Indicator handles should first be obtained in the OnInit() event handler, not in the other event handlers.
      4. Price quotes returned by the terminal are already normalised. Don't normalise them again.
        For calculated price quotes, normalise prices based on the tick size. Don't normalise based on Points or number of Digits (see below).
      5. When scanning through the currently open positions, you need to Select the position first before obtaining its properties. So use the function PositionGetSymbol() to obtain it's symbol and select the position by index as well, for further processing. Or use the class CTrade functionality from the Trade Classes in the Standard Library if you prefer Object Oriented Programming.

        Thanks to y'all am able to compile the code successfully, thanks alot. But I can't get to use the ticks instead

         
        Dotia2u #:

        Thanks to y'all am able to compile the code successfully, thanks alot. But I can't get to use the ticks instead

        Are you connected and login in?
        Reason: