11/**
22 * Commodity Channel Index - a true momentum indicator. Measures sudden price acceleration.
33 *
4- * Defined as the upscaled ratio of the current distance to average distance from a Moving Average (default: SMA).
4+ * Defined as the upscaled ratio of current distance to average distance from a Moving Average (default: SMA).
55 * The upscaling factor of 66.67 was chosen so that the majority of indicator values falls between +200 and -200.
66 * Signal level is +/-100.
77 */
@@ -57,18 +57,16 @@ extern string Signal.Sound.Down = "Signal Down.wav";
5757#property indicator_minimum -180
5858
5959double cci []; // all CCI values
60- double cciLong []; // long trade segments
61- double cciShort []; // short trade segments
62- double trend []; // trade segment length
60+ double cciLong []; // long colored CCI values
61+ double cciShort []; // short colored CCI values
62+ double trend []; // last color segment length
6363
64- int appliedPrice ;
64+ int appliedPrice ;
6565
66- bool signal .sound ;
67- bool signal .alert ;
68- bool signal .mail ;
69- bool signal .telegram ;
70-
71- string indicatorName = " " ;
66+ bool signal .sound ;
67+ bool signal .alert ;
68+ bool signal .mail ;
69+ bool signal .telegram ;
7270
7371// parameter stepper directions
7472#define STEP_UP 1
@@ -276,8 +274,9 @@ bool onTrendChange(int direction) {
276274
277275 // skip the signal if it was already handled elsewhere
278276 string sPeriod = PeriodDescription ();
279- string eventName = " rsf::" + StdSymbol () +" ," + sPeriod +" ." + indicatorName +" .onTrendChange(" + direction +" )." + TimeToStr (Time [0 ]), propertyName = " " ;
280- string message1 = indicatorName +" signal " + ifString (direction ==MODE_LONG , " long" , " short" ) +" (bid: " + NumberToStr (_Bid , PriceFormat ) +" )" ;
277+ string indicator = " CCI(" + Periods +" )" ;
278+ string eventName = " rsf::" + StdSymbol () +" ," + sPeriod +" ." + indicator +" .onTrendChange(" + direction +" )." + TimeToStr (Time [0 ]), propertyName = " " ;
279+ string message1 = indicator +" " + ifString (direction ==MODE_LONG , " long" , " short" ) +" signal (bid: " + NumberToStr (_Bid , PriceFormat ) +" )" ;
281280 string message2 = Symbol () +" ," + PeriodDescription () +" : " + message1 ;
282281 string localTime = TimeToStr (TimeLocalEx (" onTrendChange(2)" ), TIME_MINUTES |TIME_SECONDS );
283282 string accountAlias = GetAccountAlias ();
@@ -416,8 +415,9 @@ bool SetIndicatorOptions(bool redraw = false) {
416415 redraw = redraw !=0 ;
417416
418417 string stepSize = ifString (Periods .Step , " :" + Periods .Step , " " );
419- indicatorName = " CCI(" + Periods + stepSize +" )" ;
420- IndicatorShortName (indicatorName );
418+ string sSignal = ifString (Signal .onTrendChange , " signal" , " " );
419+ string name = " CCI(" + Periods + stepSize +" )" + sSignal ;
420+ IndicatorShortName (name ); // subwindow chart legend
421421
422422 IndicatorBuffers (indicator_buffers );
423423 SetIndexBuffer (MODE_MAIN , cci );
@@ -430,10 +430,10 @@ bool SetIndicatorOptions(bool redraw = false) {
430430 SetIndexDrawBegin (MODE_LONG , drawBegin );
431431 SetIndexDrawBegin (MODE_SHORT , drawBegin );
432432
433- SetIndexLabel (MODE_MAIN , " CCI(" + Periods +" )" ); // displays values in indicator and "Data" window
433+ SetIndexLabel (MODE_MAIN , " CCI(" + Periods +" )" ); // "Data" window labels
434434 SetIndexLabel (MODE_LONG , NULL );
435435 SetIndexLabel (MODE_SHORT , NULL );
436- SetIndexLabel (MODE_TREND , NULL ); // prevents trend value in indicator window
436+ SetIndexLabel (MODE_TREND , NULL );
437437
438438 SetIndexStyle (MODE_MAIN , DRAW_NONE );
439439 SetIndexStyle (MODE_TREND , DRAW_NONE );
0 commit comments