your code line "if maxhigh>maxHighday then" remains true, because you do not update the value stored in maxHighday whenever maxhigh is greater than that.
You are correctly updating the value stored in maxhigh whenever high>maxhigh, but you might have missed doing the same for maxHighday when maxhigh>maxHighday.
Adding maxHighday = maxhigh; directly in the line above plot1("high"); should ensure the alert is only fired when there is a new high, but the plot1 would also only appear in this situation.
Regards,
ABCTG
The following user says Thank You to ABCTG for this post:
Yes, the alert was output each time the day's high was greater than the previous day's high and the intraday high was updated.
However, I would like the alert to go off only once when the day's high becomes greater than the previous day's high.
Therefore, I do not want an alert to be sounded each time the intraday high is subsequently renewed.
your code line "if maxhigh>maxHighday then" remains true, because you do not update the value stored in maxHighday whenever maxhigh is greater than that.
You are correctly updating the value stored in maxhigh whenever high>maxhigh, but you might have missed doing the same for maxHighday when maxhigh>maxHighday.
Adding maxHighday = maxhigh; directly in the line above plot1("high"); should ensure the alert is only fired when there is a new high, but the plot1 would also only appear in this situation.
Regards,
ABCTG
The code here is for an indicator that sets the day resolution and sounds an alert only once when the day's high is greater than the previous day's high.
variables:high_1(0),higf_2(0);
high_1=high;
higf_2=high[1];
if high_1>higf_2 then begin
plot1(open,"open");
plot2(high,"high");
plot3(low,"low");
plot4(close,"close");
alert("High");
end
else begin
Noplot(1);
Noplot(2);
Noplot(3);
Noplot(4);
end;
How can I perform the same operation as above with 1 minute resolution?
in that case instead of setting "maxHighday = maxhigh" setting maxHighday to a very large number that is never reached by the market directly in the line above "plot1("high");" should work.
maxHighday = 999999 should usually be enough.
Regards,
ABCTG
LW11041104
Thank you for your response.
Yes, the alert was output each time the day's high was greater than the previous day's high and the intraday high was updated.
However, I would like the alert to go off only once when the day's high becomes greater than the previous day's high.
Therefore, I do not want an alert to be sounded each time the intraday high is subsequently renewed.
in that case instead of setting "maxHighday = maxhigh" setting maxHighday to a very large number that is never reached by the market directly in the line above "plot1("high");" should work.
maxHighday = 999999 should usually be enough.
Regards,
ABCTG
Thank you for your reply.
I replaced maxHighday = 999999 and it seems to have worked.
I may ask for your help again, but I would appreciate it if you could assist me in that case.