Skip to content

Commit 33dd8f1

Browse files
committed
update CCI chart legend
1 parent 634bb08 commit 33dd8f1

5 files changed

Lines changed: 26 additions & 25 deletions

File tree

mql40/include/rsf/core/indicator.mqh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int init() {
100100
// before onInit(): log input parameters if loaded by iCustom()
101101
if (__isSuperContext && IsLogDebug()) {
102102
string sInputs = InputsToStr();
103-
if (StringLen(sInputs) > 0) {
103+
if (sInputs != "") {
104104
sInputs = StringConcatenate(sInputs, NL,
105105
"AutoConfiguration=", AutoConfiguration, ";", NL,
106106
"__lpSuperContext=", "0x", IntToHexStr(__lpSuperContext), ";");

mql40/include/rsf/indicators/chartinfos/init.mqh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ int afterInit() {
136136

137137
// setup a chart ticker
138138
if (!__virtualTicksTimerId) {
139-
int hWnd = __ExecutionContext[EC.chart];
140-
int millis = 2000; // once every 2 seconds
139+
int hWnd = __ExecutionContext[EC.chart], milliseconds;
141140

142141
if (StrStartsWithI(GetAccountServer(), "XTrade-")) {
143-
// offline ticker to update chart data in synthetic charts
144-
__virtualTicksTimerId = SetupTickTimer(hWnd, millis, TICK_CHART_REFRESH|TICK_IF_WINDOW_VISIBLE);
142+
// offline ticker to update synthetic charts
143+
milliseconds = 1000;
144+
__virtualTicksTimerId = SetupTickTimer(hWnd, milliseconds, TICK_CHART_REFRESH|TICK_IF_WINDOW_VISIBLE);
145145
if (!__virtualTicksTimerId) return(catch("afterInit(1)->SetupTickTimer(hWnd="+ IntToHexStr(hWnd) +") failed", ERR_RUNTIME_ERROR));
146146

147147
// display ticker status
@@ -153,8 +153,9 @@ int afterInit() {
153153
ObjectSetText(label, "n", 6, "Webdings", LimeGreen); // a "dot" marker, Green = online
154154
}
155155
else {
156-
// virtual ticks to update chart infos on a slow data feed
157-
__virtualTicksTimerId = SetupTickTimer(hWnd, millis, TICK_IF_WINDOW_VISIBLE);
156+
// virtual ticks to update chart infos/custom positions without waiting for the next tick
157+
milliseconds = 600;
158+
__virtualTicksTimerId = SetupTickTimer(hWnd, milliseconds, TICK_IF_WINDOW_VISIBLE);
158159
if (!__virtualTicksTimerId) return(catch("afterInit(2)->SetupTickTimer(hWnd="+ IntToHexStr(hWnd) +") failed", ERR_RUNTIME_ERROR));
159160
}
160161
}

mql40/indicators/CCI.mq4

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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

5959
double 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);

mql40/indicators/ZigZag.mq4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ bool SetIndicatorOptions(bool redraw = false) {
17841784
IndicatorBuffers(terminal_buffers);
17851785
SetIndexBuffer(MODE_UPPER_BAND, upperBand ); SetIndexEmptyValue(MODE_UPPER_BAND, 0); SetIndexLabel(MODE_UPPER_BAND, donchianName +" upper band"); if (!Donchian.ShowChannel) SetIndexLabel(MODE_UPPER_BAND, NULL);
17861786
SetIndexBuffer(MODE_LOWER_BAND, lowerBand ); SetIndexEmptyValue(MODE_LOWER_BAND, 0); SetIndexLabel(MODE_LOWER_BAND, donchianName +" lower band"); if (!Donchian.ShowChannel) SetIndexLabel(MODE_LOWER_BAND, NULL);
1787-
SetIndexBuffer(MODE_SEMAPHORE_OPEN, semaphoreOpen ); SetIndexEmptyValue(MODE_SEMAPHORE_OPEN, 0); SetIndexLabel(MODE_SEMAPHORE_OPEN, NULL);
1787+
SetIndexBuffer(MODE_SEMAPHORE_OPEN, semaphoreOpen ); SetIndexEmptyValue(MODE_SEMAPHORE_OPEN, 0); SetIndexLabel(MODE_SEMAPHORE_OPEN, NULL);
17881788
SetIndexBuffer(MODE_SEMAPHORE_CLOSE, semaphoreClose); SetIndexEmptyValue(MODE_SEMAPHORE_CLOSE, 0); SetIndexLabel(MODE_SEMAPHORE_CLOSE, shortName +" high/low"); if (!ZigZag.Width) SetIndexLabel(MODE_SEMAPHORE_CLOSE, NULL);
17891789
SetIndexBuffer(MODE_UPPER_CROSS, upperCross ); SetIndexEmptyValue(MODE_UPPER_CROSS, 0); SetIndexLabel(MODE_UPPER_CROSS, shortName +" extension up"); if (!crossingDrawType) SetIndexLabel(MODE_UPPER_CROSS, NULL);
17901790
SetIndexBuffer(MODE_LOWER_CROSS, lowerCross ); SetIndexEmptyValue(MODE_LOWER_CROSS, 0); SetIndexLabel(MODE_LOWER_CROSS, shortName +" extension down"); if (!crossingDrawType) SetIndexLabel(MODE_LOWER_CROSS, NULL);

mql40/libraries/rsfMT4Expander.dll

-512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)