Download MetaTrader 5

Need help! with OnChartEvent comma expected error

To add comments, please log in or register
Carry on your private correspondence in your profile. It is secure!
Jiayu Fu
1230
Jiayu Fu 2015.02.16 07:34 

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
45497
Vladimir Karputov 2015.02.16 07:50  

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
45497
Vladimir Karputov 2015.02.16 08:17  
//+------------------------------------------------------------------+
//| 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
1230
Jiayu Fu 2015.02.16 16:19  
barabashkakvn:

Thank u!!

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

To add comments, please log in or register