count how many times a conditional event occurs

count how many times a conditional event occurs

Manage alerts

Loading saved threads...

Jon Thetford · External communityPost link
External question — Stack Overflow Stack Exchange Author: Jon Thetford Original post: https://stackoverflow.com/questions/67612978 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I'm trying to count how many times a conditional event occurs. But when I test it, it gives me unrealistic numbers. I don't think I am coding it correctly anybody want to help me out?? for(i=0;i<Bars; i++) { //Condition I want met if(Close[i+1]<Close[i+2]<Close[i+3]<Close[i+4]<Close[i+5]); //Add 1 each time condition is met for sum total when the for loop ends x=x+1; Comment(x); }
Quote
Report
Ken Lee · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Ken Lee Original post: https://stackoverflow.com/a/67613000 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. the ; of the if statement effectively terminates the conditional statements (so the x=x+1 will not be executed correctly according to the condition(s). Hence , please change if(Close[i+1]<Close[i+2]<Close[i+3]<Close[i+4]<Close[i+5]); //Add 1 each time condition is met for sum total when the for loop ends x=x+1; to if(Close[i+1]<Close[i+2]<Close[i+3]<Close[i+4]<Close[i+5]) { //Add 1 each time condition is met for sum total when the for loop ends x=x+1;}
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Jon Thetford Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/67612978 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I'm trying to count how many times a conditional event occurs. But when I test it, it gives me unrealistic numbers. I don't think I am coding it correctly anybody want to help me out?? for(i=0;i<Bars; i++) { //Condition I want met if(Close[i+1]<Close[i+2]<Close[i+3]<Close[i+4]<Close[i+5]); //Add 1 each time condition is met for sum total when the for loop ends x=x+1; Comment(x); }

Cancel quote

Checking account access…