Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 287

 
evillive:

That's the thing, there's no free price in the code, you can't just replace it(((

Try here

switch(InpMAMethod)
     {
      case MODE_EMA:  CalculateEMA(rates_total,prev_calculated,close);        break;
      case MODE_LWMA: CalculateLWMA(rates_total,prev_calculated,close);       break;
      case MODE_SMMA: CalculateSmoothedMA(rates_total,prev_calculated,close); break;
      case MODE_SMA:  CalculateSimpleMA(rates_total,prev_calculated,close);   break;
     }

change close to open. If it starts counting by open, then dig in this direction how to change this value. I can't run beta terminal now to look through its editor.

Change the value here beforehand:

//--- counting from 0 to rates_total
   ArraySetAsSeries(ExtLineBuffer,false);
   ArraySetAsSeries(close,false);
//--- first calculation or number of bars was changed
 
There is no point in changing Close to Open, there will be little change. It is easier not to bother with such nonsense, but to take data from the formed bar.
 

Greetings all))

I wrote an EA, but it doesn't work at all)))) or it doesn't work correctly. i've been poking around, fixing many things, but nevertheless, the EA doesn't work.

here is a fragment of the calculation of trading decisions based on the RSI indicator :

//--------------------Данные------------------------------------

   int Ticket1_RSI=-1, Ticket2_RSI=-1;                    // Номера открытых ордеров
   extern double Lot=0.01;                                 // Объем лота
int RSI()                                                  // Функция RSI
   {                                                                                                             
   double T, P;
   double RSI_0, RSI_1, RSI_2;                      // Значения индикатора RSI
//------------------Значения индикатора---------------------------------------   
   RSI_0=iRSI(Symbol(), 0, 14, PRICE_CLOSE, 0);              // Получаем данные от RSI 
   RSI_1=iRSI(Symbol(), 0, 14, PRICE_CLOSE, 1);              // Получаем данные от RSI 
   RSI_2=iRSI(Symbol(), 0, 14, PRICE_CLOSE, 2);              // Получаем данные от RSI 
//------------------Условие на продажу---------------------------------   
   if (RSI_1 > RSI_0 > 70 && RSI_1 > RSI_2)         // Если индикатор превышает значение 70 и виден поворот вниз
      {                                                                                                           
      if (Ticket2_RSI > 0)                                                     // Если имеется ордер на покупку
         OrderClose(Ticket2_RSI, OrderLots(), Bid, 0, 0);                            // Закрытие ордера на покупку
      if (Ticket1_RSI <= 0)                                                    // Если ордера на продажу нет
         {
         Ticket1_RSI=OrderSend(Symbol(), OP_SELL, Lot, Bid, 2, 0, 0);        // Открытие ордера на продажу
         if (OrderSelect(Ticket1_RSI, SELECT_BY_TICKET)==true)
            {
            T=OrderOpenTime();
            P=OrderOpenPrice();
            ObjectCreate("Arrow", 22, 0, T, P);               // Создание индикатора ордера
            ObjectSet("Arrow", OBJPROP_COLOR, IndianRed);                             // Изменение цвета в мутно-красноватый
            ObjectSet("Arrow", OBJPROP_ARROWCODE, 242);                               // Направление стрелки вниз
            ObjectCreate("Text", 21, 0, T, P);                // Создание текстового объекта
            ObjectSetText("Text", "Open sell-order by RSI", 6, "Times New Roman", Navy);     // Текст, шрифт, стиль, цвет     
            }
         }
      }
//-------------------Условие на покупку--------------------------------   
   if (RSI_1 < RSI_0 < 30 &&  RSI_1 < RSI_2)         // Если индикатор ниже значения 30 и виден поворот вверх
      {
      if (Ticket1_RSI > 0)                                                     // Если имеется ордер на продажу
         OrderClose(Ticket1_RSI, OrderLots(), Ask, 0, 0);                            // Закрытие ордера на продажу
      if (Ticket2_RSI <= 0)                                                    // Если ордера на продажу нет
         {
         Ticket2_RSI=OrderSend(Symbol(), OP_BUY, Lot, Ask, 2, 0, 0);         // Открытие ордера на покупку
         if (OrderSelect(Ticket2_RSI, SELECT_BY_TICKET)==true)
            {
            T=OrderOpenTime();
            P=OrderOpenPrice();
            ObjectCreate("Arrow", 22, 0, T, P);   // Создание индикатора ордера          
            ObjectSet("Arrow", OBJPROP_COLOR, LawnGreen);                             // Изменение цвета в ярко-зеленый
            ObjectSet("Arrow", OBJPROP_ARROWCODE, 241);                               // Направление стрелки вверх
            ObjectCreate("Text", 21, 0, T, P);     // Создание текстового объекта
            ObjectSetText("Text", "Open buy-order by RSI", 6, "Times New Roman", Navy);      // Текст, шрифт, стиль, цвет
            }
         }   
      }
//--------------------------------------------------------------------   
   return;    
   } 

The thing is, the EA immediately opens a buy order, despite the value of the indicator, and does not want to close it. Objects like text and arrows do not appear.

Help me figure this out)) just new to this myself

 
waroder:

Greetings all))

I wrote an EA, but it doesn't work at all)))) or it doesn't work correctly. i've been poking around, fixing many things, but nevertheless, the EA doesn't work.

here is a fragment of the calculation of trading decisions based on the RSI indicator :

//--------------------Данные------------------------------------

The thing is, the EA immediately opens a buy order, despite the value of the indicator, and does not want to close it. Objects like text and arrows do not appear.

Help me figure this out)) just new to this myself


if (RSI_1 > RSI_0 && RSI_0 > 70 && RSI_1 > RSI_2)         // Если индикатор превышает значение 70 и виден поворот вниз
 
Vinin:



So you have to write each inequality separately in the conditions? If you generalise somehow, it will be seen as an error? Then why does the program say there are no errors when compiling?
 
waroder:

So you have to write each inequality separately in the conditions? If you generalize it somehow, it will be perceived as an error? Then why does the program say that there is no error when compiling?

There is no error, you just don't get the result you are expecting.
 
hoz:

...How do you look for a cause in a situation like this?


Purely by accident I stumbled across it. You need to simplify things. Comment everything out, uncomment the first import, compile, call functions, etc.


 
Integer:
There is no point in changing Close to Open, there will be little change. It is easier not to bother with such nonsense, but take the data from the formed bar.
I agree, but since there was a question...
 
Vinin:

There is no error, you just do not get the result you were expecting.


I figured it out)) one order was opened immediately without any further changes, because I had to write NULL instead of Symbol() in the line:

   RSI_1=iRSI(Symbol(), 0, 14, PRICE_CLOSE, 1);              // Получаем данные от RSI 

You have to write NULL instead of Symbol(), because there is a discrepancy in the variable types. Because of this, I saw RSI as a null value, so I immediately opened it, because the condition worked.

I have now fixed it and everything is fine.

The only problem is that the objects are only created once on the first trade.

 

ouch ouch ouch... I'm an idiot))))))

I create objects all with the same name, so I get the error that the object already exists)))))))

Reason: