Condition Countif  [SOLVED]

Questions about MultiCharts and user contributed studies.
toyutim
Posts: 3
Joined: 21 Aug 2023
Has thanked: 1 time

Condition Countif

Postby toyutim » 21 Aug 2023

Hi all. I am trying to execute the trade based on the below conditions. But i am not sure how to write the script if i want 3 out of 4 of 1 -4 conditions are True. I tried "countif" but failed. Is there any expert that ca help me? Thanks

condition 1 = a;
condition 2 = b;
condition 3 = c;
condition 4 = d;
condition 5 = (3 out of 4 of 1 -4 conditions are True);

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Condition Countif  [SOLVED]

Postby TJ » 21 Aug 2023

the rudimentary way to write this logic is to lay them out one by one:

Code: Select all

if condition1 then count1=1 else count1=0; if condition2 then count2=1 else count2=0; if condition3 then count3=1 else count3=0; if condition4 then count4=1 else count4=0; condition5 = sum(count1+count2+count3+count4) > 2;


Return to “MultiCharts”