[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 34

 

Hello!

Can you please tell me if a trend line is programmatically drawn on a chart, is it possible to read its value at the desired point (again, programmatically)?

 
demlin:

Hello!

Can you please tell me if a trend line is programmatically drawn on a chart, is it possible to read its value at the desired point (again, programmatically)?

Some time ago I wrote an article where the trend line was used to find the right point on the chart. Take a look, maybe you'll find something for yourself... :)
 
demlin:

Hello!

Can you please tell me if a trend line is programmatically drawn on a chart, is it possible to read its value at the desired point (again, programmatically)?


It seems to be impossible, but if I really want to, I suppose I can...:-Р
 
Roman.:

They don't seem to be able to, but if you really want to, you can...:-Р

I'd like that very much :)

I wanted to make an indicator, but as I'm dealing with indicators for the first time, I got lost. The lines are drawn as they should be, but I cannot find the way to squeeze in the array with values. In the end, I haven't got anywhere.

 
artmedia70:
I wrote an article once where I used the trend line to find the right point on the chart. Have a look, maybe you'll find something for yourself... :)
Thanks, I've got the straight line function there, I'll twist it a bit
 

With MoveFileA all went well. Thank you very much, TheXpert!

 
demlin:

I'd like that very much :)

I wanted to make an indicator, but as I'm dealing with indicators for the first time, I got lost. The lines are drawn as they should be, but I cannot find the way to squeeze in the array with values. As a result, I didn't manage to squeeze it in.

But if you had shown the code and told me what you want, you might have done without the straight line equation... It's an indicator and all the necessary data are in its buffers... Although ... :)
 
I think I have an idea... If you have a trendline constructed, then, using the straight line equation function, run in the loop from the value of its start point to the value of its end point and at each bar enter the values returned by the straight line equation function into another indicator array created for this purpose. Then, using the number of the needed bar, take these values from the array. It goes something like this...
 
artmedia70:
If you'd show me the code and tell me what you want, you'd probably won't need straight line equation... It's an indicator and all the necessary data are in its buffers ... Although ... :)

Here's the code, copied from the tutorial from the same site :)

#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window

extern int History=21;        // Колич.баров в расчётной истории
extern int M= 3;           // начальный бар с которого начинаем поиск фракталов в цикле.
int    i,k;                // номера баров в циклах.
int    Vnf3,Vnf2,Vnf1;     // номера реперных фракталов (1-ый справа на графике на нисходящем тренде).
int    VnfL3,VnfL2,VnfL1;  // номера реперных фракталов (1-ый справа на графике на восходящем тренде).
int    VFN,VFNL;           // счетчик найденных фракталов.
int    Md,MdL;             // счетчики кол-ва модификаций

double VMF1,VMF2;     // промежуточные значения верхних фракталов на нисходящем тренде.
double VMFL1,VMFL2;  // промежуточные значения нижних фракталов на восходящем тренде.
double VlFl_L;             // Min значение ближайшего нижнего фрактала на тренде вниз
double VlFl_H;             // Max значение ближайшего верхнего фрактала на тренде вверх
datetime tim1_L;           // Время ближайшего нижнего фрактала после нисходящего тренда 
datetime timL1_H;          // Время ближайшего верхнего фрактала после восходящего тренда 

datetime tim1,tim2,tim3;   // время для построения линий вилки Чувашова.
datetime timL1,timL2,timL3;// время для построения линий вилки Чувашова.

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   for (i=3;i<=History;i++)
    {//цикл
    if(High[i]>High[i+1] &&High[i]>High[i-1]&&High[i]>Close[i-2])
     {//фрактал
      VFN++;           // счетчик найденного фрактала.
      // ------------------------------------------------------------+
      if(VFN==1)       // если 1-ый фрактал найден, запоминаем значения: Max[i], № свечи[i], время[i]:
        {// f1
           Vnf1=i;        // запоминаем номер Max бара найденного фрактала.
           VMF1=High[i];  // запоминаем Max значение 1-ого найденного фрактала.
           tim1=iTime(NULL,0,i);        // запоминаем время 1-ой опорной точки.
         }//-f1
    // --------------------------------------------------------------+
    if(VFN==2)        // если 2-ый фрактал найден, запоминаем значения: Max[i], № свечи[i], время[i]:
      {// f2
          VMF2=High[i];    // запоминаем Max значение 2-ого найденного фрактала.
          if(VMF2>VMF1)    // если Max значение 2-го фрактала больше 1-го (т.е. направлена вниз),
            {
              Vnf2=i;      // запоминаем номер Max бара найденного фрактала.
              tim2=iTime(NULL,0,i);      // запомним время 2-ой опорной точки.
            }
            else VFN=VFN-1;
       }//-f2
    // --------------------------------------------------------------+

// ------------------------------------------------------------------+
   if(VFN==2) break; // найдены все 2 фрактала, выходим из цикла.
// ------------------------------------------------------------------+ 
    }//-фрактал                      
   }//-цикл 
//----

for (i=3;i<=History;i++)
    {//цикл
    if(Low[i]<Low[i+1] &&Low[i]<Low[i-1]&&Low[i]<Close[i-2])
     {//фрактал
      VFNL++;           // счетчик найденного фрактала.
      // ------------------------------------------------------------+
      if(VFNL==1)       // если 1-ый фрактал найден, запоминаем значения: Max[i], № свечи[i], время[i]:
        {// f1
           VnfL1=i;        // запоминаем номер Max бара найденного фрактала.
           VMFL1=Low[i];  // запоминаем Max значение 1-ого найденного фрактала.
           //Comment("VMFL1=",VMFL1);
           timL1=iTime(NULL,0,i);        // запоминаем время 1-ой опорной точки.
         }//-f1
    // --------------------------------------------------------------+
    if(VFNL==2)        // если 2-ый фрактал найден, запоминаем значения: Max[i], № свечи[i], время[i]:
      {// f2
          VMFL2=Low[i];    // запоминаем Max значение 2-ого найденного фрактала.
          if(VMFL2<VMFL1)    // если Max значение 2-го фрактала больше 1-го (т.е. направлена вниз),
            {
              VnfL2=i;      // запоминаем номер Max бара найденного фрактала.
              timL2=iTime(NULL,0,i);      // запомним время 2-ой опорной точки.
            }
            else VFNL=VFNL-1;
       }//-f2
    // --------------------------------------------------------------+

// ------------------------------------------------------------------+
   if(VFN==2) break; // найдены все 2 фрактала, выходим из цикла.
// ------------------------------------------------------------------+ 
    }//-фрактал                      
   }//-цикл 


DelLine();DelLineH();CreateLine();CreateLineH();
   return(0);
  }
//+------------------------------------------------------------------+

void DelLine()        // Удаление трендовых линий Sell и значков для вилки Чувашова 
   {
   ObjectDelete("Tr_down1");
  // ObjectDelete("Tr_down2");
  // ObjectDelete("Frak_1");
   //ObjectDelete("Frak_2");
   //ObjectDelete("Frak_3");
   }

void DelLineH()        // Удаление трендовых линий BUY и значков для вилки Чувашова 
   {
   ObjectDelete("Tr_up1");
   //ObjectDelete("Tr_up2");
   //ObjectDelete("Fr_1");
   //ObjectDelete("Fr_2");
   //ObjectDelete("Fr_3");
   }
void CreateLine()       // Создание и отрисовка трендовых линий Sell линий вилки Чувашова 
   {
   ObjectCreate("Tr_down1",OBJ_TREND,0,tim2,VMF2,tim1,VMF1);
   ObjectSet("Tr_down1",OBJPROP_COLOR,Red);
   ObjectSet("Tr_down1",OBJPROP_WIDTH,1);  // тонкой линией и 
   ObjectSet("Tr_down1",OBJPROP_STYLE,STYLE_SOLID);// пунктиром
   //ObjectCreate("Tr_down2",OBJ_TREND,0,tim2,VMF2,tim1,VMF1);
   //ObjectSet("Tr_down2",OBJPROP_COLOR,Aqua);
  // ObjectSet("Tr_down2",OBJPROP_WIDTH,1);  // тонкой линией и 
  // ObjectSet("Tr_down2",OBJPROP_STYLE,STYLE_DOT);// пунктиром 
   }
  
   void CreateLineH()       // Создание и отрисовка трендовых линий BUY линий вилки Чувашова 
   {
   ObjectCreate("Tr_up1",OBJ_TREND,0,timL2,VMFL2,timL1,VMFL1);
   ObjectSet("Tr_up1",OBJPROP_COLOR,Green);
   ObjectSet("Tr_up1",OBJPROP_WIDTH,1);  // тонкой линией и 
   ObjectSet("Tr_up1",OBJPROP_STYLE,STYLE_SOLID);// пунктиром
   //ObjectCreate("Tr_up2",OBJ_TREND,0,timL2,VMFL2,timL1,VMFL1);
   //ObjectSet("Tr_up2",OBJPROP_COLOR,Aqua);
   //ObjectSet("Tr_up2",OBJPROP_WIDTH,1);  // тонкой линией и 
  // ObjectSet("Tr_up2",OBJPROP_STYLE,STYLE_DOT);// пунктиром 
   }

I want to get two lines and read their values on any bars via iCustom

 

Dear forum members, help!

I need an indicator with the following requirements: 1) Intersection of two MAs (you can choose type of MA, period of MA, what MA is applied to, as well as shift).

2) The indicator draws an arrow at the intersection point.

3) At the moment of crossing, there will be a beep and an e-mail message.

4) The signal is produced only once. At the moment of crossing the MA.

There are two indicators: MA_Shift_Crossover_Alert.mq4 and 2MA CrossoverWithPrice_fixed.ex4

The first one doesn't like that the signal is given at every candlestick and after crossing the MA. The second one does not manage to set the MA shift.

Is there some way to add the possibility to shift MA to the second indicator?

The indicators are attached in the archive.

Thank you.

Files:
Reason: