Code for defining sequence of application of two conditions for example

code for defining sequence of application of two conditions for example

i have 2 condition for entry(buy or sell),cond1 and cond2.
suppose
cond1= vol>=20dayavgvol,
cond2=cross(x,y),

the way i have written this in my code is

buy=cond1 and cond2;

the issue i am facing is at the time of cross(cond2) even if my cond1 (volume) is not true then and delayed signal for buy or sell is displayed at the cross when my cond1 becomes true .

what would be the solution for this if i want to give it a sequence like if cond1 is true then and only then at the cross i should get buy or sell signal.

you could try Hold
https://www.amibroker.com/guide/afl/hold.html

if the first condition occurs, then you could hold it for a certain number of bars and check if the 2nd condition occurred to complete a valid signal.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.