I'm sorry, the code had the variables wrong. Here it is fixed to make it more understandable.
int bullCount1 = 0; // Initialize the bullish candle counter to 0 int bearCount1 = 0; // Initialize the bearish candle counter to 0 for (int i = 1; i < 20; i++) // Loop through the last 20 bars { if (CountTrades() > 0) { if (Close[i] > Open[i]) { bullCount1++; // Increase the counter if the candlestick is bullish } else if (Close[i] < Open[i]) { bearCount1++; // Increase the counter if the candlestick is bearish } } }
int bullCount1 = 0; // Initialize the bullish candle counter to 0 int bearCount1 = 0; // Initialize the bearish candle counter to 0 bool OpenBar = TRUE; if(iVolume(Symbol(),PERIOD_CURRENT,0)>1) { OpenBar=false; } if(OpenBar) { for (int i = 1; i < 20; i++) // Loop through the last 20 bars { if (Close[i] > Open[i]) { bullCount1++; // Increase the counter if the candlestick is bullish } else if (Close[i] < Open[i]) { bearCount1++; // Increase the counter if the candlestick is bearish } } }
Try this, I don't really get what you want, but here what I understand.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello. I'm sorry for my English. Can someone help me? I'm new to this, and I'm trying to get the number of bullish and bearish bars forming up to a distance of N bars. I'm doing it like this, but it counts the bars that are before the trade itself, the ones that have already formed. I'm trying to make it count as soon as a trade is opened. Thank you.