Skip to content

Commit

Permalink
Merge branch 'v3.001-dev' into v3.002-dev
Browse files Browse the repository at this point in the history
* v3.001-dev:
  GHA: Compile: Fixes uploading artifacts after compilation
  GHA: Compile: Ignores compiling platform files
  Fixing CompileTest
  Fixes compilation errors on build 4275
  GHA: Test: Includes compile workflow
  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 24, 2024
2 parents 3687d5f + 53b8c0c commit 52c8fcc
Show file tree
Hide file tree
Showing 30 changed files with 656 additions and 116 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"
}
64 changes: 62 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,75 @@ 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 }}
path-ignore: .mt${{ matrix.version }}
path: '**/*.mq${{ matrix.version }}'
verbose: true
- name: Print compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
shell: powershell
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: files-ex${{ matrix.version }}
path: '**/*.ex[45]'

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 }}*
30 changes: 7 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,19 @@ on:

jobs:

Compile:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Compile
uses: fx31337/mql-compile-action@master
with:
mt-version: 4.0.0.1349
verbose: true
- name: Print compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
shell: powershell
- name: Upload artifacts (MQL4)
uses: actions/upload-artifact@v2
with:
name: files-ex4
path: '**/*.ex4'
- name: Upload artifacts (MQL5)
uses: actions/upload-artifact@v2
with:
name: files-ex5
path: '**/*.ex5'
compile:
name: Compile
uses: ./.github/workflows/compile.yml
with:
artifact_prefix: mt
skip_cleanup: true

Experts-MQL4:
defaults:
run:
shell: bash
working-directory: tests
needs: Compile
needs: compile
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions 3D/Cube.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class Cube : public Mesh<T> {
* Initializes graphics device-related things.
*/
virtual void Initialize(Device* _device) {
SetShaderVS(_device.VertexShader(ShaderCubeSourceVS, T::Layout));
SetShaderPS(_device.PixelShader(ShaderCubeSourcePS));
SetShaderVS(_device.CreateVertexShader(ShaderCubeSourceVS, T::Layout));
SetShaderPS(_device.CreatePixelShader(ShaderCubeSourcePS));
}
#endif
};
29 changes: 17 additions & 12 deletions 3D/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,25 @@ class Device : public Dynamic {
/**
* Creates vertex shader to be used by current graphics device.
*/
virtual Shader* VertexShader(string _source_code, const ShaderVertexLayout& _layout[],
string _entry_point = "main") = NULL;
virtual Shader* CreateVertexShader(string _source_code, const ShaderVertexLayout& _layout[],
string _entry_point = "main") = NULL;

/**
* Creates pixel shader to be used by current graphics device.
*/
virtual Shader* PixelShader(string _source_code, string _entry_point = "main") = NULL;
virtual Shader* CreatePixelShader(string _source_code, string _entry_point = "main") = 0;

/**
* Creates vertex buffer to be used by current graphics device.
*/
virtual VertexBuffer* CreateVertexBuffer() = 0;

/**
* Creates vertex buffer to be used by current graphics device.
*/
template <typename T>
VertexBuffer* VertexBuffer(T& data[]) {
VertexBuffer* _buff = VertexBuffer();
VertexBuffer* CreateVertexBuffer(T& data[]) {
VertexBuffer* _buff = CreateVertexBuffer();
// Unfortunately we can't make this method virtual.
if (dynamic_cast<MTDXVertexBuffer*>(_buff) != NULL) {
// MT5's DirectX.
Expand All @@ -165,15 +170,10 @@ class Device : public Dynamic {
return _buff;
}

/**
* Creates vertex buffer to be used by current graphics device.
*/
virtual VertexBuffer* VertexBuffer() = NULL;

/**
* Creates index buffer to be used by current graphics device.
*/
virtual IndexBuffer* IndexBuffer(unsigned int& _indices[]) = NULL;
virtual IndexBuffer* CreateIndexBuffer(unsigned int& _indices[]) = 0;

/**
* Renders vertex buffer with optional point indices.
Expand All @@ -183,7 +183,7 @@ class Device : public Dynamic {
/**
* Renders vertex buffer with optional point indices.
*/
virtual void RenderBuffers(VertexBuffer* _vertices, IndexBuffer* _indices = NULL) = NULL;
virtual void RenderBuffers(VertexBuffer* _vertices, IndexBuffer* _indices = NULL) = 0;

/**
* Renders given mesh.
Expand Down Expand Up @@ -233,6 +233,11 @@ class Device : public Dynamic {
int Height() { return frontend.Ptr().Height(); }

void SetCameraOrtho3D(float _pos_x = 0.0f, float _pos_y = 0.0f, float _pos_z = 0.0f) {
if (Width() <= 0 || Height() <= 0) {
Print("Cannot set 2D camera as width or height of the viewport is zero!");
DebugBreak();
return;
}
DXMatrixOrthoLH(mtx_projection, 1.0f * _pos_z, 1.0f / Width() * Height() * _pos_z, -10000, 10000);
}

Expand Down
14 changes: 5 additions & 9 deletions 3D/Devices/MTDX/MTDXDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,11 @@ class MTDXDevice : public Device {
}
}

/**
* Creates index buffer to be used by current graphics device.
*/
IndexBuffer* IndexBuffer() { return NULL; }

/**
* Creates vertex shader to be used by current graphics device.
*/
virtual Shader* VertexShader(string _source_code, const ShaderVertexLayout& _layout[], string _entry_point = "main") {
Shader* CreateVertexShader(string _source_code, const ShaderVertexLayout& _layout[],
string _entry_point = "main") override {
MTDXShader* _shader = new MTDXShader(&this);
_shader.Create(SHADER_TYPE_VS, _source_code, _entry_point);
_shader.SetDataLayout(_layout);
Expand All @@ -111,7 +107,7 @@ class MTDXDevice : public Device {
/**
* Creates pixel shader to be used by current graphics device.
*/
virtual Shader* PixelShader(string _source_code, string _entry_point = "main") {
Shader* CreatePixelShader(string _source_code, string _entry_point = "main") override {
MTDXShader* _shader = new MTDXShader(&this);
_shader.Create(SHADER_TYPE_PS, _source_code, _entry_point);
return _shader;
Expand All @@ -120,12 +116,12 @@ class MTDXDevice : public Device {
/**
* Creates vertex buffer to be used by current graphics device.
*/
VertexBuffer* VertexBuffer() { return new MTDXVertexBuffer(&this); }
VertexBuffer* CreateVertexBuffer() override { return new MTDXVertexBuffer(&this); }

/**
* Creates index buffer to be used by current graphics device.
*/
virtual IndexBuffer* IndexBuffer(unsigned int& _indices[]) {
IndexBuffer* CreateIndexBuffer(unsigned int& _indices[]) override {
IndexBuffer* _buffer = new MTDXIndexBuffer(&this);
_buffer.Fill(_indices);
return _buffer;
Expand Down
4 changes: 2 additions & 2 deletions 3D/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ class Mesh : public Dynamic {
Print("Indices: ", _s_indices);
#endif

vbuff = _vbuff = _device.VertexBuffer<T>(_vertices);
ibuff = _ibuff = _device.IndexBuffer(_indices);
vbuff = _vbuff = _device.CreateVertexBuffer<T>(_vertices);
ibuff = _ibuff = _device.CreateIndexBuffer(_indices);
return true;
}
};
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 @@ -386,23 +386,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 @@ -309,8 +309,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
Loading

0 comments on commit 52c8fcc

Please sign in to comment.