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

 
Lol Kek:

Is it possible for an input variable of type boolean in the Input parameters interface to make it possible to double click instead of toggling between true/false to display its text? Thanks

enum  ENUM_ONOFF
{
On  = 1,  // On   тут любой текст
Off = 0   // Off  тут любой текст
};

input ENUM_ONOFF iValue = On; // Параметр
 
Vladimir Pastushak:

Thank you, but that's a bit different. I know about this method - in this case I will have a drop-down selector, when you select it, select the value.

But I need it to work as input bool yesOrNo = true; - when in incoming parameters just click twice and it changes value to the opposite and vice versa at repeated ones. Only instead of true and false print your text

 
Lol Kek:

Thanks, but it's a bit different. I know about this way - in this case I will have a drop-down selector when I have to select it, select the value.

I need it to work like input bool yesOrNo = true; - when in incoming parameters just click twice and it changes value to the opposite and vice versa at repeated ones. Only instead of true and false print your text

There is no difference bool is true and folse is 1, folse is 0

 

Hello. I'm a green beginner. Some tips on the basics.

1 - why am I programming in mql4? It sends me a template for mql5 withint OnInit() and void OnTick() functions? They don't create errors, but do they work. I am starting to get confused.

2 - I am writing an Expert Advisor.void OnTick() - as I see it replaces the int start() function andint OnInit()- instead ofint init().

2.1 - I've prescribed the variables to be used inint OnInit() and it started to complain. I assigned a variable type immediately as it appears. The curse stopped. Why?

2.2 - It is easy to open pendingBuy and Sellorders. Why does not it open them? Although I don't see any errors.

int BS1 = OrderSend (Symbol(),OP_BUYSTOP,lots,Ask+50,3,0,0,"bs1",1,0,clrGreen);

int SS1 = OrderSend (Symbol(),OP_SELLSTOP,lots,Bid+50,3,0,0,"ss1",-1,0,clrRed);

3 - How to screw a counter to the variable - order number. (BS1, SS1) - variables that directly tell us which order it is. So, when the EA continues to search for the necessary order, it will detect it just as easily.Will its identifier remain the same afterOP_BUYSTOP changes its value toBUY? Will I be able to find it using the data in BS1?

4 - What is the easiest way to check if any of thepending orders is already open or not, especially if possible slippage of 3 points is specified in opening parameters. I.e. it scans a range of prices, not just one price and may open at 1-3 pips above/below the default price....

5. Please advise where to get a textbook or lessons on MQL4. I want to improve my skills. I wonder. It may be a strategy described in 2 lines, but when I open an Expert Advisor, I see 100500 lines of code. Why... I don't understand the code :(


I'm flooded with questions :)) Please help me understand

 
<br/ translate="no">.


I'm swamped with questions )))) Please help me understand

2.2 : Ask+50 is a bit of a stretch :-) 50 as far as I understood the idea of the points... I mean 50 * _Point... and normalize it. That is, instead of Ask+50 you should write NormalizeDouble(Ask+50*_Point,_Digits).

 
@Maxim Kuznetsov- thank you.)
 

Read, understood what each of the parameters means, set.....

My pending sell is not opening. It doesn't even give out errors.GetLastError()=0! It opens to buy as it should, but ignores to sell. It makes me laugh, what does it want? ))))

int BS1 = OrderSend (Symbol(),OP_BUYSTOP,lots,NormalizeDouble(Ask+50*_Point,_Digits),3,0,0,"bs1",1,0,clrGreen);
  int SS1 = OrderSend (Symbol(),OP_SELLSTOP,lots,NormalizeDouble(Bid+50*_Point,_Digits),3,0,0,"ss1",101,0,clrRed);
    if (GetLastError()==1);
    {
    Alert (GetLastError());
    }

Good people, where can I get the necessary knowledge? ))

 
Gilmor:

Read, understood what each of the parameters means, set.....

My pending sell is not opening. It doesn't even give out errors.GetLastError()=0! It opens to buy as it should, but ignores to sell. It makes me laugh, what does it want? ))))

Good people, where can I get the necessary knowledge? ))

There is an interesting tab in the terminal called "Experts". This is where the mistakes of experts are written. Take a look. And then in your code.

 
int start()                                  // Спец. функция start()
  {                                          
  double prise;
  double lots = 0.01;  
  if (OrdersTotal()<1)
  {
  prise = MarketInfo(Symbol(), MODE_ASK);
  // int BS1 = OrderSend (Symbol(),OP_BUYSTOP,lots,NormalizeDouble(Ask+50*_Point,_Digits),3,0,0,"bs1",1,0,clrGreen);
  int SS1 = OrderSend (Symbol(),OP_SELLSTOP,lots,NormalizeDouble(Bid+50*_Point,_Digits),3,0,0,"ss1",101,0,clrRed);
   /* if (GetLastError()==1);
    {
    Alert (GetLastError());
    }
    */
  }
 
   return;                                   // Выход из start()
  }

Artyom Trishkin:

There is an interesting tab in the terminal - "Experts". It contains errors of Expert Advisors. You may look through it. And then in your code.

As you can see this tab also shows supposedly perfect. Loaded it, initiated it. It has no errors whatsoever. :(

And so, thank you! I didn't know about using this tab.

 

Good afternoon.

I've been torturing myself for a week trying to find information. Help with the code))

Purpose : To find out the difference in opening and closing pips of a candle.

Add it up and display it on the screen, for 100 bars.

In the end, I want to see the total amount on the screen.

void OnTick ()

{

double minprice =99999 , mp,cl,

maxprice =-99999;

double Index = 0;

double Index1 = 0;

for(int i=100; i>0; i--)

{

mp = iLow (Symbol(), PERIOD_CURRENT, i);

cl = iClose(Symbol(), PERIOD_CURRENT, i);

if( mp < minprice)

minprice = mp - cl;

Index = minprice + mp ;

}

Thank you.

Документация по MQL5: Константы, перечисления и структуры / Константы графиков / Периоды графиков
Документация по MQL5: Константы, перечисления и структуры / Константы графиков / Периоды графиков
  • www.mql5.com
Все предопределенные периоды графиков имеют уникальные идентификаторы. Идентификатор PERIOD_CURRENT означает текущий период графика, на котором запущена mql5-программа.
Reason: