[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RESTRICTING ALERTS ON DAILY CHARTS



PureBytes Links

Trading Reference Links

I have a problem with restricting alerts on live charts.

I'm currently working with the following function / indicator:

FIRSTTRADEDAY-FUNCTION
if upticks + downticks < 595000 then FirstTradeDay=0 else
FirstTradeDay=1;




CROSS-INDICATOR

Inputs: c1(close of data1);
Variable: counter(0),Avg1(0),Avg2(0);

Avg1=waverage(c1,10);
Avg2=waverage(c1,30);


print("COUNTERCHECK1 ",counter,"  FIRSTTRADEDATE  : ",FirstTradeDay,"
UPDOWN  : ",upticks+downticks,"  TIME : ",currenttime);

if FirstTradeDay=0 then begin
	counter = 0;
	print("COUNTERCHECK2  ",counter);
end;


if counter = 0 then begin	
	print("COUNTERCHECK3  : ",counter);
	if Avg1 crosses over Avg2 then begin
			counter=counter+1;
			Alert("BUY");
		
			print("COUNTERCHECK4  : ",counter);
			end;
end;


plot1(avg1);
plot2(avg2);



What I'm trying to do should be very simple: I want to get an alert
notification after the first occurance of the given condition (avg
crosses avg). Afterwards I don't want to be informed anymore, until it
the condition happens again. With other words: I'm not interested in
receiving more than one alert notification per day.

Therefore I have the Function "FirstTradeDay" (The condition "if upticks
+ downticks < 595000"  is only to test it intraday. Normally it is set
to > 1) In conjunction with the corresponding if-statemant in the
Indicator :

if FirstTradeDay=0 then begin
	counter = 0;
	print("COUNTERCHECK2  ",counter);
end;

the variable counter should be reset every day.

If an avg. crossover occurs the value of counter is increased by one and
no other alert should be triggered that day. Unfortunately counter is
being reset after every new trade (see copy of the debug window).



1)	COUNTERCHECK1       0.00  FIRSTCOUNTERCHECK  :       0.00
UPDOWN  : 593786.00  TIME   :   1336.00
	COUNTERCHECK2       0.00
	COUNTERCHECK3       0.00
	COUNTERCHECK4      1.00

With 1) everything is fine.

2)	COUNTERCHECK1       0.00  FIRSTCOUNTERCHECK  :       0.00
UPDOWN  : 594786.00  TIME   :   1337.00
	COUNTERCHECK2       0.00
	COUNTERCHECK3       0.00
	COUNTERCHECK4       1.00

Why is counter being reset to 0 ? The way I see it the variable should
be 1, and should be reset to 0 with countercheck2, because up+downticks
is below 595000.

3)	COUNTERCHECK1       0.00  FIRSTCOUNTERCHECK  :       1.00
UPDOWN  : 595026.00  TIME   :   1338.00
	COUNTERCHECK3       0.00
	COUNTERCHECK4       1.00

Same problem here. Counter is being reset at the beginning. 
I do not get the info on CounterCheck2 because the condition
up+downticks > 595000 is true.



I really don't what I am doing wrong. I would be glad if anybody could
help me.

Tks a lot in advance

Sven Hedrich