Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1317

 
Vladimir Karputov:

See the errors:

1. Always specify the chart symbol explicitly (yes, you can rely on documentation, but it's better to ALWAYS specify it explicitly)

2. String makes no sense - as preff+"hhh" will never equal Symbol()


Added: better to have this approach - always one line on the chart, just change the price of the line when you switch charts.

If explicit warning: implicit conversion from 'string' to 'number'

The essence of the problem is that the line is not displayed where it was created.

If I create it on the tool at the price of 255, why is it displayed at 255 when I load another tool with the current price of 310?

Please tell me how to save the line and display it where it was created.
 
serg_V777:

If it explicitly issues a warning: implicit conversion from 'string' to 'number'

The essence of the problem is that the line is not displayed where it was created.

If I create it on the tool at the price of 255, why is it displayed at 255 when I load another tool with the current price of 310?

Please advise how to save the line and display it where it was created.

You have shown me your code snippet - I have given you your snippet. Declare the variables and you won't have errors.

I cannot understand your logic with lines. Try to describe your actions in detail - and most importantly WHY you need to do it.


In your code I don't understand whyChartSymbol

 
Vladimir Karputov:

You showed me a scrap of code - I gave you your scrap. Declare the variables and there will be no errors.

I do not understand your logic with lines. Try to describe your actions in detail - and most importantly WHY you should do it.


In your code, I don't understand why I needChartSymbol.

void OnChartEvent(const int id,           // идентификатор события   
                  const long& lparam,     // параметр события типа long 
                  const double& dparam,   // параметр события типа double 
                  const string& sparam) { // параметр события типа string 
 
 
  preff=ChartSymbol( NULL);
  price=SymbolInfoDouble(Symbol(),SYMBOL_BIDLOW); 
 if(id == CHARTEVENT_OBJECT_CLICK && sparam == "dz_draw")// Нажатие кнопки   
  {   
   ObjectCreate(0,preff+"hhh",OBJ_HLINE,0,0,price) ;    
 ObjectSetInteger(0,preff+"hhh",OBJPROP_COLOR,clrBlack); 
   ObjectSetInteger(0,preff+"hhh",OBJPROP_STYLE,0); 
   ObjectSetInteger(0,preff+"hhh",OBJPROP_WIDTH,3); 
   ObjectSetInteger(0,preff+"hhh",OBJPROP_BACK,false); 
   ObjectSetInteger(0,preff+"hhh",OBJPROP_SELECTABLE,true); 
   ObjectSetInteger(0,preff+"hhh",OBJPROP_SELECTED,true); 
   ObjectSetInteger(0,"dz_draw"   ,OBJPROP_STATE,false);
   }
}

So I create a line at the price of 277 on the Gazp chart.

When I change it in the same window on Sber, the line created on Gazp at 277 is displayed...

If I create and Sber line at 310, I get two lines on the chart - one correct (created where needed and what it costs) and the second wrong - not from this chart ....

By changing tools and creating lines in the price range of 200- 400 and going back to the Gazp chart I get both people and horses mixed up :),

But I need the only one (maybe a couple of horizontal lines), created where and when I need it.

 
serg_V777:

So I create a line at 277 on the Gazp chart...

When changing in the same window on Sber the line created on Gazp at 277 is displayed...

If I also create a line on Sber at 310, I get two lines on the chart - one correct (created where needed and at what needed) and the second incorrect - not from this chart....

By changing tools and creating lines in the price range of 200- 400 and going back to the Gazp chart I get both people and horses mixed up :),

But it's the only one I need (maybe a couple more horizontal lines), created where and when I need it.

ChartSymbol

Read the help. After the help, do not use this operator - you don't need it.


You need the following algorithm: for each character to save the price. The price is stored in global variables of the terminal (global variable name is symbol name). Next, you need to service 'CHARTEVENT_OBJECT_CHANGE' and'CHARTEVENT_OBJECT_DRAG' - and re-save the price to global variables.

There are also a lot of nuances to be solved: for example - there is a global variable and no line on the chart...

 
User_mt5:
Thank you very much. You've really helped me.

And of course, where else could this feature be but in the middle of the list of technical indicators?)

Can't you do it without being sarcastic?

You don't seem to read the documentation at all... And yet you respond to clues as if you were the center of the universe... Only an illiterate, helpless navel...

 
Vitaly Muzichenko:

Thank you!

There is no way to do it with standard tools.

You can't do it without using system DLLs.

I published a whole library for this purpose )

For the 5's separately.
CDir (MT4) - класс для получения оглавления каталога
CDir (MT4) - класс для получения оглавления каталога
  • www.mql5.com
Класс CDir предназначен для получения сведений о файлах и папках вне "песочницы" MQL4 подобно команде MS-DOS Dir. Задействован вызов системных DLL, поэтому следует разрешить их использование.
 
Vladimir Karputov:

Read the help. After the help, do not use this operator - you do not need it.


You need this algorithm: for each symbol you need to save a price. The price is stored in global variables of the terminal (the name of the global variable is just the name of the symbol). Next, you need to service 'CHARTEVENT_OBJECT_CHANGE' and'CHARTEVENT_OBJECT_DRAG' - and re-save the price to global variables.

There are a lot of nuances to be solved yet: for example - there is a global variable and no line on the chart...

Thanks for the algorithm.

Question -- why is the line found and discolored in this code ?

if(preff+"hhh" == ChartSymbol(0) ){
ObjectSetInteger(0,preff+"hhh",OBJPROP_COLOR,clrNONE); }

but to do it the way it should be done is a dark forest to go to....

 
Mikhail Dovbakh:

You can't do it without using system DLLs.

I published a whole library for this purpose )

For 5 separately.

Great, there's just what I need!

 
Сергей Таболин:

Can't you do it without being sarcastic?

You don't seem to read the documentation at all... But you answer the tips like you're the center of the universe... Only an illiterate and helpless navel...

Instead of being rude, you'd do something useful, for God's sake!

And don't bother answering and responding! Your opinion, alas, is of no interest to me!)

 

Please tell me which class to inherit your class from in order to use all the methods of these

to use all methods of these classes inside of your class, without creating objects inside of your class?



Reason: