Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 285

 
 
buyanov:

got the message "comma expected" I don't know what it means, maybe I should contact the developers?


int WhatType()

//>>>>>>>>>>>>>>>>>>>>>

{



Alert("beg  WhatType()");



if(OrderSelect(NextTick,SELECT_BY_TICKET)==true) Alert("OrderSelected=",NextTick);

Alert(NextTick);



Alert("NextType=",NextType);

OpPrice=OrderOpenPrice();

ClPrice=OrderClosePrice();



if(ClPrice>OpPrice)CurType=OP_BUY;

else CurType=OP_SELL;



Alert("CurType=",CurType);



Alert("end WhatType()");

//>>>>>>>>>>>>>>>>>>>>>>>>>

}//Alert("end int WhatType()");


In which line does the compiler give an error?

 

Good afternoon!

Made a line that I want to move freely. At the moment you have to click on the line and only then you can move it. How can I make it possible to move the line without double clicking?

double startL;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
startL=Bid;

SetHLine(clrAqua, "", startL, STYLE_SOLID, 5);    
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }

color array_color[5]={clrRed,clrAliceBlue,clrAqua,clrRoyalBlue,clrCrimson};
void OnChartEvent(const int    id,
                  const long   &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_OBJECT_DRAG)
     {
      Print("object name: ",sparam);
      ObjectSetInteger(0,sparam,OBJPROP_COLOR,array_color[rand()%5]);
     }
  }
    

void SetHLine(color cl, string nm="", double p1=0, int st=0, int wd=1) {
  if (nm=="") nm=DoubleToStr(Time[0], 0);
  if (p1<=0) p1=Bid;
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_HLINE, 0, 0,0);
  ObjectSet(nm, OBJPROP_PRICE1, p1);
  ObjectSet(nm, OBJPROP_COLOR , cl);
  ObjectSet(nm, OBJPROP_STYLE , st);
  ObjectSet(nm, OBJPROP_WIDTH , wd);
}
//+----------------------------------------------------------------------------+
 
Nauris Zukas:

Good afternoon!

Made a line that I want to move freely. At the moment you have to click on the line and only then you can move it. How can I make it possible to move the line without double clicking?

ObjectSetInteger(0,nm,OBJPROP_SELECTED,true);
Actually, you wrote a very old design
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_HLINE
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_HLINE
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_HLINE - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Vitaly Muzichenko:
ObjectSetInteger(0,nm,OBJPROP_SELECTED,true);


Thank you, but something didn't work. I put it this way, maybe something is wrong?

   if(id==CHARTEVENT_OBJECT_DRAG)
     {
      Print("object name: ",sparam);
      ObjectSetInteger(0,sparam,OBJPROP_SELECTED,true);
      ObjectSetInteger(0,sparam,OBJPROP_COLOR,array_color[rand()%5],true);     
     }
Vitaly Muzichenko:
Actually, you have written a very old construction.

I searched through the forum, I've seen constructions with classes, but I'm not good at classes, so I wanted to start with the simplest one (in terms of appearance).

 
Nauris Zukas:


Thank you, but something didn't work. I put this function this way, must be something wrong?

I searched the forum, I saw constructions with classes, but I'm not good at classes, so I wanted to start with the simplest one (in terms of appearance).

There should be a pair with OBJPROP_SELECTABLE

   if(id==CHARTEVENT_OBJECT_DRAG)
     {
      Print("object name: ",sparam);
      ObjectSetInteger(0,sparam,OBJPROP_SELECTABLE,true);
      ObjectSetInteger(0,sparam,OBJPROP_SELECTED,true);
      ObjectSetInteger(0,sparam,OBJPROP_COLOR,array_color[rand()%5],true);     
     }
 
Alexey Viktorov:

Must be paired with OBJPROP_SELECTABLE

I don't know, something is not working. It only moves after a double click and the line goes black.

 
Nauris Zukas:

I don't know, something doesn't work. It only moves after a double click and the line goes black.

Well, then add another before these two lines.

ObjectSetInteger(0, sparam, OBJPROP_HIDDEN, false);
 
Alexey Viktorov:

Well, then add another line in front of those two lines.

Didn't work, maybe there 's a mistake in the code?

Files:
 
buyanov:

I got the message "comma expected", I don't know what it means, may be I should contact the developers?


int WhatType()

//>>>>>>>>>>>>>>>>>>>>>

{


Alert("beg WhatType()");


if(OrderSelect(NextTick,SELECT_BY_TICKET)==true) Alert("OrderSelected=",NextTick);

Alert(NextTick);


Alert("NextType=",NextType);

OpPrice=OrderOpenPrice();

ClPrice=OrderClosePrice();


if(ClPrice>OpPrice)CurType=OP_BUY;

else CurType=OP_SELL;


Alert("CurType=",CurType);


Alert("end WhatType()");

//>>>>>>>>>>>>>>>>>>>>>>>>>

}//Alert("end int WhatType()");

I pasted it into MetaEditor, tweaked it a little - no errors

void WhatType()
//>>>>>>>>>>>>>>>>>>>>>
{
Alert("beg  WhatType()");
int NextTick=1, NextType=1;
if(OrderSelect(NextTick,SELECT_BY_TICKET)==true) Alert("OrderSelected=",NextTick);
Alert(NextTick);
Alert("NextType=",NextType);
double OpPrice=OrderOpenPrice();
double ClPrice=OrderClosePrice();
int CurType;
if(ClPrice>OpPrice)CurType=OP_BUY;
else CurType=OP_SELL;
Alert("CurType=",CurType);
Alert("end WhatType()");
//>>>>>>>>>>>>>>>>>>>>>>>>>
}//Alert("end int WhatType()");
Reason: