Sign only at candle closure

1

Code: Select all

//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Orange
#property indicator_color2 DarkGray
#property indicator_color3 Orange
#property indicator_color4 LimeGreen
#property indicator_color5 Red
#property indicator_color6 LimeGreen
#property indicator_style2 STYLE_DOT
#property indicator_style3 STYLE_DOT
#property indicator_style4 STYLE_DOT

//
//
//
//
//

extern int    RsiLength  = 9;
extern int    RsiPrice   = PRICE_CLOSE;
extern int    HalfLength = 5;
extern int    DevPeriod  = 100;
extern double Deviations = 0.8;
extern bool   UseAlert   = true;
extern bool   DrawArrows = true;

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
double Arriba[];
double Abajo[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

int init()
{
   HalfLength=MathMax(HalfLength,1);
         SetIndexBuffer(0,buffer1); 
         SetIndexBuffer(1,buffer2);
         SetIndexBuffer(2,buffer3); 
         SetIndexBuffer(3,buffer4);
         
         SetIndexBuffer(4,Arriba);
         SetIndexStyle(4,DRAW_ARROW);
         SetIndexArrow(4,234);
         SetIndexEmptyValue(4,0.0);
         SetIndexLabel(4,"Flecha Arriba");
         SetIndexBuffer(5,Abajo);
         SetIndexStyle(5,DRAW_ARROW);
         SetIndexArrow(5,233);
         SetIndexEmptyValue(5,0.0);
         SetIndexLabel(5,"Flecha Abajo");
         
         
   return(0);
}
int deinit() 
{
 /* DellObj(PrefixArrow);*/
  
 return(0); 
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int start() {




   int i,j,k,counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
           int limit=MathMin(Bars-1,Bars-counted_bars+HalfLength);

   //
   //
   //
   //
   //
   Arriba[i]=0;
   Abajo[i]=0;
   
   static datetime timeLastAlert = NULL;
   
   for (i=limit; i>=0; i--) buffer1[i] = iRSI(NULL,0,RsiLength,RsiPrice,i);
   for (i=limit; i>=0; i--)
   {
      double dev  = iStdDevOnArray(buffer1,0,DevPeriod,0,MODE_SMA,i);
      double sum  = (HalfLength+1)*buffer1[i];
      double sumw = (HalfLength+1);
      for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
      {
         sum  += k*buffer1[i+j];
         sumw += k;
         if (j<=i)
         {
            sum  += k*buffer1[i-j];
            sumw += k;
         }
      }
      buffer2[i] = sum/sumw;
      buffer3[i] = buffer2[i]+dev*Deviations;
      buffer4[i] = buffer2[i]-dev*Deviations;
  
  //Parte que envia señal    
  
      if( buffer1[i] >= buffer3[i] /*&& buffer1[i+1] < buffer3[i+1]*/ )
      { Arriba[i] = High[i] ; }
      {  /*if( DrawArrows ) ArrowDn(Time[i], High[i]);*/  }
      
      
      if( buffer1[i] <= buffer4[i] /*&& buffer1[i+1] > buffer4[i+1] */)
      { Abajo[i] = Low[i] ; }
      { /* if( DrawArrows ) ArrowUp(Time[i], Low[i]);*/}
      
      
      //Parte que envia señal    
      if( buffer1[i] >= buffer3[i] /*&& buffer1[i+1] < buffer3[i+1]*/ )
      { 
         
         
         if( UseAlert && i == 0 && Time[0] != timeLastAlert )
         {
            Alert(Symbol(),"  M",Period()," Posible Venta");
            timeLastAlert = Time[0];
         }
      }
      
      if( buffer1[i] <= buffer4[i] /*&& buffer1[i+1] > buffer4[i+1] */)
      { 
         

         if( UseAlert && i == 0 && Time[0] != timeLastAlert )
         {
            Alert(Symbol(),"  M",Period()," Posible Compra");
            timeLastAlert = Time[0];
         }         
      }
   }
   return(0);
}


could someone help me with this code, i would like the sign to only appear at the closing of the current candle
These users thanked the author Guibean for the post:
ShahreyarRafi


Re: Sign only at candle closure

2
Guibean wrote: Fri Oct 23, 2020 1:32 am

Code: Select all

//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Orange
#property indicator_color2 DarkGray
#property indicator_color3 Orange
#property indicator_color4 LimeGreen
#property indicator_color5 Red
#property indicator_color6 LimeGreen
#property indicator_style2 STYLE_DOT
#property indicator_style3 STYLE_DOT
#property indicator_style4 STYLE_DOT

//
//
//
//
//

extern int    RsiLength  = 9;
extern int    RsiPrice   = PRICE_CLOSE;
extern int    HalfLength = 5;
extern int    DevPeriod  = 100;
extern double Deviations = 0.8;
extern bool   UseAlert   = true;
extern bool   DrawArrows = true;

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
double Arriba[];
double Abajo[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

int init()
{
   HalfLength=MathMax(HalfLength,1);
         SetIndexBuffer(0,buffer1); 
         SetIndexBuffer(1,buffer2);
         SetIndexBuffer(2,buffer3); 
         SetIndexBuffer(3,buffer4);
         
         SetIndexBuffer(4,Arriba);
         SetIndexStyle(4,DRAW_ARROW);
         SetIndexArrow(4,234);
         SetIndexEmptyValue(4,0.0);
         SetIndexLabel(4,"Flecha Arriba");
         SetIndexBuffer(5,Abajo);
         SetIndexStyle(5,DRAW_ARROW);
         SetIndexArrow(5,233);
         SetIndexEmptyValue(5,0.0);
         SetIndexLabel(5,"Flecha Abajo");
         
         
   return(0);
}
int deinit() 
{
 /* DellObj(PrefixArrow);*/
  
 return(0); 
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int start() {




   int i,j,k,counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
           int limit=MathMin(Bars-1,Bars-counted_bars+HalfLength);

   //
   //
   //
   //
   //
   Arriba[i]=0;
   Abajo[i]=0;
   
   static datetime timeLastAlert = NULL;
   
   for (i=limit; i>=0; i--) buffer1[i] = iRSI(NULL,0,RsiLength,RsiPrice,i);
   for (i=limit; i>=0; i--)
   {
      double dev  = iStdDevOnArray(buffer1,0,DevPeriod,0,MODE_SMA,i);
      double sum  = (HalfLength+1)*buffer1[i];
      double sumw = (HalfLength+1);
      for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
      {
         sum  += k*buffer1[i+j];
         sumw += k;
         if (j<=i)
         {
            sum  += k*buffer1[i-j];
            sumw += k;
         }
      }
      buffer2[i] = sum/sumw;
      buffer3[i] = buffer2[i]+dev*Deviations;
      buffer4[i] = buffer2[i]-dev*Deviations;
  
  //Parte que envia señal    
  
      if( buffer1[i] >= buffer3[i] /*&& buffer1[i+1] < buffer3[i+1]*/ )
      { Arriba[i] = High[i] ; }
      {  /*if( DrawArrows ) ArrowDn(Time[i], High[i]);*/  }
      
      
      if( buffer1[i] <= buffer4[i] /*&& buffer1[i+1] > buffer4[i+1] */)
      { Abajo[i] = Low[i] ; }
      { /* if( DrawArrows ) ArrowUp(Time[i], Low[i]);*/}
      
      
      //Parte que envia señal    
      if( buffer1[i] >= buffer3[i] /*&& buffer1[i+1] < buffer3[i+1]*/ )
      { 
         
         
         if( UseAlert && i == 0 && Time[0] != timeLastAlert )
         {
            Alert(Symbol(),"  M",Period()," Posible Venta");
            timeLastAlert = Time[0];
         }
      }
      
      if( buffer1[i] <= buffer4[i] /*&& buffer1[i+1] > buffer4[i+1] */)
      { 
         

         if( UseAlert && i == 0 && Time[0] != timeLastAlert )
         {
            Alert(Symbol(),"  M",Period()," Posible Compra");
            timeLastAlert = Time[0];
         }         
      }
   }
   return(0);
}


could someone help me with this code, i would like the sign to only appear at the closing of the current candle

Code: Select all

if( buffer1[i+1] <= buffer4[i+1]

Who is online

Users browsing this forum: Abdi, felixo, friend4you, kvak, Proximic [Bot], ssscary, WhatsApp [Bot], Yandex [Bot] and 88 guests