Hi all, i think i have something fairly simple, (but not simple enough).
I want to make this Heiken ashi indicator alert at the open of the first candle (color change) instead of at the open of the next candle.
Here is some of the code. Thanks in advance. I have a feeling its pretty simple and if anyone wants it when its done I will post it up. I gotta learn some coding, thanks again.
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double haOpen, haHigh, haLow, haClose;
string sAlertMsg;
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;
haClose=(Open[pos]+High[pos]+Low[pos]+Close[pos])/4;
haHigh=MathMax(High[pos], MathMax(haOpen, haClose));
haLow=MathMin(Low[pos], MathMin(haOpen, haClose));
if (haOpen<haClose)
{
ExtMapBuffer1[pos]=haLow;
ExtMapBuffer2[pos]=haHigh;
}
else
{
ExtMapBuffer1[pos]=haHigh;
ExtMapBuffer2[pos]=haLow;
}
ExtMapBuffer3[pos]=haOpen;
ExtMapBuffer4[pos]=haClose;
pos--;
}
//sound / alert, added by sangmane
if(SoundOn) {
if(Time[0]>LastAlert) {
if(ExtMapBuffer3[1]>ExtMapBuffer4[1] && ExtMapBuffer3[2]<=ExtMapBuffer4[2]) {
LastAlert = Time[0];
//Alert(TimeToStr(Time[0],TIME_DATE|TIME_SECONDS),": DOWN");
sAlertMsg="HeikenAshi Alert - "+Symbol()+" : Signal Down";
if (Alert_Email) SendMail( sAlertMsg, "MT4 Alert!n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )+"n"+sAlertMsg);
PlaySound("Alert1.wav");
}
else if(ExtMapBuffer3[1]<ExtMapBuffer4[1] && ExtMapBuffer3[2]>=ExtMapBuffer4[2]) {
LastAlert = Time[0];
//Alert(TimeToStr(Time[0],TIME_DATE|TIME_SECONDS),": UP");
PlaySound("Alert1.wav");
sAlertMsg="HeikenAshi Alert - "+Symbol()+" : Signal Up";
if (Alert_Email) SendMail( sAlertMsg, "MT4 Alert!n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )+"n"+sAlertMsg);
I want to make this Heiken ashi indicator alert at the open of the first candle (color change) instead of at the open of the next candle.
Here is some of the code. Thanks in advance. I have a feeling its pretty simple and if anyone wants it when its done I will post it up. I gotta learn some coding, thanks again.
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double haOpen, haHigh, haLow, haClose;
string sAlertMsg;
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;
haClose=(Open[pos]+High[pos]+Low[pos]+Close[pos])/4;
haHigh=MathMax(High[pos], MathMax(haOpen, haClose));
haLow=MathMin(Low[pos], MathMin(haOpen, haClose));
if (haOpen<haClose)
{
ExtMapBuffer1[pos]=haLow;
ExtMapBuffer2[pos]=haHigh;
}
else
{
ExtMapBuffer1[pos]=haHigh;
ExtMapBuffer2[pos]=haLow;
}
ExtMapBuffer3[pos]=haOpen;
ExtMapBuffer4[pos]=haClose;
pos--;
}
//sound / alert, added by sangmane
if(SoundOn) {
if(Time[0]>LastAlert) {
if(ExtMapBuffer3[1]>ExtMapBuffer4[1] && ExtMapBuffer3[2]<=ExtMapBuffer4[2]) {
LastAlert = Time[0];
//Alert(TimeToStr(Time[0],TIME_DATE|TIME_SECONDS),": DOWN");
sAlertMsg="HeikenAshi Alert - "+Symbol()+" : Signal Down";
if (Alert_Email) SendMail( sAlertMsg, "MT4 Alert!n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )+"n"+sAlertMsg);
PlaySound("Alert1.wav");
}
else if(ExtMapBuffer3[1]<ExtMapBuffer4[1] && ExtMapBuffer3[2]>=ExtMapBuffer4[2]) {
LastAlert = Time[0];
//Alert(TimeToStr(Time[0],TIME_DATE|TIME_SECONDS),": UP");
PlaySound("Alert1.wav");
sAlertMsg="HeikenAshi Alert - "+Symbol()+" : Signal Up";
if (Alert_Email) SendMail( sAlertMsg, "MT4 Alert!n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )+"n"+sAlertMsg);