Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1125

 
BillionerClub:

How do I convert the mouse position in time, but without throwing?

There has to be at least some kind of event. Would moving the mouse work?
 
Alexey Viktorov:
Well, there has to be some kind of event. Maybe moving the mouse would work?

No, just reading the coordinates and converting during the candle.

 
Alexey Viktorov:
Well at least there must be some event. Maybe moving the mouse would work?

Yes thanks, you're right, it's the same thing. Although, of course, a person would first move the mouse and then press the hotkey.

 
It turned out to be impossible to use functions of custom events in scripts. Now I have to run the indicator and use it to run the script. In principle, what difference does it make if you don't use drag and drop, but hotkeys.
 
BillionerClub:
It's funny, it turns out that custom event functions cannot be used in scripts. Now I have to run the indicator and run the script through it. In principle, what difference does it make if I don't use drag and drop, but hotkeys.

I probably should have written in the documentation more specifically that OnChartEvent does not work in scripts, but such a line is in the documentation

The function can be called in Expert Advisors and indicators, it should have void type and 4 parameters:

And custom events have nothing to do with it.

 
BillionerClub:

How to convert, mouse position, in time, but without throwing?

Some people write without punctuation, others poke around... They think because they're asking a question everyone should know what they're talking about...

Did you go to school? Was it hard? Do you think it's going to be easy here? Wouldn't you rather go back to school?

 
Alexey Viktorov:

Well, here's the line.

Just put a number instead of a formula and ...

I do so, but it returns zero. This function in indicator"A_D1", I put its value in the buffer, then I call indicator from script, output value to the printer

  Lot= iCustom(NULL,0,"A_D1",0,1);
  Print("Lot ",DoubleToStr(Lot,2));

If the function in the indicator with the string

RiskMony = floor(FreeMargin*risk/100);

it will print some number 0.07, but if

RiskMony =1.5;//

it will print 0.00

 

Thank you all for all your help and criticism, everyone be kind. I added the entire script to the indicator via CHARTEVENT_CLICK as a function. Everything worked out, convenience at times and speed.


#include <Keys.mqh>
CKeys ckeys;

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//--- нажатие кнопки на клавиатуре 
   if(id==CHARTEVENT_CLICK)
     {

      if(ckeys.KeyCtrlState())
        {
        Запустить();        
        }

     }

  }



 
macleta:

I do so, but it returns zero. This function in the indicator"A_D1", I put its value in the buffer, then I call the indicator from the script, output the value to the printer

If the function in the indicator with the string

it will print some number 0.07, but if

it will print 0.00.

Int seems to go to binary rounding, truncation, and is not compatible with other data types, no loss.

 
macleta:

I do so, but it returns zero. This function in the indicator"A_D1", I put its value in the buffer, then I call the indicator from the script, output the value to the printer

If the function in the indicator with the string

it will print some number 0.07, but if

it will print 0.00

How about 15 or 20 instead of 1.5? Maybe you want to make very little profit on a too long TP?
Reason: