Alternate Candle

To add comments, please log in or register
Masternook
18
Masternook  
I'm trying to make the indicator send a signal when it arrives on the 8 alternating candle, does anyone know where the error is in the code.
Then I would like to place when I get to the 8 candle alternating a graphic sign below or a square like in the photo to be able to analyze past graphics, I am not asking to do for me but to give a light or an example of how I can do this and please help me to find the error in that code.

I'm going to post a print of a marker I found with alternating candles.

Indicador Gráfico chandle changeError Image
#property link      ""





#property indicator_chart_window

extern string TimeFrameNote="0-CurrentTimeframe, 1-1MIN, 5-5MIN, 15-15MIN, 30-30MIN, 60-1H, 240-4H, 1440-D1, 10080-W1, 43200-MN1";
extern int  TimeFrame = 0;
extern bool Alerts_ON = true;
extern string SoundWAV = "woody2.wav";

int 
   ChangeCandle = 0;


datetime LastAlarmTime;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() 
  {
   LastAlarmTime = iTime(Symbol(),TimeFrame,0);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit() 
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   int counter;
   string TimeFrameStr; 
//----
   switch(TimeFrame)
     {
      case 0 : TimeFrameStr="Period "+Period(); break;
      case 1 : TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
     }   
   RefreshRates();
  // int secondsleft = Time[0]+Period()*60-TimeCurrent();
  // int SecondsElaps = TimeCurrent()-Time[0];

   if( LastAlarmTime < Time[0] && Alerts_ON && ChangeColorOk() != "" ){
    Alert( ChangeColorOk() + " " + Symbol() + " " + TimeFrameStr );
    PlaySound(SoundWAV);
    LastAlarmTime = iTime(Symbol(),TimeFrame,0);
   }  
   return(0);
  }
//+------------------------------------------------------------------+
string ChangeColorOk(){
 string str="";
   if( iClose(Symbol(),PERIOD_CURRENT,1)< iOpen(Symbol(),PERIOD_CURRENT,1) && 
       iClose(Symbol(),PERIOD_CURRENT,2)> iOpen(Symbol(),PERIOD_CURRENT,2 )||
       iClose(Symbol(),PERIOD_CURRENT,1)> iOpen(Symbol(),PERIOD_CURRENT,1) && 
       iClose(Symbol(),PERIOD_CURRENT,2)< iOpen(Symbol(),PERIOD_CURRENT,2 ) ){
    
    ChangeCandle++;}
    else{
    ChangeCandle = 0;}
    if (ChangeCandle = 8){
    str = "8 Candles";   
   }    
       
   
 return str;     
}


To add comments, please log in or register