[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 403

 
Nail_Saby писал(а) >>

I took a piece of code with for from the ready-made function http://fxnow.ru/blog.php?user=Yuriy&blogentry_id=66...

And what about return()? To make it work?

You have to start with the logic. What you want to get and how.

 

Please tell me why it is impossible to equate the value of one MA to another and open a trade in case they are equal. It only works with <= or >=, but nothing else.

 
Stanislav.exe >>:

Подскажите почему нельзя приравнять значение одной МА к другой и в случае их равенства открывать сделку. У меня работает только со знаками <= или >=, а никак иначе.

it is not recommended to compare double variables

 
sanyooooook писал(а) >>

Variables of type double are not recommended to be compared

So what is the right way to write it if I need a crossover and not more or less?

And one more thing, is it possible to count the number of trades for the time equal to: from the first MA crossing to their recrossing?

If yes how...

 
Stanislav.exe >>:

Так как правильно написать если мне нужно именно пересечение, а не больше или меньше?

И ещё один момент можно ли считать количество сделок за время равное: от первого пересечения МА до их повторного пересечения?

Если да то как...

   ma=iMA(NULL,0, MovingPeriod,0,MODE_EMA,PRICE_CLOSE,5);
   ma1=iMA(NULL,0, MovingPeriod1, MovingShift,MODE_EMA,PRICE_CLOSE,5);
   ma2=iMA(NULL,0, MovingPeriod,0,MODE_EMA,PRICE_CLOSE,1);
   ma3=iMA(NULL,0, MovingPeriod1, MovingShift,MODE_EMA,PRICE_CLOSE,1);
//---- sell conditions
   if ( ma1< ma && ma2< ma3) 
     {
      res=OrderSend(Symbol(),OP_SELL, Lots,NormalizeDouble(Bid,Digits),5,0,0,"", MAGICMA,0,Red);
      f=0;
      return;
     }
//---- buy conditions
   if ( ma1> ma && ma2> ma3)
     {
      res=OrderSend(Symbol(),OP_BUY, Lots,NormalizeDouble(Ask,Digits),5,0,0,"", MAGICMA,0,Blue);
      f=0;
      return;
one version of the code
 
sanyooooook писал(а) >>
one of code variants

Thank you sanyooooook, if I may, what does the last digit in

ma=iMA(....... ...PRICE_CLOSE,.... this 5);

And about the number of deals, is it possible to set the number of deals to be only 1 or 2 or 3 during the MA

 
Stanislav.exe >>:

Спасибо sanyooooook, если можно, что означает последняя цифра в

ma=iMA(....... ..PRICE_CLOSE,.... вот эта пятёрочка 5);

И ещё на счёт количества сделок, можно прописать, чтоб их было например только 1 или 2..3 за время перечения МА

In the MetaEditor, highlight the text you are interested in in this case iMA and press F1, the information about the highlighted line will appear at the bottom of the window

 
sanyooooook писал(а) >>

In the meta-editor, highlight the text you are interested in in this case iMA and press F1, the information about the highlighted line will appear at the bottom of the window.

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

How it in Russian to understand my friend, I've read it, but I can't understand it...

 
Stanislav.exe >>:
shift - Индекс получаемого значения из индикаторного буфера (сдвиг относительно текущего бара на указанное количество периодов назад).

Как это по русски понять дружище, я это уже читал всё равно допереть не могу...

In simple terms, this is the number of the bar from which the indicator signal is taken. The current bar is zero, then the count is deep into history.

 

It is easier and quicker to check the intersection in a different way

   ma11=iMA(NULL,0, MovingPeriod,0,MODE_EMA,PRICE_CLOSE,1);
   ma12=iMA(NULL,0, MovingPeriod,0,MODE_EMA,PRICE_CLOSE,2);
   ma21=iMA(NULL,0, MovingPeriod1,0,MODE_EMA,PRICE_CLOSE,1);
   ma22=iMA(NULL,0, MovingPeriod1,0,MODE_EMA,PRICE_CLOSE,2);
   if (( ma11- ma12)*( ma21- ma22)<0) {
       //пересечение есть
       if ( ma11> ma21)  // Пересечение вверх
       if ( ma11<ma21)  // Пересечение вниз
   }
The speed is faster. Logical complex expressions take longer than simple ones. Multiplication is faster than logical
Reason: