Download MetaTrader 5

Need help! with OnChartEvent comma expected error

To add comments, please log in or register
Jiayu Fu
1294
Jiayu Fu  

i compiled it with the aim to show me the spread of the market when i press 'Q' but i get this error " comma expected"

thx,

 

string obj_spread = "Market Spread";  
//+------------------------------------------------------------------+
void OnChartEvent(const int CHARTEVENT_KEYDOWN,         // Event ID
                  const long& Q,   // Parameter of type long event
                  const double& 2, // Parameter of type double event                       // <--------------------------------the error is here
                  const string& NULL  // Parameter of type string events'
  )
  {
        spread = MarketInfo(Symbol(), MODE_SPREAD); 
      s string s = +DoubleToStr(spread, 0)+" pips";
       ObjectCreate(obj_spread, OBJ_LABEL, 0, 0, 0);
       ObjectSet(obj_spread, OBJPROP_CORNER, 0);
       ObjectSet(obj_spread, OBJPROP_YDISTANCE, 16);
       ObjectSet(obj_spread, OBJPROP_XDISTANCE, 190);e
       ObjectSetText(obj_spread, s, 5, "FixedSys", Blue);
    ObjectSetText(obj_spread, s);
    WindowRedraw(); 
  } 
Vladimir Karputov
Moderator
61173
Vladimir Karputov  

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.



Vladimir Karputov
Moderator
61173
Vladimir Karputov  
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if(id==CHARTEVENT_KEYDOWN) // CHARTEVENT_KEYDOWN
      if(lparam==71)
        {
         string obj_spread="Market Spread";
         spread=MarketInfo(Symbol(),MODE_SPREAD);
         s string s=+DoubleToStr(spread,0)+" pips";
         ObjectCreate(obj_spread,OBJ_LABEL,0,0,0);
         ObjectSet(obj_spread,OBJPROP_CORNER,0);
         ObjectSet(obj_spread,OBJPROP_YDISTANCE,16);
         ObjectSet(obj_spread,OBJPROP_XDISTANCE,190);e
         ObjectSetText(obj_spread,s,5,"FixedSys",Blue);
         ObjectSetText(obj_spread,s);
         WindowRedraw();
        }
  }
Jiayu Fu
1294
Jiayu Fu  
barabashkakvn:

Thank u!!

ahh sry i'm new here i didnt know the src button. 

To add comments, please log in or register