Syntax help

 

Hello,

I'm not super good with understanding C++ and mt5 so this is probably super simple but I'm getting a '<' illegal operation use on line 45 and 49 as well as some operator expected on 51. Can anyone help me with this?

#include<Trade\Trade.mqh>
CTrade trade;
bool Cross_Below = false;
void OnTick()
  {
//---
    
    MqlTick price;
    SymbolInfoTick(_Symbol, price);
    
    double ask = price.ask;
    double bid = price.bid;
    
    // price array with previous price info
    MqlRates PriceInfo[];
    
    // sorts the array from the current candle as 0 to past being n
    ArraySetAsSeries(PriceInfo, true);
    
    //this fills the array with data from the current candle back 3 candles
    int PriceData = CopyRates(_Symbol,_Period,  0,3, PriceInfo);
    
    string signal = "";
    
    double EMA50Array[], EMA100Array[], EMA150Array[];
    
    int EMA50Definition = iMA(_Symbol, _Period, 50,0,MODE_EMA,PRICE_CLOSE);
    
    int EMA100Definition = iMA(_Symbol, _Period, 100,0,MODE_EMA,PRICE_CLOSE);
    
    int EMA150Definition = iMA(_Symbol, _Period, 150,0,MODE_EMA,PRICE_CLOSE);
    
    ArraySetAsSeries(EMA50Array, true);
    
    ArraySetAsSeries(EMA100Array, true);
    
    ArraySetAsSeries(EMA150Array, true);
    
    CopyBuffer(EMA50Definition, 0,0, 50, EMA50Array);
    
    CopyBuffer(EMA100Definition, 0,0, 100, EMA100Array);
    
    CopyBuffer(EMA150Definition, 0,0, 150, EMA150Array);
    
    if (PriceInfo[0] < EMA50Array[0])
    {
    bool Cross_Below = true;
    }
    if (Cross_Below == true && PriceInfo[0] > EMA50Array[0])
    {
    trade.Buy(0.10, NULL, bid,0(bid-150*_Point),NULL);
    }
    datetime time = price.time;
    
    Comment(ask, bid, EMA50Array[0],EMA100Array[0], EMA150Array[0]);
  }
 
never mind I solved it price can only be used as a reference
 
Tim G. :
never mind I solved it price can only be used as a reference

Remember: in MQL5, the indicator handle is received ONCE IN OnInit !!!

Forum on trading, automated trading systems and testing trading strategies

How to start with MQL5

Vladimir Karputov, 2020.11.13 06:01

Receiving data from an indicator in an MQL5.

Scheme:

Getting data from indicators in an MQL5 Expert Advisor

An example for the iMA indicator:


Reason: