MetaTrader 5 herunterladen

Help me fixing an alert

Einloggen oder registrieren, um einen Kommentar zu schreiben
paul.doberan
23
paul.doberan  

I am trying to include an alert into an inside bar indicator but I can't get it to work. It gives me an alert for every new candle instead of only for inside bars.

I was hoping you could provide some help.

input int    TriggerCandle 	= 1;
input bool   EnableNativeAlerts = true;
input bool   EnableSoundAlerts  = true;
input bool   EnableEmailAlerts  = true;
input string AlertEmailSubject  = "";
input string AlertText  	= "";
input string SoundFileName	= "alert.wav";
 
datetime LastAlertTime = D'01.01.1970';


//At the end of the onCalculate function

if ((TriggerCandle > 0) && (Time[0] > LastAlertTime))
{
	string Text;
	
	if (HighBuff[TriggerCandle] > 0)
	{
		Text = AlertText + "Inside Bar: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period());
		if (EnableNativeAlerts) Alert(Text);
		if (EnableEmailAlerts) SendMail(AlertEmailSubject + "Inside Bar", Text);
		if (EnableSoundAlerts) PlaySound(SoundFileName);
		LastAlertTime = Time[0];
	}

}

This is the code I was using.


The indicator I am using is from Tecciztecatl's inside bar indicator.

https://www.mql5.com/en/code/16533


I hope someone can help

Best,

Paul

Inside Bar
Inside Bar
  • Stimmen: 13
  • 2016.10.13
  • Taras Slobodyanik
  • www.mql5.com
The indicator determines the inside bar and marks its High/Low. It is plotted based on the closed candles (does not redraw). The identified inside bar can be displayed on smaller periods. You may set a higher period (to search for the inside bar) and analyze on a smaller one.
Carl Schreiber
Moderator
7847
Carl Schreiber  
  1. "... but I can't get it to work" is a bit to less to help you. What does not work: Alert, SendMail or Sound? Is there an entry in the 2 logs?
  2. Have you gone through you indicator wit the debugger - but make sure it is not running anywhere else while you debug!
  3. Can it be that you never reached the  if(( TriggerCandle > 0 ... ?
paul.doberan
23
paul.doberan  
Carl Schreiber:
  1. "... but I can't get it to work" is a bit to less to help you. What does not work: Alert, SendMail or Sound? Is there an entry in the 2 logs?
  2. Have you gone through you indicator wit the debugger - but make sure it is not running anywhere else while you debug!
  3. Can it be that you never reached the  if(( TriggerCandle > 0 ... ?

Thank you for the answer.

I do get an alert, (which is what I am focusing on right now). There are also no errors in the compiler. 

However, what I want to achieve:

Get an alert for every new inside bar.

What I get:

An alert for every new bar that is starting.

What I assume is that since a new bar always starts as an inside bar this prompts the alert. What I don't get is that I am using HighBuffer[1] so it should focus only on the second candle not the current.

Also it could be that the Buffer is drawn to a candle while it is in the current state. However, since I am using HighBuffer[1] not HighBuffer[0] I don't see why this should matter. 

It could be another problem I don't see, because I'm not so familiar with programming.

As I understand the code, a candle that is not an inside bar gets a value of EMPTY_VALUE and the test >0 should not execute the if statement (alert).

Carl Schreiber
Moderator
7847
Carl Schreiber  

google mal nach: "mt5 inside bar pattern" - ich wieder hole mich, warum das Rad neu erfinden, wenn es bereits verschenkt wird?

paul.doberan
23
paul.doberan  
Carl Schreiber:

google mal nach: "mt5 inside bar pattern" - ich wieder hole mich, warum das Rad neu erfinden, wenn es bereits verschenkt wird?


Danke,

Nach weiterer suche habe ich den hier gefunden: http://www.pointzero-trading.com/Products/view/PZInsideBars

Funktioniert mit alert sehr gut, falls noch jemand sucht. 

Download Free Indicators and Expert Advisors (EA) for Metatrader (MT4/MT5)
Download Free Indicators and Expert Advisors (EA) for Metatrader (MT4/MT5)
  • www.pointzero-trading.com
Download free indicators, expert advisors and scripts for the Metatrader Trading Platform (MT4/MT5)
Einloggen oder registrieren, um einen Kommentar zu schreiben