[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 287

 

Here's the problem... Indicator buffers only work in indicators. you won't get anything by simply moving the code around, use standard and custom indicator calls in your script code. Technical indicators will help you

 
FAQ:

Here's the problem... Indicator buffers only work in indicators. you won't get anything by simply moving the code around, use standard and custom indicator calls in your script code. Technical indicators will help you

Ahhhh!!! thanks!!!

Question how to calculate the moment when these two crossed for the last time?
 
GarKain:
Ahhh!!! Thank you!!!

Question, how do you calculate the last time these two crossed paths?

There you go.

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

extern int ExtRVIPeriod=10;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
 double RVI_1 = iCustom( NULL,0,"Relativ Vigor Index",ExtRVIPeriod,0,1);
 double RVI_2 = iCustom( NULL,0,"Relativ Vigor Index",ExtRVIPeriod,0,2);
 double RVIS_1= iCustom( NULL,0,"Relativ Vigor Index",ExtRVIPeriod,1,1);
 double RVIS_2= iCustom( NULL,0,"Relativ Vigor Index",ExtRVIPeriod,1,2);
 
 Comment("\n","\n"," RVI:  1 Бар = ",RVI_1,
              "\n"," RVI:  2 Бар = ",RVI_2,
              "\n"," RVIS: 1 Бар = ",RVIS_1,
              "\n"," RVIS: 2 Бар = ",RVIS_2); 
              
   if(RVI_2<RVIS_2&&RVI_1>RVIS_1)    //Biu 
       SetArrow(241,Blue,"Biu"+Time[0],Time[0],Low[0],0);
       
   if(RVI_2>RVIS_2&&RVI_1<RVIS_1)    //Sell
       SetArrow(242,Red,"Sell"+Time[0],Time[0],High[0],0);       
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 12.10.2007                                                     |
//|  Описание : Установка значка на графике, объект OBJ_ARROW.                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    cd - код значка                                                         |
//|    cl - цвет значка                                                        |
//|    nm - наименование               ("" - время открытия текущего бара)     |
//|    t1 - время открытия бара        (0  - текущий бар)                      |
//|    p1 - ценовой уровень            (0  - Bid)                              |
//|    sz - размер значка              (0  - по умолчанию)                     |
//+----------------------------------------------------------------------------+
void SetArrow(int cd, color cl,
              string nm="", datetime t1=0, double p1=0, int sz=0) {
  if (nm=="") nm=DoubleToStr(Time[0], 0);
  if (t1<=0) t1=Time[0];
  if (p1<=0) p1=Bid;
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_ARROW, 0, 0,0);
  ObjectSet(nm, OBJPROP_TIME1    , t1);
  ObjectSet(nm, OBJPROP_PRICE1   , p1);
  ObjectSet(nm, OBJPROP_ARROWCODE, cd);
  ObjectSet(nm, OBJPROP_COLOR    , cl);
  ObjectSet(nm, OBJPROP_WIDTH    , sz);
}
 

Good day!

Gentle traders, in one of the forum posts I saw an interesting "indicator".

If I'm not mistaken, the background of the 5th chart shows silhouettes of hourly candlesticks. That is, it was clearly visible how the price changed over the course of an hour.

Please, do not hesitate to download(igrok081@mail.ru) or suggest where to download, or at least even the name.

Thanks in advance .

Alexander.

 
r772ra:

There you go.

*shamefully* I didn't understand any of the code. But, pardon my fastidiousness, I wanted to know how to calculate the moment when these two crossed each other AT THE LAST SINGLE TIME? Maybe the code is correct and it starts counting only after it was run. if so, how can we make it check when it was before running the script?


How can I do it myself?



I understand a little but still want to know. how can I make it check if it was before the script was started and what the price was at that point.

 
GarKain:


explain to a dummy where the brew is. how do I do it myself?


Read here:

https://book.mql4.com/ru/samples/indicators

And here:

https://book.mql4.com/ru/samples/shared

 
Thanks for the info.

the question remains. how can we make it check when these lines have been crossed recently? and what was the price at that moment.


Basically what I want to achieve:

I need the script to find the last crossing on the chart and subtract the price at the time of the crossing from the current price.

tell me how it can be implemented.
 
Isn't it possible? If I knew what to look for I would have found it a long time ago.
 

find out which bar was crossed and then find the time of the bar = crossing time

you can calculate the exact price of the crossing, but you cannot find out what the price of the instrument was, the best you can do is to know the bar number, and therefore its hight low open close

 
FAQ:

find out which bar was crossed and then find the time of the bar = crossing time

you can calculate the exact price of the crossing, but you cannot find out what the price of the instrument was, the best you can do is to know the bar number, and therefore its hight low open close

exactly i need the number of the bar which was the last crossing. how do i know it?
Reason: