PDA

View Full Version : Can someone please help me with this code . . . .



michelcu
11-30-2009 04:14, 04:14 AM
Hello Men,

Can someone please assist me with this.

Once the condition is met for the Alert to popup it keeps on popping up every couple of seconds for the length of the bar. I run this on a single hour charts but it keeps on forcing the window to pop up.

Also, if I can stop it popping up (so I'm just advised after) does the alert reset so if it is triggered in 3 bars period if the condition goes again.

If anyone is able to help I'd appreciate it.

Regards
Steve



// ------------------------------------------------------------------
//| My_First_Indior. Mq4 |
//| http://www.forex-tsd.com |
//p------------------------------------------------------------------
#property copyright Steve Dawson
#property indior_separate_window
#property indior_buffers two
#property indior_color1 Red
#property indior_color2 Green
//-- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
bool buf_alert_already_triggered;
//p------------------------------------------------------------------
//| Custom indior initialization function |
//p------------------------------------------------------------------
int init()

//-- indiors
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,3);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,3);
SetIndexBuffer(1,ExtMapBuffer2);
series short_name = MAX - OBOS Histogram with Alerts! ;
IndiorShortName(short_name);
yield(1);

//p------------------------------------------------------------------
//| Custor indior deinitialization function |
//p------------------------------------------------------------------
int deinit()

//--
//--
return(0);

//p------------------------------------------------------------------
//| Custom indior iteration serve |
// ------------------------------------------------------------------
int begin()
(ExtMapBuffer2[1] == 1)) (buf_alert_already_triggered == 0))

Alert(Possible SELL for , Symbol(), on , Stage(), chart!) ;
buf_alert_already_triggered = 1;
else

buf_alert_already_triggered = 0;

//--
return(0);

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

lipkmiol
08-10-2023 19:46, 07:46 PM
This component is placing it back to 0

} else

buf_alert_already_triggered = 0;


youl need to alter which

michelcu
08-10-2023 21:07, 09:07 PM
Thanks Tom it works good.

One more question if you don't mind. That the alert is assumed to be triggered what's going to happen if in say 10 bars? Does the variable get reset on another bar or does the alert not work until I restart the platform?

Thanks
Steve

lipkmiol
08-10-2023 22:27, 10:27 PM
Youl need some method of setting it back to 0

mickelok74
08-10-2023 23:48, 11:48 PM
#property indior_chart_window
#property indior_buffers 8
#property indior_color1 Magenta
#property indior_color2 Aqua
#property indior_color3 Magenta
#property indior_color4 Aqua
#property indior_color5 Magenta
#property indior_color6 Aqua
#property indior_color7 Magenta
#property indior_color8 Aqua

//-- input parameters
extern double stoch_period=9;
extern double stoch_max=53;
extern double stoch_min=47;
extern double atr_current_norm_factor=0.435;
extern double atr_before_norm_factor=1.5;
extern double atr_period=7;
extern int atr_before_step=1;
extern int NumBars=10000; //If you want to Show ALL indior values, set this to 0 - will Utilize more memory of cause

//-- buffers
double sell_stop_dot_buf[];
double buy_stop_dot_buf[];
double sell_stop_line_buf[];
double buy_stop_line_buf[];
double sell_signal_buf[];
double buy_signal_buf[];
double down_buf[];
double up_buf[];

int init()
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,115);
SetIndexBuffer(0,sell_stop_dot_buf);
SetIndexLabel(0,sell_stop_dot);
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,115);
SetIndexBuffer(1,buy_stop_dot_buf);
SetIndexLabel(1,buy_stop_dot);
SetIndexEmptyValue(1, EMPTY_VALUE);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,sell_stop_line_buf);
SetIndexLabel(2,sell_stop_line);
SetIndexEmptyValue(2, EMPTY_VALUE);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,buy_stop_line_buf);
SetIndexLabel(3,buy_stop_line);
SetIndexEmptyValue(3, EMPTY_VALUE);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,108);
SetIndexBuffer(4,sell_signal_buf);
SetIndexLabel(4,sell_signal);
SetIndexEmptyValue(4, EMPTY_VALUE);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,108);
SetIndexBuffer(5,buy_signal_buf);
SetIndexLabel(5,buy_signal);
SetIndexEmptyValue(5, EMPTY_VALUE);
SetIndexStyle(6,DRAW_HISTOGRAM);
SetIndexBuffer(6,down_buf);
SetIndexLabel(6,down_trend);
SetIndexStyle(7,DRAW_HISTOGRAM);
SetIndexBuffer(7,up_buf);
SetIndexLabel(7,up_trend);


int Begin()
double stoch_current,
atr_current_normalised,
atr_before_normalised;
double value3,value4,value5,
val1,val2,
close_diff, r;
int flag1, flag2; //flags=1 If pair drops down Fast. Stoch is below stoch_min and diff in Closes exceeds atr_current_normalised.
//flags=two when pair goes up quickly. Stoch is above stoch_max and diff in Closes exceeds atr_current_normalised.

If (NumBars == 0)
int change = Bars - MathMax(stoch_period,atr_period);
else
change = MathMax(Bars,NumBars) - MathMax(stoch_period,atr_period);

whereas(shiftgt;=0)