Questions from Beginners MQL5 MT5 MetaTrader 5 - page 555

 
Alexey Viktorov:

I read those arguments. But it wasn't an argument, it was just an unwillingness to understand explanations and attempts to prove the fault of the terminal. Your words were not backed up by anything. You are too lazy to make screenshots and explain your thoughts clearly.

What screenshots?! I have provided the code, it is running on MT4 and it will crash on MT5. The type of error is written in the code which is also commented out.
 
comp:
What screenshots?! Provided code, it runs on MT4 and crashes with an error in MT5. The type of error is written in the code which is also commented out.

That's fine. That's your point of view. You think that everyone has to do something to understand your point of view, but you don't think that it's easier not to argue with you, and it's really easier to get banned for being too demanding.

I fortunately do not have the right to ban, so I am just stopping this dialogue.

 
Please tell me why orders are not opening
void OnTick()
  {
   int pos;
   int rsi;
   int uroven1;
   int uroven2;
   int kolpos;
   uroven1=RSI_uroven1;
   uroven2=RSI_uroven2;

   rsi=iRSI(Symbol(),0,RSI,0,1);

//==================================================================
   for(int pos=0; pos<OrdersTotal(); pos++)
     {
      OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
         kolpos++;

     }
//====================================================================
   if(kolpos==0)
     {
      if(rsi>uroven1 || rsi<uroven1 || rsi>uroven2 || rsi<uroven2)
        {
         OrderSend(Symbol(),OP_BUY,Lot,Ask,30,0,0,"",Magic,0,clrAliceBlue);
         OrderSend(Symbol(),OP_SELL,Lot,Bid,30,0,0,"",Magic,0,clrRed);

        }
     }
  }
Please tell me why the orders are not opening.
 
edutak:
Please tell me why orders are not opening.

I have at least 4 errors

'RSI_uroven1' - undeclared identifier 32.mq4 13 12

'RSI_uroven2' - undeclared identifier 32.mq4 14 12

'RSI' - undeclared identifier 32.mq4 16 24

'pos' - variable already defined 32.mq4 19 12

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property strict
int RSI=23;
int RSI_uroven1=100;
int RSI_uroven2=100;
int Magic=777;
double Lot=0.1;
void OnTick()
  {
   int pos;
   int rsi;
   int uroven1;
   int uroven2;
   int kolpos;
   uroven1=RSI_uroven1;
   uroven2=RSI_uroven2;

   rsi=iRSI(Symbol(),0,RSI,0,1);

//==================================================================
   for(int pos=0; pos<OrdersTotal(); pos++)
     {
      OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
         kolpos++;

     }
//====================================================================
   if(kolpos==0)
     {
      if(rsi>uroven1 || rsi<uroven1 || rsi>uroven2 || rsi<uroven2)
        {
         OrderSend(Symbol(),OP_BUY,NormalizeDouble(Lot,2),Ask,30,0,0,"",Magic,0,clrAliceBlue);
         OrderSend(Symbol(),OP_SELL,NormalizeDouble(Lot,2),Bid,30,0,0,"",Magic,0,clrRed);

        }
     }
  }
//+------------------------------------------------------------------+

все октрывает

1	2015.01.02 09:00	buy	1	0.10	120.42	0.00	0.00	0.00	10000.00
2	2015.01.02 09:00	sell	2	0.10	120.39	0.00	0.00	0.00	10000.00
3	2016.04.04 13:08	close at stop	2	0.10	111.66	0.00	0.00	3.26	10003.26
4	2016.04.04 13:08	close at stop	1	0.10	111.63	0.00	0.00	-11.85	9991.41

 
edutak:
Please tell me why the orders are not opening.

First of all I gave you a normal function that counts the number of orders, but you still continue to use your wrong one.

Secondly if(rsi>uroven1 || rsi<uroven1 || rsi>uroven2 || rsi<uroven2) conditions are mutually contradictory.

 
Vitalii Ananev:

First of all I gave you a normal function that counts the number of orders, but you still continue to use your wrong one.

Secondly if(rsi>uroven1 || rsi<uroven1 || rsi>uroven2 || rsi<uroven2) conditions are mutually inconsistent.

I will use normal functions, this is a draft for now, for the tester - I just copy in blocks, it's faster that way.

If at crossing RSI of any of levels an order opens, and at crossing any other level - it closes and immediately opens another, then there is no contradiction.

Or is there?

 
Vladislav Andruschenko:

I have at least 4 errors

'RSI_uroven1' - undeclared identifier 32.mq4 13 12

'RSI_uroven2' - undeclared identifier 32.mq4 14 12

'RSI' - undeclared identifier 32.mq4 16 24

'pos' - variable already defined 32.mq4 19 12


Thank you, it works.
 
edutak:

I will use normal functions, this is a rough draft for now, for the tester - I just copy in blocks, it's quicker that way.

If when RSI crosses any of the levels an order opens and when it crosses any other level it closes and immediately opens another, then there is no contradiction.

Or is there?

Just think about it. Let's assume that uroven1 = 80; rsi = 30; the condition rsi > 80 or rsi < 80 means that (30 > 80 [false] or 30 < 80[true]) does not exist in nature. Although the condition will be true, because it uses an OR operator, but it is essentially meaningless.

The second part of the expression Suppose uroven2 = 20; rsi = 30 (30 > 20 [true] or 30< 20[false] ) is the same.

 

The second part of the expression Suppose uroven2 = 20; rsi = 30 (30 > 20 [true] or 30< 20[false] ) is the same.

When I write or, I mean that at any level crossing, the order will be opened. When the second condition 30<20[false] occurs, at that moment, the previous order will be closed and it will become true.

If I understand it correctly.

 
If you turn out to be right, I will add a second RSI.
Reason: