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

 
PS - and also - indirectly :-) - you can store up to 63 letters in a variable name - whether Russian or English...
 
A word of advice, please: when creating the function ObjectCreate (when creating a trend line), I get a ray, which, following from one point to another has a continuation on the chart only to the right side.
 
DemanRap: So the ray that goes from one point to the next only continues to the right-hand side of the graph, but how can I make it continue to the left-hand side?
Can't you draw a ray to the left, or do you want a straight line instead of a ray?
 
I want my robot to be able to track where this ray would be on historical data. For example, I want to check how close it would be to other fractals, not just the 2 fractals on which I originally built it.
 
yes. so my goal is to get a straight line.
 
DemanRap: yes. so my goal is to get a straight line.

datetime time1 = …;
double price1 = …;

datetime time2 = …;
double price2 = …;

datetime timeDifference =  time2 – time1;  // добавить
double priceDifference = price2 – price1;  // добавить

ObjectCreate("trend_line1", OBJ_TREND, 0, time1, price1, time2, price2);
ObjectCreate("trend_line2", OBJ_TREND, 0, time1, price1, time1 - timeDifference, price1 - priceDifference); // добавить

To get a straight line, try adding the highlighted lines

 
Thank you very much, but it turned out to be much simpler. I just drew another ray and swapped time1, price1 and time2 price2 in it. but it took me a whole day to figure it out)))
 
Aleksander:

what about them? - global at terminal level?

they store some time in the variable file :-) date of access, name and value of type double


The question about GV variables is as follows... In S.K.'s book on MQL4, in chapter "GlobalVariables" in section "Properties of GV-Variables" it is written: "A GV variable can only be of type double". Below, in the section "Function GlobalVariableDel()", there is an example of expert globalvar.mq4 with the following content:

//--------------------------------------------------------------------
// globalvar.mq4
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------
int    Experts;                                 // Колич. экспертов
double Depo=10000.0,                            // Заданный депозит
       Persent=30,                              // Заданный процент     
       Money;                                   // Искомые средства
string Quantity="GV_Quantity";                  // Имя GV-переменной
//--------------------------------------------------------------------
int init()                                      // Спец. функция init
  {
   Experts=GlobalVariableGet(Quantity);         // Получим тек. знач.
   Experts=Experts+1;                           // Колич. экспертов
   GlobalVariableSet(Quantity, Experts);        // Новое значение
   Money=Depo*Persent/100/Experts;              // Средства для эксп.
   Alert("Для эксперта в окне ", Symbol()," выделено ",Money);
   return;                                      // Выход из init()
  }
//--------------------------------------------------------------------
int start()                                     // Спец. функция start
  {
   int New_Experts= GlobalVariableGet(Quantity);// Новое колич. эксп.
   if (Experts!=New_Experts)                    // Если изменилось
     {
      Experts=New_Experts;                      // Теперь текущ. такое
      Money=Depo*Persent/100/Experts;           // Новое знач. средств 
      Alert("Новое значение для эксперта ",Symbol(),": ",Money);
     }
   /*
   ...
   Здесь долен быть указан основной код эксперта,
   в котором используется значение переменной Money
   ...
   */
   return;                                      // Выход из start()
  }
//--------------------------------------------------------------------
int deinit()                                    // Спец. ф-ия deinit
  {
   if (Experts ==1)                             // Если эксперт один..
      GlobalVariableDel(Quantity);              //..удаляем GV-перемен
   else                                         // А иначе..
      GlobalVariableSet(Quantity, Experts-1);   //..уменьшаем на 1
   Alert("Эксперт выгружен из окна ",Symbol()); // Сообщ. о выгрузке
   return;                                      // Выход из deinit()
  }
//--------------------------------------------------------------------

Question: why in this example GV variables Expert and New_Expert are of int type. although, as stated earlier, these variables should be of double type?

 

Good afternoon, can you tell me what might be wrong with the EA?

//+------------------------------------------------------------------+
//|                                                           iB.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

int MagicNumber = 1981;
//-----------------------------------------
extern double  Percent        = 0.8;
extern double  Lots           = 0.1;

bool Accept()
  {
   bool TradeOpen;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
        {
         if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP) TradeOpen=false;
            else TradeOpen=True;
         if (OrderType() == OP_BUY)
            {if (OrderStopLoss() < (Low[1] * Point)) 
                  OrderModify(OrderTicket(),OrderOpenPrice(),(Low[1] * Point),0,0,Green);}
         if (OrderType() == OP_SELL) 
            {if (OrderStopLoss() > (High[1] * Point)) 
                  OrderModify(OrderTicket(),OrderOpenPrice(),(High[1] * Point),0,0,Red);}
        }
     }

   return(TradeOpen);
  }
//-------------------------------------------------------------------+
int start()
  {
//----
   if (Accept())
   {
      if(High[1]<High[2] && Low[1]>Low[2])   
         if ((High[1]-Low[1])/(High[2]-Low[2])<Percent)
       {
         OrderSend(Symbol(), OP_BUYSTOP, Lots, High[1], 3, Low[2], 0, "iB", MagicNumber, 0, Green);
         OrderSend(Symbol(), OP_SELLSTOP, Lots, Low[1], 3, High[2], 0, "iB", MagicNumber, 0, Red);
       }
   }
   return(0);
  }
//+------------------------------------------------------------------+
It compiles without any problems, no errors, but it does not trade. I have tried to comment out different code blocks, but I have not found the culprit. I have not noticed any problems with logic.
 
I forgot my password on my old demo account. Where can I find it?