I suspect this must be some logic error on my part, but I really can't figure it out. Any help appreciated.
I have a section of code that should turn the line green if a condition is true ( nRSI_Sig == 1) or red ( nRSI_Sig == -1 ). If neither condition is true, the default line color of blue will be used.
nRSI_Sig is set prior to this in a section of code that is restricted by a check for NEWBAR ( if ( nBarState == BARSTATE_NEWBAR ) ).
The issue is that in RT the line is always Blue (the default color), even though nRSI_Sig is 1 or -1 most of the time, and I get the correct color printed on the Formula Output screen:
All historical data is displayed as I would expect (red or green line) and the value of the line is always correct in either mode. A refresh of the chart will display the line color correctly.
If I remove the NEWBAR check in the section of code above, it all displays correctly, even in RT.
What am I missing?
Thanks!
I have a section of code that should turn the line green if a condition is true ( nRSI_Sig == 1) or red ( nRSI_Sig == -1 ). If neither condition is true, the default line color of blue will be used.
PHP Code:
if ( nBarState == BARSTATE_NEWBAR ) {
debugPrintln("Index: " + nBarIndex + " nRSI_Sig: " + nRSI_Sig + " nLastRSI: " + nLastRSI + " nCurrentRSI: " + nCurrentRSI);
if ( nRSI_Sig == 1 ) {
setBarFgColor(Color.RGB(0,255, 0), 0);
debugPrintln("Index: " + nBarIndex + " Green ");
}
if ( nRSI_Sig == -1 ) {
setBarFgColor(Color.RGB(255,0, 0), 0);
debugPrintln("Index: " + nBarIndex + " Red ");
}
}
The issue is that in RT the line is always Blue (the default color), even though nRSI_Sig is 1 or -1 most of the time, and I get the correct color printed on the Formula Output screen:
PHP Code:
Index: -3 nRSI_Sig: -1 nLastRSI: 66.38295566980304 nCurrentRSI: 68.40682690587413
Index: -3 Red
Index: -2 nRSI_Sig: 1 nLastRSI: 68.40682690587413 nCurrentRSI: 71.8209949644798
Index: -2 Green
Index: -1 nRSI_Sig: 1 nLastRSI: 71.8209949644798 nCurrentRSI: 72.76165327122916
Index: -1 Green
Index: 0 nRSI_Sig: 1 nLastRSI: 72.76165327122916 nCurrentRSI: 71.6848261373386
Index: 0 Green
If I remove the NEWBAR check in the section of code above, it all displays correctly, even in RT.
What am I missing?
Thanks!
Comment