[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 123

 
Thanks for your help, I replacedOrdersTotal() withOrdersHistoryTotal(). It worked.
 

For those who understand mql4 more than I do, please help. There are 3 questions.

1.First on the double constant. We have all known iMa, masks, Moving Average/ The question is: Incorrect mapping of values.

Example:

extern string  MA1="";
extern string  MA2="";
extern string  MA3="";
string com;


double MA1 = iMA(NULL,PERIOD_M15,9,0,0,0);
double MA2 = iMA(NULL,PERIOD_M15,15,0,0,0);
double MA3 = iMA(NULL,PERIOD_M15,21,0,0,0);

if (MA1>MA2 && MA1!=MA2 && MA1>MA3 && MA1!=MA3 ) com="значение1";
if (MA1<MA2 && MA1==MA2 && MA1<MA3 && MA3!=MA3 ) com="значение2";

So the value all the time will be = value1. The code stubbornly refuses to understand != (not equal)

2. Question /Opening Search Closing/.

What I want from the program but it doesn't work.

1.Check condition (true ; false)

2. If there is such an order, we don't open it; if there is no order, we open it. We open it based onOrderComment() condition.

3. Checking If the X or Y event occurs , close. X-(for example another signal iMA1>iMA2, Y-another signal iMA2>iMA3)

That's how I do it but nothing comes out.

if (MA1>MA2 && MA1!=MA2 && MA1<MA3 && MA2>MA3 && MA2!=MA3)
{
   for (int i=1;i<=OrdersTotal(); i++)       
       {
        if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if (OrderComment()=="значение1")return(0);
            else
            {
            OrderSend(Symbol(),OP_SELL, LOT,NormalizeDouble(Bid,Digits),2,0,0,com,Magic,0,Red);
            }
           }
       } 
}

And how to close I do not understand where to insert.

3. Question about the offset (int shift)

In the second group of iMA, I shift the relative current bar back by 3) What for, so that when a signal described above, do not open repeated orders on each bar. But the shift does not happen for some reason.

double MA1 = iMA(NULL,PERIOD_M15,9,0,0,0);
double MA2 = iMA(NULL,PERIOD_M15,15,0,0,0);
double MA3 = iMA(NULL,PERIOD_M15,21,0,0,0);

double MA4 = iMA(NULL,PERIOD_M15,9,0,0,3);
double MA5 = iMA(NULL,PERIOD_M15,15,0,0,3);
double MA6 = iMA(NULL,PERIOD_M15,21,0,0,3);

Please help me with the knowledge. I do not know how to use it. I do not know where in the Internet there is a similar implementation.

 
dertop:

For those who understand mql4 more than I do, please help. There are 3 questions.

1.First by constant double.

2. how to close I don't understand where to put in at all.

3. Question about offset (int shift)

1. https://www.mql5.com/ru/articles/1561

2. if (close conditions) OrderClose(...)

3. See what exactly this shift is and who it shifts
 
ilunga:

1. https://www.mql5.com/ru/articles/1561

2. if (closing conditions) OrderClose(...)

3. See what exactly this shift is and who it shifts


Thank you very much for such a quick reply.

About 1. Yes, I got it, we will dig there.

On 2.if (closing conditions) OrderClose(...) (it is clear without it) But I got confused in if, what for where where and why....

Correct if wrong....

if (MA1>MA2 && MA1!=MA2 && MA1<MA3 && MA2>MA3 && MA2!=MA3)                                         // если true то заходим в тело цикла...
{
   for (int i=1;i<=OrdersTotal(); i++)                                                             //шаг2 проверяем все ордера на наличие ордера со значением1
       {
        if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if (OrderComment()=="значение1")return(0);                                            // если орден найден то ничего не делаем
            else
            {
            OrderSend(Symbol(),OP_SELL, LOT,NormalizeDouble(Bid,Digits),2,0,0,com,Magic,0,Red);   // а вот тут проблемы кто за чем идёт и куда вставить условие закрытие отдельно за телом всего условия (ma1;ma2 и тд), или там где OrderSelect()
            }
           }
       } 
}

The index of the value obtained from the indicator buffer (shift relative to the current bar by the specified number of periods back). from mql4 help

 
dertop:


Thank you very much for such a quick reply.

By 2.if (closing conditions) OrderClose(...) (that's understandable without it) But I'm confused in if, what for where where and why....

Correct if wrong....


if (MA1>MA2 && MA1!=MA2 && MA1<MA3 && MA2>MA3 && MA2!=MA3)                                         // если true то заходим в тело цикла...
{
   for (int i=1;i<=OrdersTotal(); i++)                                                             //шаг2 проверяем все ордера на наличие ордера со значением1
       {
        if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if (OrderComment()=="значение1")return(0);                                            // если орден найден то ничего не делаем
            else
            {
            OrderSend(Symbol(),OP_SELL, LOT,NormalizeDouble(Bid,Digits),2,0,0,com,Magic,0,Red);   // а вот тут пока написано следующее: для каждого из ордеров у которого мы сюда зашли мы поставим еще один ордер
            }
           }
       } 
}
 
ilunga:

Sorry, why check inequalities when the condition is already given! This slows down the reading of the conditions and their fulfilment!

if (MA1>MA2 && MA1!=MA2 && MA1<MA3 && MA2>MA3 && MA2!=MA3)//MA1!=MA2 && и && MA2!=MA3 не нужны, т.к. в предыдущих сравнениях
                                                          //равенство ухе исключено! Так что нужно так:
if (MA1>MA2 && MA1<MA3 && MA2>MA3)
 
borilunad:

Sorry, why check inequalities when the condition is already given! This slows down the reading of the conditions and their fulfilment!


There's something strange here.

if (MA1>MA2 && MA1<MA3 && MA2>MA3)

MA1>MA2 and MA2>MA3 and then MA1<MA3

Especially since it is sufficient to

if (MA1>MA2 && MA2>MA3)
 
borilunad:

Sorry, why check inequalities when the condition is already given! This slows down the reading of the conditions and their fulfilment!


I'm sorry, I missed it a bit. I didn't pay attention to it at first. These calculations are made for 4 MAs, and there are cases when MA1>MA2 and at the time MA3=MA4 (so check is needed because this is how the strategy is built)

if (MA1>MA2 && MA1!=MA2 && MA1<MA3 && MA2<MA3 && MA2!=MA3 && MA3<MA4 && MA3!=MA4)                                         // если true то заходим в тело цикла...
{
   for (int i=1;i<=OrdersTotal(); i++)                                                             //шаг2 проверяем все ордера на наличие ордера со значением1
       {
        if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if (OrderComment()=="значение1")return(0);                                            // если орден найден то ничего не делаем
                else
                {
                if (OrderComment()!="значение1")                                                         // если такого ордера нету
                   {
                   OrderSend(Symbol(),OP_SELL, LOT,NormalizeDouble(Bid,Digits),2,0,0,com,Magic,0,Red);   // тогда открываем
                   }
                }
         if (MA1<MA2 && MA1!=MA2 && MA1>MA3 && MA1!=MA3 && MA3>MA4 && MA3!=MA4)                          // если true новый сигнал
             {
            OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),3,CLR_NONE);               // тогда закрываем
             }

           }
       } 
}

Like this?????

 
Vinin:


There's something strange here.

MA1>MA2 and MA2>MA3 and then MA1<MA3


Yeah sorry got confused, first time writing on the forum. Copypasted first, then decided to handwrite and got confused... but the example above is correct...

MA1>MA2 and MA1<MA3 and MA3<MA4

 

Good afternoon.

Please help me to modify the indicator.

I have a standard Pivot, i would like to have an indicator that calculates levels using standard formulas, but using H, L, C data i enter myself.

I want to use it as an alternative to the standard Pivot.