Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v3.000-dev-fixes' into v3.001-de…
Browse files Browse the repository at this point in the history
…v-new

* origin/v3.000-dev-fixes:
  • Loading branch information
kenorb committed Apr 19, 2024
2 parents 83d5ee7 + 8f5733b commit b51b818
Show file tree
Hide file tree
Showing 16 changed files with 433 additions and 53 deletions.
8 changes: 4 additions & 4 deletions Array.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,12 @@ static int GetLowestArrDoubleValue(double& arr[][], int key) {
}

template <typename X>
static void ArrayStore(ARRAY_REF(X, array), int index, X value, int reserve_size = 0) {
if (index >= ArraySize(array)) {
ArrayResize(array, MathMax(index + 1, ArraySize(array)), reserve_size);
static void ArrayStore(ARRAY_REF(X, array), int _idx, X value, int reserve_size = 0) {
if (_idx >= ArraySize(array)) {
ArrayResize(array, MathMax(_idx + 1, ArraySize(array)), reserve_size);
}

array[index] = value;
array[_idx] = value;
}
};

Expand Down
10 changes: 5 additions & 5 deletions Chart.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -378,23 +378,23 @@ class Chart : public Market {
*
* In case of error, check it via GetLastError().
*/
double GetPeakPrice(int bars, int mode, int index, ENUM_TIMEFRAMES timeframe = PERIOD_CURRENT) {
double GetPeakPrice(int bars, int mode, int _idx, ENUM_TIMEFRAMES timeframe = PERIOD_CURRENT) {
int ibar = -1;
// @todo: Add symbol parameter.
double peak_price = GetOpen(0);
switch (mode) {
case MODE_HIGH:
ibar = ChartStatic::iHighest(symbol, timeframe, MODE_HIGH, bars, index);
ibar = ChartStatic::iHighest(symbol, timeframe, MODE_HIGH, bars, _idx);
return ibar >= 0 ? GetHigh(timeframe, ibar) : false;
case MODE_LOW:
ibar = ChartStatic::iLowest(symbol, timeframe, MODE_LOW, bars, index);
ibar = ChartStatic::iLowest(symbol, timeframe, MODE_LOW, bars, _idx);
return ibar >= 0 ? GetLow(timeframe, ibar) : false;
default:
return false;
}
}
double GetPeakPrice(int bars, int mode = MODE_HIGH, int index = 0) {
return GetPeakPrice(bars, mode, index, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF));
double GetPeakPrice(int bars, int mode = MODE_HIGH, int _idx = 0) {
return GetPeakPrice(bars, mode, _idx, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Chart.struct.tf.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ struct ChartTf {
* @param
* _tf ENUM_TIMEFRAMES_INDEX Specify timeframe index enum.
*/
static ENUM_TIMEFRAMES const IndexToTf(ENUM_TIMEFRAMES_INDEX index) {
static ENUM_TIMEFRAMES const IndexToTf(ENUM_TIMEFRAMES_INDEX _idx) {
// @todo: Convert it into a loop and using tf constant, see: TfToIndex().
switch (index) {
switch (_idx) {
case M1:
return PERIOD_M1; // 1 minute.
case M2:
Expand Down
4 changes: 2 additions & 2 deletions Convert.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ class Convert {
int i, j;
len = StringLen(in);
if (len % 4 != 0) len = len - len % 4;
int size = ArraySize(output);
if (size < len / 4) {
int _size = ArraySize(output);
if (_size < len / 4) {
ArrayResize(output, len / 4);
}
for (i = 0, j = 0; j < len; i++, j += 4) {
Expand Down
6 changes: 3 additions & 3 deletions DictBase.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ class DictBase {
*/
bool HasFlags(int flags) { return (_flags & flags) == flags; }

DictSlot<K, V>* GetSlot(const unsigned int index) {
if (index >= GetSlotCount()) {
DictSlot<K, V>* GetSlot(const unsigned int _idx) {
if (_idx >= GetSlotCount()) {
// Index of out bounds.
return NULL;
}

return &_DictSlots_ref.DictSlots[index];
return &_DictSlots_ref.DictSlots[_idx];
}

/**
Expand Down
25 changes: 14 additions & 11 deletions Draw.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class Draw;
bool ObjectCreate(string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1) {
return Draw::ObjectCreate(0, _name, _otype, _swindow, _t1, _p1);
}
bool ObjectCreate(string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1, datetime _t2, double _p2) {
return Draw::ObjectCreate(0, _name, _otype, _swindow, _t1, _p1, _t2, _p2);
}
bool ObjectDelete(string _name) { return Draw::ObjectDelete(_name); }
bool ObjectSet(string _name, int _prop_id, double _value) { return Draw::ObjectSet(_name, _prop_id, _value); }
int ObjectsTotal(int _type = EMPTY) { return Draw::ObjectsTotal(); }
Expand Down Expand Up @@ -126,34 +129,34 @@ class Draw : public Chart {
* @return
* If successful, returns true, otherwise false.
*/
static bool SetIndexLabel(int index, string text) {
static bool SetIndexLabel(int _idx, string text) {
#ifdef __MQL4__
// https://docs.mql4.com/customind/setindexlabel
::SetIndexLabel(index, text);
::SetIndexLabel(_idx, text);
return true;
#else
// https://www.mql5.com/en/docs/customind/plotindexsetstring
return PlotIndexSetString(index, PLOT_LABEL, text);
return PlotIndexSetString(_idx, PLOT_LABEL, text);
#endif
}

/**
* Sets the new type, style, width and color for a given indicator line.
*
*/
static void SetIndexStyle(int index, int type, int style = EMPTY, int width = EMPTY, color clr = CLR_NONE) {
static void SetIndexStyle(int _idx, int type, int style = EMPTY, int width = EMPTY, color clr = CLR_NONE) {
#ifdef __MQL4__
// https://docs.mql4.com/customind/setindexstyle
::SetIndexStyle(index, type, style, width, clr);
::SetIndexStyle(_idx, type, style, width, clr);
#else
if (width != EMPTY) {
PlotIndexSetInteger(index, PLOT_LINE_WIDTH, width);
PlotIndexSetInteger(_idx, PLOT_LINE_WIDTH, width);
}
if (clr != CLR_NONE) {
PlotIndexSetInteger(index, PLOT_LINE_COLOR, clr);
PlotIndexSetInteger(_idx, PLOT_LINE_COLOR, clr);
}
PlotIndexSetInteger(index, PLOT_DRAW_TYPE, type);
PlotIndexSetInteger(index, PLOT_LINE_STYLE, style);
PlotIndexSetInteger(_idx, PLOT_DRAW_TYPE, type);
PlotIndexSetInteger(_idx, PLOT_LINE_STYLE, style);
#endif
}

Expand Down Expand Up @@ -299,9 +302,9 @@ class Draw : public Chart {
/**
* Draw a line given the price.
*/
void ShowLine(string oname, double price, int colour = Yellow) {
void ShowLine(string oname, double price, int _colour = Yellow) {
Draw::ObjectCreate(chart_id, oname, OBJ_HLINE, 0, GetBarTime(), price);
Draw::ObjectSet(oname, OBJPROP_COLOR, colour);
Draw::ObjectSet(oname, OBJPROP_COLOR, _colour);
Draw::ObjectMove(oname, 0, GetBarTime(), price);
}

Expand Down
1 change: 1 addition & 0 deletions Indicator.define.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

// Defines macros.
#define COMMA ,
#define SEMICOLON ;
#define DUMMY

#define ICUSTOM_DEF(SET_HANDLE, PARAMS) \
Expand Down
12 changes: 6 additions & 6 deletions Indicator.struct.cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ class IndicatorCalculateCache : public Dynamic {
* Returns existing or new cache as a child of current one. Useful when indicator uses other indicators and requires
* unique caches for them.
*/
IndicatorCalculateCache<C> *GetSubCache(int index) {
if (index >= ArraySize(subcaches)) {
ArrayResize(subcaches, index + 1, 10);
IndicatorCalculateCache<C> *GetSubCache(int _idx) {
if (_idx >= ArraySize(subcaches)) {
ArrayResize(subcaches, _idx + 1, 10);
}

if (subcaches[index] == NULL) {
subcaches[index] = new IndicatorCalculateCache();
if (subcaches[_idx] == NULL) {
subcaches[_idx] = new IndicatorCalculateCache();
}

return subcaches[index];
return subcaches[_idx];
}

/**
Expand Down
Loading

0 comments on commit b51b818

Please sign in to comment.