Hi Karen,
The first problem is I think you misunderstand what the BARCOUNT() function does.
As stated in the Knowledge Base article https://help.optuma.com/kb/faq.php?id=961 describing the function it “will return either the total number of data bars that are available for a symbol, or the total number of bars on the screen at the time”. Thus your script (if((BARCOUNT()>=200),BARCOUNT(),0)) will return the total number of bars in the code, that the 314 Bars on the Weekly Chart of AC8. If you apply that script to a SHOWVIEW it reflects that result.
Your script (if((BARCOUNT()>=200),1,0)) will, because the BARCOUNT is greater than 200, return a result of 1. However, if you change the 200 to 400 you’ll find it return 0, which is to be expected as the BARCOUNT = 314. Again, using a SHOWVIEW will demonstrate this.
So, I conclude that using BARCOUNT is not the appropriate function for what you are attempting to achieve, which I understand from your first post to be:
Show those bars bars that:
1 occur after the signal of a Close crossing above, and remaining above, the MA200 for longer than 200 bars, ie the first SHOWBAR will be 200 Bars past the first Close above the MA200 and SHOWBARS will show for all Bars thereafter until the Close crosses below the MA200, or
2 occur after the signal of a Close crossing above, and remaining above, the MA 100 for longer than 200 bars, ie the first SHOWBAR will be 200 Bars past the first Close above the MA100 and SHOWBARS will show for all Bars thereafter until the Close crosses below the MA100, and
if that criteria is not met then show those bars less than 200 bars that:
3 occur after the signal of a Close crossing above, and remaining above, the MA 100 for less than 200 bars, ie the first SHOWBAR will be signal the first Close above the MA100 and SHOWBARS will show for all Bars thereafter until the Close crosses below the MA100
The following script applies the criteria 1 and 2 above with the result shown in the first chart below (Note: I've use Daily Charts, the criteria are not met on a Weekly Chart):
// 20190922 -1 Karen's Ticket 54667
v1= Close() >= MA(BARS=200, CALC=Close);
v2= Close() < MA(BARS=200, CALC=Close);
//Count the number of times V1 occurred since V2
v3 = COUNTMATCHSINCESIGNAL(V1,V2);
// v4= Close() >= MA(BARS=100, CALC=Close);
v5= Close() < MA(BARS=100, CALC=Close);
//Count the number of times V4 occurred since V5
v6= COUNTMATCHSINCESIGNAL(V4,V5);
IF(v3>=200 or v6>=200, 1, 0)
Adding the 3rd criteria listed above results in this script, which produces the result on the chart below:
// 20190922 -2 Karen's Ticket 54667
v1= Close() >= MA(BARS=200, CALC=Close);
v2= Close() < MA(BARS=200, CALC=Close);
//Count the number of times V1 occurred since V2
v3 = COUNTMATCHSINCESIGNAL(V1,V2);
//
v4= Close() >= MA(BARS=100, CALC=Close);
v5= Close() < MA(BARS=100, CALC=Close);
//Count the number of times V4 occurred since V5
v6= COUNTMATCHSINCESIGNAL(V4,V5);
IF(v3>=200 or v6>=200, 1, If(v6<200 and v4, 1, 0))
Is that what you are looking for Karen?
Cheers
Trevor