Skip to content

Commit

Permalink
Fixes pre-commit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Jun 16, 2020
1 parent 05b5850 commit 0399ed6
Show file tree
Hide file tree
Showing 42 changed files with 103 additions and 106 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ logs/

# Ignores Finder metadata files on Mac
.DS_Store

Empty file modified BasicTrade.mqh
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion Buffer.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ class Buffer : public Dict<long, T> {
return (T)median;
}
};
#endif // BUFFER_MQH
#endif // BUFFER_MQH
2 changes: 1 addition & 1 deletion BufferStruct.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ class BufferStruct : public DictStruct<long, TStruct> {
}
};

#endif // BUFFER_STRUCT_MQH
#endif // BUFFER_STRUCT_MQH
14 changes: 7 additions & 7 deletions Chart.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ class Chart : public Market {

// Variables.
datetime last_bar_time;

// Current tick index (incremented every OnTick()).
int tick_index;

// Current bar index (incremented every OnTick() if IsNewBar() is true).
int bar_index;

Expand Down Expand Up @@ -277,7 +277,7 @@ class Chart : public Market {
*/
~Chart() {
}

long GetId() {
return ChartID();
}
Expand Down Expand Up @@ -549,7 +549,7 @@ class Chart : public Market {
case PRICE_WEIGHTED:
return (h + l + c + c) / 4;
}

return EMPTY_VALUE;
}

Expand Down Expand Up @@ -1061,18 +1061,18 @@ class Chart : public Market {
bool IsPeak() {
return IsPeak(cparams.tf, symbol);
}

/**
* Acknowledges chart that new tick happened.
*/
virtual void OnTick() {
++tick_index;

if (GetLastBarTime() != GetBarTime()) {
++bar_index;
}
}

/**
* Returns current tick index (incremented every OnTick()).
*/
Expand Down
2 changes: 1 addition & 1 deletion Condition.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,4 @@ class Condition {

/* Setters */
};
#endif // CONDITION_MQH
#endif // CONDITION_MQH
34 changes: 17 additions & 17 deletions Config.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum CONFIG_FORMAT {
string ToJSON(const MqlParam& param, bool, int) {
switch (param.type) {
case TYPE_BOOL:
//boolean
//boolean
return JSON::ValueToString((bool)param.integer_value);
case TYPE_INT:
return JSON::ValueToString((int)param.integer_value);
Expand Down Expand Up @@ -81,12 +81,12 @@ public:
bool operator== (const ConfigEntry& _s) {
return type == _s.type && double_value == _s.double_value && integer_value == _s.integer_value && string_value == _s.string_value;
}

JsonNodeType Serialize(JsonSerializer& s) {
s.PassEnum(this, "type", type);

string aux_string;

switch (type) {
case TYPE_BOOL:
case TYPE_UCHAR:
Expand All @@ -99,15 +99,15 @@ public:
case TYPE_LONG:
s.Pass(this, "value", integer_value);
break;

case TYPE_DOUBLE:
s.Pass(this, "value", double_value);
break;

case TYPE_STRING:
s.Pass(this, "value", string_value);
break;

case TYPE_DATETIME:
if (s.IsWriting()) {
aux_string = TimeToString(integer_value);
Expand All @@ -119,7 +119,7 @@ public:
}
break;
}

return JsonNodeObject;
}
};
Expand All @@ -130,7 +130,7 @@ class Config : public DictStruct<string, ConfigEntry> {
File *file;

public:

/**
* Class constructor.
*/
Expand All @@ -139,7 +139,7 @@ class Config : public DictStruct<string, ConfigEntry> {
file = new File();
}
}

bool Set(string key, bool value) {
ConfigEntry param = {TYPE_BOOL, 0, 0, ""};
param.integer_value = value;
Expand Down Expand Up @@ -205,33 +205,33 @@ class Config : public DictStruct<string, ConfigEntry> {
}

string data = "";

while (!FileIsEnding(handle)) {
data += FileReadString(handle) + "\n";
}

FileClose(handle);

if (format == CONFIG_FORMAT_JSON || format == CONFIG_FORMAT_JSON_NO_WHITESPACES) {
if (!JSON::Parse(data, this)) {
Print("Cannot parse JSON!");
return false;
}
} else if (format == CONFIG_FORMAT_INI) {
// @todo
}
}

return true;
}

/**
* Save config into the file.
*/
bool SaveToFile(string path, CONFIG_FORMAT format) {
ResetLastError();

int handle = FileOpen(path, FILE_WRITE | FILE_ANSI);

if (handle == INVALID_HANDLE) {
string terminalDataPath = TerminalInfoString(TERMINAL_DATA_PATH);
#ifdef __MQL5__
Expand All @@ -242,7 +242,7 @@ class Config : public DictStruct<string, ConfigEntry> {
Print("Cannot open file \"", path , "\" for writing. Error code: ", GetLastError(), ". Consider using path relative to \"" + terminalDataPath + "\\" + terminalSubfolder + "\\Files\\\" as absolute paths may not work.");
return false;
}

string text = JSON::Stringify(this);

FileWriteString(handle, text);
Expand Down
6 changes: 3 additions & 3 deletions Convert.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ public:
ArrayResize(output, len/4);
}
for (i = 0, j = 0; j < len; i++, j += 4) {
output[i] = (StringGetCharacter(in, j)) | ((StringGetCharacter(in, j + 1)) << 8)
output[i] = (StringGetCharacter(in, j)) | ((StringGetCharacter(in, j + 1)) << 8)
| ((StringGetCharacter(in, j+2)) << 16) | ((StringGetCharacter(in, j + 3)) << 24);
}
return (len / 4);
}

static void StringToType(string value, bool& out) {
out = value != "" && value != NULL && value != "0" && value != "false";
}
Expand All @@ -327,7 +327,7 @@ public:
static void StringToType(string value, string& out) {
out = value;
}

/**
* Converts MqlParam struct to double.
*/
Expand Down
4 changes: 2 additions & 2 deletions Dict.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ class Dict : public DictBase<K, V> {
_current_id = right._current_id;
_mode = right._mode;
}

void operator=(const Dict<K, V>& right) {
Resize(right.GetSlotCount());
for (unsigned int i = 0; i < (unsigned int)ArraySize(right._DictSlots_ref.DictSlots); ++i) {
_DictSlots_ref.DictSlots[i] = right._DictSlots_ref.DictSlots[i];
}
_current_id = right._current_id;
_mode = right._mode;
_mode = right._mode;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions DictBase.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct DictSlotsRef {

// Incremental index for dict operating in list mode.
unsigned int _list_index;

unsigned int _num_used;

DictSlotsRef() { _list_index = 0; _num_used = 0; }
Expand Down Expand Up @@ -246,7 +246,7 @@ class DictBase {
// Nothing to unset.
return;
}

unsigned int position = Hash(key) % ArraySize(_DictSlots_ref.DictSlots);
unsigned int tries_left = ArraySize(_DictSlots_ref.DictSlots);

Expand Down Expand Up @@ -368,4 +368,4 @@ class DictBase {
unsigned int Hash(float x) { return (unsigned int)((unsigned long)x * 10000 % 10000); }
};

#endif
#endif
4 changes: 2 additions & 2 deletions DictObject.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class DictObject : public DictBase<K, V> {
_DictSlots_ref.DictSlots[i] = right._DictSlots_ref.DictSlots[i];
}
_current_id = right._current_id;
_mode = right._mode;
_mode = right._mode;
}

/**
Expand Down Expand Up @@ -271,4 +271,4 @@ class DictObject : public DictBase<K, V> {
}
};

#endif
#endif
6 changes: 3 additions & 3 deletions DictStruct.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ class DictStruct : public DictBase<K, V> {
_current_id = right._current_id;
_mode = right._mode;
}

void operator=(const DictStruct<K, V>& right) {
Resize(right.GetSlotCount());
for (unsigned int i = 0; i < (unsigned int)ArraySize(right._DictSlots_ref.DictSlots); ++i) {
_DictSlots_ref.DictSlots[i] = right._DictSlots_ref.DictSlots[i];
}
_current_id = right._current_id;
_mode = right._mode;
_mode = right._mode;
}

DictStructIterator<K, V> Begin() {
Expand Down Expand Up @@ -293,4 +293,4 @@ class DictStruct : public DictBase<K, V> {
}
};

#endif
#endif
2 changes: 1 addition & 1 deletion EA.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class EA {
Object::Delete(trade);

for (DictObjectIterator<ENUM_TIMEFRAMES, Dict<long, Strategy *>> iter1 = strats.Begin(); iter1.IsValid(); ++iter1) {
for (DictIterator<long, Strategy *> iter2 = iter1.Value().Begin(); iter2.IsValid(); ++iter2) {
for (DictIterator<long, Strategy *> iter2 = iter1.Value().Begin(); iter2.IsValid(); ++iter2) {
Object::Delete(iter2.Value());
}
}
Expand Down
26 changes: 13 additions & 13 deletions Indicators/Indi_Bands.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ class Indi_Bands : public Indicator {
/**
* Calculates Bands on another indicator.
*
* When _applied_price is set to -1, method will
* When _applied_price is set to -1, method will
*/
static double iBandsOnIndicator(
Indicator *_indi, string _symbol, ENUM_TIMEFRAMES _tf, unsigned int _period, double _deviation, int _bands_shift,
ENUM_BANDS_LINE _mode = BAND_BASE, // (MT4/MT5): 0 - MODE_MAIN/BASE_LINE, 1 -
// MODE_UPPER/UPPER_BAND, 2 - MODE_LOWER/LOWER_BAND
int _shift = 0, Indicator *_obj = NULL) {

double _indi_value_buffer[];
double _std_dev;
double _line_value;
Expand All @@ -135,12 +135,12 @@ class Indi_Bands : public Indicator {
for (int i = _bands_shift; i < (int)_period; i++) {
int current_shift = _shift + (i - _bands_shift);
// Getting current indicator value.
_indi_value_buffer[i - _bands_shift] = _indi[i - _bands_shift].value.GetValueDbl(_indi.GetIDataType());
_indi_value_buffer[i - _bands_shift] = _indi[i - _bands_shift].value.GetValueDbl(_indi.GetIDataType());
}

// Base band.
_line_value = Indi_MA::SimpleMA(_shift, _period, _indi_value_buffer);

// Standard deviation.
_std_dev = Indi_StdDev::iStdDevOnArray(_indi_value_buffer, _line_value, _period);

Expand All @@ -156,39 +156,39 @@ class Indi_Bands : public Indicator {

return EMPTY_VALUE;
}

static double iBandsOnArray(double& array[], int total, int period, double deviation, int bands_shift, int mode, int shift)
{
#ifdef __MQL5__
#ifdef __MQL5__
Indi_PriceFeeder price_feeder(array);
return iBandsOnIndicator(&price_feeder, NULL, NULL, period, deviation, bands_shift, (ENUM_BANDS_LINE)mode, shift);
#else
return ::iBandsOnArray(array, total, period, deviation, bands_shift, mode, shift);
#endif
}

static double iBandsOnArray2(double& array[], int total, int period, double deviation, int bands_shift, int mode, int shift)
{
#ifdef __MQL5__
#ifdef __MQL5__
// Calculates bollinger bands indicator from array data
int size = ArraySize(array);
if (size < period)
return false;
if (period <= 0)
return false;

double ma = Indi_MA::iMAOnArray(array, total, period, 0, MODE_SMA, 0);

double sum = 0.0, val;
int i;

for (i = 0; i < period; i++) {
val = array[size - i - 1] - ma;
sum += val * val;
}

double dev = deviation * MathSqrt(sum / period);

switch (mode) {
case BAND_BASE:
return ma;
Expand Down
Loading

0 comments on commit 0399ed6

Please sign in to comment.