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

 
Zolotai:

It has nothing to do with the code. I just need the right condition. The question is, is there any way to know the time of the current bar? How can I find out the time of the bar at all?
Time[index_need_bar]; will return you the open time of the bar with the number "index_need_bar". You can use iTime() for other symbols and timeframes
 

How to get a signal in an EA from this indicator

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#define  SH_BUY   1
#define  SH_SELL  -1
extern int     AllBars=0;
extern int     Otstup=30;
extern double  Per=9;
int            SH,NB,i,UD;
double         R,SHMax,SHMin;
double         BufD[];
double         BufU[];

int init()
{
   if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
   IndicatorBuffers(2);
   IndicatorShortName("SHI_SilverTrendSig");
   SetIndexStyle(0,DRAW_ARROW,0,1);
   SetIndexStyle(1,DRAW_ARROW,0,1);
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,BufU);
   SetIndexBuffer(1,BufD);
   SetIndexDrawBegin(0,Bars-NB);
   SetIndexDrawBegin(1,Bars-NB);
   ArrayInitialize(BufD,0.0);
   ArrayInitialize(BufU,0.0);
   return(0);
}
int start()
{
   int CB=IndicatorCounted();
   if(CB<0) return(-1); else if(NB>Bars-CB) NB=Bars-CB;
   for (SH=1;SH<NB;SH++)
   {
      for (R=0,i=SH;i<SH+10;i++) {R+=(10+SH-i)*(High[i]-Low[i]);}      R/=55;

      SHMax = High[Highest(NULL,0,MODE_HIGH,Per,SH)];
      SHMin = Low[Lowest(NULL,0,MODE_LOW,Per,SH)];
      if (Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100 && UD!=SH_SELL) { BufU[SH]=Low[SH]-R*0.5; UD=SH_SELL; }
      if (Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100 && UD!=SH_BUY) { BufD[SH]=High[SH]+R*0.5; UD=SH_BUY; }
   }
   return(0);
}

I tried it through iCustom but it says the value is 2147483647 when specifying any line or bar numbers ...

 
VOLDEMAR:

How to get a signal in an EA from this indicator

I tried it through iCustom but it says the value is 2147483647 when specifying any line or bar numbers ...

This value is EMPTY_VALUE. It is in the indicator buffer by default, if there is no signal. Cycle through the buffer and fetch the non-empty values.
 

Check his buffers like this:

if (Bufer0>0) {               // в double Bufer0 через iCustom() ранее получено значение буфера индикатора 0
   if (Bufer0!=EMPTY_VALUE) {
      // поймали значение в буфере
      }
   }
 
artmedia70:

Check its buffers like this:


Ok I get that, but there could be a hundred values in the buffer how to find the last one and how to determine whether the last one is a buy signal or a sell signal ?
 
Got it, thanks.
 
VOLDEMAR:

Ok, I get it, but there can be hundreds of values in buffer, how to find the last one and how to determine which is the last one to buy signal or sell ?

I didn't compile the code and did not look in MT, but BufD is first blue buffer, BufU is zero red buffer. What do they show there on the screen, blue and red dots? So, see which dot of which colour points to what there. And catch them in the buffers - red in the zero buffer, blue in the first one.

Well... And values need to be caught on the first bar most likely, didn't see it redrawing or not. Or maybe a loop is needed from the zero bar until the value is encountered. It all depends on how it gives out its signals...

 
Hi, can you tell me why I can't configure any EA in Mt4, all of them show negative values when testing the strategy!
 
serjlarkin:
Hi, can you tell me why I can't set any of the Expert Advisors in Mt4, all of them show negative values when I test the strategy!
What negative value?
 

Hello!

Need some help! Is it possible to create an indicator of the following nature: - counting ticks according to this principle https://www.mql5.com/ru/code/9915 - this is already half of the indicator .... But to refine as follows and depict it graphically with the following parameters:


Help, for whom it is a piece of cake)

Reason: