This is my entire code: the custom indicator in Ichimoku with 2 chiku and the when the 2 chiku is collision the alarm and sound should showed.
in all system everything worked correctly, But in one of the the Alert and sound not show.
What causes the alert window and sound playback in Metatrader 4 to stop working?
please help.
#property strict #property indicator_width1 5 #property indicator_width2 5 #property indicator_width3 2 #property indicator_width4 2 #property indicator_width7 2 #property indicator_width8 2 input int Tenkan=9; input int Kijun=26; input int SenkuB=52; input int Chiku1Shift=-26; // Chiku 1 Shift input int Chiku2Shift=78; //Chiku 2 Shift input int KomuShift=26; input string alertFileName = "alert.wav"; //--- indicator buffers double KumoUpColorBuffer[]; double KumoDownColorBuffer[]; double TenkanBuffer[]; double kijunBuffer[]; double ChikuBuffer[]; double Chiku2Buffer[]; double SenkuABuffer[]; double SenkuBBuffer[]; int LastBar, currentBar; int crossCandleCheck; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,KumoUpColorBuffer); SetIndexBuffer(1,KumoDownColorBuffer); SetIndexBuffer(2,TenkanBuffer); SetIndexBuffer(3,kijunBuffer); SetIndexBuffer(4,ChikuBuffer); SetIndexBuffer(5,Chiku2Buffer); SetIndexBuffer(6,SenkuABuffer); SetIndexBuffer(7,SenkuBBuffer); ArraySetAsSeries(KumoUpColorBuffer,true); ArraySetAsSeries(KumoDownColorBuffer,true); ArraySetAsSeries(TenkanBuffer,true); ArraySetAsSeries(kijunBuffer,true); ArraySetAsSeries(ChikuBuffer,true); ArraySetAsSeries(Chiku2Buffer,true); ArraySetAsSeries(SenkuABuffer,true); ArraySetAsSeries(SenkuBBuffer,true); SetIndexShift(0, KomuShift); SetIndexShift(1, KomuShift); SetIndexShift(4, Chiku1Shift); SetIndexShift(5, Chiku2Shift); SetIndexShift(6, KomuShift); SetIndexShift(7, KomuShift); LastBar = Bars(_Symbol,PERIOD_CURRENT); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- currentBar = Bars(_Symbol,PERIOD_CURRENT); ArraySetAsSeries(low,true); ArraySetAsSeries(high,true); ArraySetAsSeries(close,true); double highest,lowest,T,K; int bars = rates_total-1; if(prev_calculated>0) {bars=rates_total-(prev_calculated-1);} for(int i=bars; i>=0; i--) { ///////////////////// tenkun highest = high[ArrayMaximum(high,Tenkan,i)]; lowest = low[ArrayMinimum(low,Tenkan,i)]; T = (highest + lowest)/2; TenkanBuffer[i] = T; ///////////////////// kijun highest = high[ArrayMaximum(high,Kijun,i)]; lowest = low[ArrayMinimum(low,Kijun,i)]; K = (highest + lowest)/2; kijunBuffer[i] = K; //////////// senkuA ,senku kum2 and greenkumo highest = high[ArrayMaximum(high,Tenkan,i)]; lowest = low[ArrayMinimum(low,Tenkan,i)]; T = (highest + lowest)/2; SenkuABuffer[i] = (T + K)/2; KumoUpColorBuffer[i]= SenkuABuffer[i]; ///////////////////// senkuB and redkumo and senku B kumo 2 highest = high[ArrayMaximum(high,SenkuB,i)]; lowest = low[ArrayMinimum(low,SenkuB,i)]; SenkuBBuffer[i] = (highest+lowest)/2; KumoDownColorBuffer[i]= SenkuBBuffer[i]; // chiku ChikuBuffer[i] = close[i]; Chiku2Buffer[i] = close[i]; } if(currentBar != LastBar) { if(Chiku1Shift > Chiku2Shift) { crossCandleCheck = Chiku1Shift - Chiku2Shift ; if(ChikuBuffer[crossCandleCheck ] > Chiku2Buffer[1] && ChikuBuffer[crossCandleCheck + 1] < Chiku2Buffer[2]) { Alert("A collision occurred ||||||||||||||||||||||||||||"); PlaySound(alertFileName); } else if(ChikuBuffer[crossCandleCheck] < Chiku2Buffer[1] && ChikuBuffer[crossCandleCheck + 1] > Chiku2Buffer[2]) { Alert("A collision occurred ||||||||||||||||||||||||||||"); PlaySound(alertFileName); } } else if(Chiku1Shift < Chiku2Shift) { crossCandleCheck = Chiku2Shift - Chiku1Shift; if(ChikuBuffer[1] > Chiku2Buffer[crossCandleCheck] && ChikuBuffer[2] < Chiku2Buffer[crossCandleCheck+1]) { Alert("A collision occurred ||||||||||||||||||||||||||||"); PlaySound(alertFileName); } else if(ChikuBuffer[0] < Chiku2Buffer[crossCandleCheck] && ChikuBuffer[ 2] > Chiku2Buffer[crossCandleCheck+1]) { Alert("A collision occurred ||||||||||||||||||||||||||||"); PlaySound(alertFileName); } } else { if(ChikuBuffer[1] > Chiku2Buffer[1] && ChikuBuffer[2] < Chiku2Buffer[2]) { Alert("A collision occurred ||||||||||||||||||||||||||||"); PlaySound(alertFileName); } else if(ChikuBuffer[1] < Chiku2Buffer[1] && ChikuBuffer[2] > Chiku2Buffer[2]) { Alert("A collision occurred ||||||||||||||||||||||||||||"); PlaySound(alertFileName); } } LastBar = currentBar; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
This is my entire code: the custom indicator in Ichimoku with 2 chiku and the when the 2 chiku is collision the alarm and sound should showed.
in all system everything worked correctly, But in one of the the Alert and sound not show.
What causes the alert window and sound playback in Metatrader 4 to stop working?
please help.
If it works correctly except for on one system, then it's not your MetaTrader code. It's a setting somewhere, or something is blocking it, on the system.
If it works correctly except for on one system, then it's not your MetaTrader code. It's a setting somewhere, or something is blocking it, on the system.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi I create Custom Indicator for meta trader 4. In this Indicator Users should get the text alert in alert window and the alert sound should play too in special situation . ،his is worked perfectly in my and some of my friend system, both in live market and the simulation. but in one of the system the alert window not showed and the sound not play too. why this happened? What causes the alert window and sound playback in Metatrader 4 to stop working?
please help.