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

 
Guys, is the update out yet?
 
I have a question about indicators with stochastic at levels 20 and 80. Or MACD with level 0.
so the question is how to take the value of the indicator when it is below 20 or above 80, the main line and the signal line.Or crossed behind these levels.Indicator values, I think I've got, but then what to do with them do not know.

Stoh=iStochastic(Symbol(),PERIOD_H1,Kperiod,Dperiod,slowing,MODE_SMA,0,MODE_MAIN,0);
StohSignal=iStochastic(Symbol(),PERIOD_H1,Kperiod,Dperiod,slowing,MODE_SMA,0,MODE_SIGNAL,0)

Macd=iMACD(Symbol(),PERIOD_H4,fast_ema_period,slow_ema_period,signal_period,PRICE_CLOSE,MODE_MAIN,0);
MacdSignal=iMACD(Symbol(),PERIOD_H4,fast_ema_period,slow_ema_period,signal_period,PRICE_CLOSE,MODE_SIGNAL,0);
 
denis77515:
Gentlemen programmers, explain pliz stochastic indicators have levels 20, 80. Or MACD with level 0.
I think i have got the indicator value, but i don't know what to do with it.

Stoh=iStochastic(Symbol(),PERIOD_H1,Kperiod,Dperiod,slowing,MODE_SMA,0,MODE_MAIN,0);
StohSignal=iStochastic(Symbol(),PERIOD_H1,Kperiod,Dperiod,slowing,MODE_SMA,0,MODE_SIGNAL,0);

Macd=iMACD(Symbol(),PERIOD_H4,fast_ema_period,slow_ema_period,signal_period,PRICE_CLOSE,MODE_MAIN,0);
MacdSignal=iMACD(Symbol(),PERIOD_H4,fast_ema_period,slow_ema_period,signal_period,PRICE_CLOSE,MODE_SIGNAL,0);


Study Guide

although it's probably too late, we're updating today.

example from the tutorial

//--------------------------------------------------------------------
// grafobjects.mq4
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------
int start()                            // Спец. функция start
  {
//--------------------------------------------------------------- 1 --
   int Sit;
   double MACD_M_0,MACD_M_1,           // Главная линия, 0 и 1 бар
   MACD_S_0,MACD_S_1;                  // Сигнальная линия, 0 и 1 бар
   string Text[4];                     // Объявление строков. массива
   color  Color[4];                    // Объявление массива цветов

   Text[0]= "Открытие Buy";            // Текст для различных ситуаций
   Text[1]= "Открытие Sell";
   Text[2]= "Удерживаем Buy";
   Text[3]= "Удерживаем Sell";

   Color[0]= DeepSkyBlue;              // Цвет объекта ..
   Color[1]= LightPink;                // .. для различных ситуаций
   Color[2]= Yellow;
   Color[3]= Yellow;
//--------------------------------------------------------------- 2 --
   ObjectCreate("Label_Obj_MACD", OBJ_LABEL, 0, 0, 0);// Создание объ.
   ObjectSet("Label_Obj_MACD", OBJPROP_CORNER, 1);    // Привязка угол
   ObjectSet("Label_Obj_MACD", OBJPROP_XDISTANCE, 10);// Координата Х
   ObjectSet("Label_Obj_MACD", OBJPROP_YDISTANCE, 15);// Координата Y
//--------------------------------------------------------------- 3 --
   MACD_M_0 =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);  // 0 бар
   MACD_S_0 =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);// 0 бар
   MACD_M_1 =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);  // 1 бар
   MACD_S_1 =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);// 1 бар
//--------------------------------------------------------------- 4 --
   // Анализ ситуации 
   if(MACD_M_1<MACD_S_1 && MACD_M_0>=MACD_S_0)// Персеч. снизу вверх
      Sit=0;
   if(MACD_M_1>MACD_S_1 && MACD_M_0<=MACD_S_0)// Персеч. сверху вниз
      Sit=1;
   if(MACD_M_1>MACD_S_1 && MACD_M_0>MACD_S_0) // Главная выше сигн.
      Sit=2;
   if(MACD_M_1<MACD_S_1 && MACD_M_0<MACD_S_0) // Главная ниже сигн.
      Sit=3;
//--------------------------------------------------------------- 5 --
   // Изменение свойств объекта
   ObjectSetText("Label_Obj_MACD",Text[Sit],10,"Arial",Color[Sit]);
//--------------------------------------------------------------- 6 --
   return;                             // Выход из start()
  }
//--------------------------------------------------------------- 7 --
int deinit()                           // Спец. функция deinit
   {
   ObjectDelete("Label_Obj_MACD");     // Удаление объекта
   return;                             // Выход из deinit()
   }
//--------------------------------------------------------------- 8 --
 
double close_price(int nomer_bara)
{
if(nomer_bara<1)
{
Alert("нельзя анализировать текущий бар");
}
else
{
if(iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)<iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)/3)//возвращает 1/3 если цена текущего бара закрылась ниже 1/3 его спреда 
{
return(1/3);
}
if(iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)>iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)/3&&(iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)<iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)*2)/3)//возвращает 2/3 если цена текущего бара закрылась ниже 2/3 и выше 1/3 его спреда 
{
return(2/3);
}

if((iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)>(iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara))*2)/3&&iClose(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara)<iHigh(Symbol(),NULL,nomer_bara)-iLow(Symbol(),NULL,nomer_bara))//возвращает 1 если цена текущего бара закрылась выше 2/3 его спреда
{
return(1);
}
}

}

 if(close_price(1)==1/3)// в случае если цена закрылась внизу то нарисовать линию на этом баре
   {
 SetVLine(Red, "", Time[1], STYLE_SOLID, 2);
   }
и так вся проблема заключается в том что линия рисуется на каждом баре не пойму какого черта... помогите пожалуйста
the line should be drawn on the bar where the price closed at the bottom, i.e. 1/3 bar
 

Hi! Going to reinstall Windows, but when I move the EAs folder to harddrive, the EAs written recently are gone! Any advice on what to do?

*I can not save the code in a document and then re-create them, because there are a lot of them, and I do not want to lose data because of a possible human factor :)

 
Good day! Please help!!! The programmer who wrote the Expert Advisor disappeared... I had to finish it myself... I had to rewrite it myself, and i still have one function to implement. My Expert Advisor is working on breakdowns of support and resistance levels + Fibo levels as a second signal, respectively, in Fibo. As a result, I get a signal, but it did not work due to some restrictions or not enough points to set the minimum Take Profit. Please help, advise or throw link to advisor.... I am looking for a restriction to enter the trade. To buy the price has to break the level from bottom to top only, and for sell from top to bottom. Thanks so much in advance!!!!!
 

Guys, please help, there is a function that returns the lot of the last open order (which is not yet closed). Can you modify it to return the lot of the next-to-last open order (also not yet closed)? Just do it without using arrays...

double FindLastLots (int otype)
{
  double oldopenprice,oldlots;
  int oldticket;
  
  ticket = 0;
  
  for (int i = OrdersTotal()-1; i>=0; i--)
  {
    if (OrderSelect(i, SELECT_BY_POS,MODE_TRADES)) 
    {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType() == otype)
      {
         oldticket = OrderTicket();
         if (oldticket>ticket)
         {
            oldlots = OrderLots();
            ticket = oldticket; 
         } 
      }  
    }
  }
  return (oldlots);
}
 
Trader7777:

Guys, please help, there is a function that returns the lot of the last open order (which is not yet closed). Can you modify it to return the lot of the next-to-last open order (also not yet closed)? Only do it without using arrays...

You don't have arrays here either. The code is not very reliable. You're looking for the last one in the list of open orders. IMHO, binding to this is not very reliable. The most reliable way to find the last open order is by its open time (it is the lowest of all)
 
Is there any tricky way to call the trend line with a hotkey?
 
okvseok:
Is there any tricky way to call a trend line with a hotkey?
You could write a script that draws this line. Bind this script to a hotkey.
Reason: