Skip to content

Commit

Permalink
Merge branch 'v3.001-dev-new' into v3.001-dev
Browse files Browse the repository at this point in the history
* v3.001-dev-new:
  Fixes new lines [end-of-file-fixer]
  GHA: Compile: Support for workflow calls
  GHA: Compile: Skips clean-up by default
  Adds vscode's extensions for devcontainer
  Adds initial config for .devcontainer/devcontainer.json
  GHA: Fixes compilation workflows
  Refs EA31337/Strategy-TDI#1. MA-targeted changes regarding input MA method and iMAOnArray implementation which input is now changed to native array (from ValueStorage).
  Refs EA31337/EA31337-indicators-other#8. Added IndicatorLegacy.h file to allow using MQL5 versions of iNAME() indicators like iMA(), iRSI() in MQL4. Used to run MQL5 indicators in MQL4.
  Refs EA31337/EA31337-indicators-other#8. Added underscores to some function parameter names  to prevent conflicts with global variables.
  Refs #11. Renamed "index" variable names into "_idx" to prevent conflicts with global variables. Also added new CreateObject() specialization to Draw.mqh. Added #ifdef to Terminal.define.h to prevent redefinition of defines.
  Indi_Fractals: Fixes code typo
  Final fix for orders are opened instead of being closed for both MT4 and MT5 (fixes GH-707)
  Fixes C++ error: no matching function for call
  • Loading branch information
kenorb committed Apr 23, 2024
2 parents c254a48 + 0ad14d1 commit 1fc4f06
Show file tree
Hide file tree
Showing 24 changed files with 611 additions and 67 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"L-I-V.mql-tools",
"ms-vscode.cpptools",
"vscodevim.vim"
],
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers-contrib/features/actionlint:1": {},
"ghcr.io/devcontainers-contrib/features/ansible:2": {},
"ghcr.io/guiyomh/features/vim:0": {},
"ghcr.io/jungaretti/features/make:1": {},
"ghcr.io/prulloac/devcontainer-features/pre-commit:1": {},
"ghcr.io/hspaans/devcontainer-features/ansible-lint:1": {}
},
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"name": "EA31337"
}
57 changes: 55 additions & 2 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Compile

env:
ARTIFACT_PREFIX: ${{ inputs.artifact_prefix || 'mt' }}

# yamllint disable-line rule:truthy
on:
pull_request:
Expand All @@ -9,18 +12,68 @@ on:
push:
paths-ignore:
- '**.md'
workflow_call:
inputs:
artifact_prefix:
default: mt
description: Artifact prefix.
required: false
type: string
skip_cleanup:
default: false
description: Whether to skip a clean-up job.
required: false
type: boolean

jobs:

Compile:
mt4:
name: Installs platform (4)
uses: EA31337/EA-Tester/.github/workflows/platform-linux.yml@dev
with:
artifact_name: ${{ inputs.artifact_prefix || 'mt' }}4
artifact_overwrite: true
skip_cleanup: true
version: 4
mt5:
name: Installs platform (5)
uses: EA31337/EA-Tester/.github/workflows/platform-linux.yml@dev
with:
artifact_name: ${{ inputs.artifact_prefix || 'mt' }}5
artifact_overwrite: true
skip_cleanup: true
version: 5

compile:
name: Compile
needs: [mt4, mt5]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: mt${{ matrix.version }}
path: .mt${{ matrix.version }}
- name: Compile
uses: fx31337/mql-compile-action@master
with:
init-platform: true
mt-path: .mt${{ matrix.version }}
verbose: true
- name: Print compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
shell: powershell

strategy:
matrix:
version: [4, 5]

cleanup:
if: inputs.skip_cleanup != true
name: Clean-up
needs: [compile]
runs-on: ubuntu-latest
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: ${{ env.ARTIFACT_PREFIX }}*
8 changes: 4 additions & 4 deletions Array.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -758,12 +758,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 @@ -187,9 +187,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 @@ -307,8 +307,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 @@ -94,13 +94,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 1fc4f06

Please sign in to comment.