Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v3.003-dev' into v3.006-dev-new
Browse files Browse the repository at this point in the history
* origin/v3.003-dev: (93 commits)
  Cherry-pick: Added SerializeStub() method to Chart class. Added more error checks. (#629)
  IndicatorData: IndicatorDataEntryValue: Adds support for datetime type
  Merge remote-tracking branch 'origin/dev-indi-no-chart4' into v3.003-dev
  IndicatorData: IndicatorDataEntryValue: Adds support for datetime type
  Merge tag 'v3.001' into dev-indi-no-chart4
  Strategy/Trade: Reenables previously disabled code
  IndicatorsTest: Disables Indi_Price for MQL4 due to failure
  GHA: Sets BtYears to 2021
  Strategy/Trade: Reenables previously disabled code
  IndicatorsTest: Reenables more indicators for testing
  IndicatorsTest: Reenables indicators for testing
  Trade: Reenables CalcLotSize()
  Indi_ZigZag: Fixes indicator path for MQL4
  GHA: Test: Sets BtDays to 4-8 to avoid time limits
  Merge tag 'v3.000' into dev-indi-no-chart4
  Indicators: Fixes potential issues with OnIndicator mode
  Indi_AppliedPrice: Fixes infinite loop when run on indicator
  Indi_Ichimoku: Shift 2nd and 3rd buffer by senkou_span_shift bars [GH-656]
  Indicator: GetEntryAlter: Fixes issue with shift
  GHA: Changes back BtDays to 4-8
  ...
  • Loading branch information
kenorb committed Apr 29, 2024
2 parents f28c6f7 + aa368d3 commit 5b9c843
Show file tree
Hide file tree
Showing 252 changed files with 7,761 additions and 6,716 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-buffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
uses: fx31337/mql-tester-action@master
with:
Script: ${{ matrix.test }}
RunOnError: show_logs 200
timeout-minutes: 10

cleanup:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test-indicator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ jobs:
with:
BtDays: 4-8
BtMonths: 1
BtYears: 2020
BtYears: 2021
MtVersion: 4.0.0.1359
RunOnError: show_logs 200
TestExpert: ${{ matrix.test }}
timeout-minutes: 10

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test-indicators-special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ jobs:
with:
BtDays: 4-8
BtMonths: 1
BtYears: 2020
BtYears: 2021
MtVersion: 4.0.0.1359
RunOnError: show_logs 200
TestExpert: ${{ matrix.test }}
timeout-minutes: 10

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test-indicators-tick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ jobs:
with:
BtDays: 4-8
BtMonths: 1
BtYears: 2020
BtYears: 2021
MtVersion: 4.0.0.1359
RunOnError: show_logs 200
TestExpert: ${{ matrix.test }}
timeout-minutes: 10

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test-indicators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- Indi_CCI.test
- Indi_CHO.test
- Indi_CHV.test
- Indi_ColorBars.test
# - Indi_ColorBars.test # @fixme
- Indi_ColorCandlesDaily.test
- Indi_ColorLine.test
- Indi_CustomMovingAverage.test
Expand Down Expand Up @@ -110,7 +110,9 @@ jobs:
with:
BtDays: 4-8
BtMonths: 1
BtYears: 2020
BtYears: 2021
MtVersion: 4.0.0.1359
RunOnError: show_logs 200
TestExpert: ${{ matrix.test }}
timeout-minutes: 10

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ jobs:
uses: fx31337/mql-tester-action@master
with:
Script: ${{ matrix.test }}
RunOnError: show_logs 200
1 change: 1 addition & 0 deletions .github/workflows/test-trade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
uses: fx31337/mql-tester-action@master
with:
Script: ${{ matrix.test }}
RunOnError: show_logs 200
timeout-minutes: 10

cleanup:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ jobs:
strategy:
matrix:
test:
- AccountTest
- BufferStructTest
- BufferTest
- ChartTest
- CompileIndicatorsTest
- DatabaseTest
# - DrawIndicatorTest
- EATest
- IndicatorDataTest
- IndicatorTest
- IndicatorsTest
- MailTest
Expand All @@ -69,11 +67,12 @@ jobs:
- name: Run ${{ matrix.test }}
uses: fx31337/mql-tester-action@master
with:
BtDays: 1-8
BtDays: 4-12
BtMonths: 1
BtYears: 2020
BtYears: 2021
Version: 4
TestExpert: ${{ matrix.test }}
RunOnError: show_logs 200
timeout-minutes: 10

Scripts-MQL4:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.associations": {
"indicatorcandle.h": "c"
"indicatorcandle.h": "c",
"*.mqh": "c"
}
}
17 changes: 8 additions & 9 deletions 3D/Chart3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include "../Bar.struct.h"
#include "../IndicatorData.mqh"
#include "../Indicators/Indi_MA.mqh"
#include "../Instances.h"
#include "../Refs.mqh"
Expand Down Expand Up @@ -72,9 +73,6 @@ class Chart3D : public Dynamic {
// References to chart type renderers.
Ref<Chart3DType> renderers[3];

// OHLC prices fetcher callback.
Chart3DPriceFetcher price_fetcher;

// Whether graphics were initialized.
bool initialized;

Expand All @@ -85,17 +83,18 @@ class Chart3D : public Dynamic {
Chart3DType* current_renderer;

Instances<Chart3D> instances;
Ref<IndicatorData> source;

public:
/**
* Constructor.
*/
Chart3D(Chart3DPriceFetcher _price_fetcher, ENUM_CHART3D_TYPE _type = CHART3D_TYPE_CANDLES) : instances(&this) {
price_fetcher = _price_fetcher;
Chart3D(IndicatorData* _source, ENUM_CHART3D_TYPE _type = CHART3D_TYPE_CANDLES) : instances(&this) {
type = _type;
offset.x = offset.y = 0.0f;
offset.z = 25.0f;
initialized = false;
source = _source;
#ifdef __MQL5__
Interface::AddListener(chart3d_interface_listener, &this);
#endif
Expand Down Expand Up @@ -172,8 +171,8 @@ class Chart3D : public Dynamic {
float GetMinBarsPrice() {
return (float)ChartStatic::iLow(
Symbol(), PERIOD_CURRENT,
ChartStatic::iLowest(Symbol(), PERIOD_CURRENT, MODE_LOW, GetBarsVisibleShiftStart() - GetBarsVisibleShiftEnd(),
GetBarsVisibleShiftEnd()));
source REF_DEREF GetLowest(MODE_LOW, GetBarsVisibleShiftStart() - GetBarsVisibleShiftEnd(),
GetBarsVisibleShiftEnd()));
}

/**
Expand All @@ -182,8 +181,8 @@ class Chart3D : public Dynamic {
float GetMaxBarsPrice() {
return (float)ChartStatic::iHigh(
Symbol(), PERIOD_CURRENT,
ChartStatic::iHighest(Symbol(), PERIOD_CURRENT, MODE_HIGH,
GetBarsVisibleShiftStart() - GetBarsVisibleShiftEnd(), GetBarsVisibleShiftEnd()));
source REF_DEREF GetHighest(MODE_HIGH, GetBarsVisibleShiftStart() - GetBarsVisibleShiftEnd(),
GetBarsVisibleShiftEnd()));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions 3D/Chart3DCandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class Chart3DCandles : public Chart3DType {
for (int _shift = chart3d.GetBarsVisibleShiftStart(); _shift != chart3d.GetBarsVisibleShiftEnd(); --_shift) {
BarOHLC _ohlc = chart3d.GetPrice(PERIOD_CURRENT, _shift);

float _height = chart3d.GetPriceScale(_ohlc.GetMaxOC()) - chart3d.GetPriceScale(_ohlc.GetMinOC());
float _height = chart3d.GetPriceScale((float)_ohlc.GetMaxOC()) - chart3d.GetPriceScale((float)_ohlc.GetMinOC());
float higher = _ohlc.IsBear();

cube1.Ptr().GetTSR().translation.x = chart3d.GetBarPositionX(_shift);
cube1.Ptr().GetTSR().translation.y = chart3d.GetPriceScale(_ohlc.GetMinOC()) + _height / 2;
cube1.Ptr().GetTSR().translation.y = chart3d.GetPriceScale((float)_ohlc.GetMinOC()) + _height / 2;
cube1.Ptr().GetTSR().scale.y = _height;

// Print(cube1.Ptr().GetTSR().translation.y);
Expand All @@ -72,8 +72,8 @@ class Chart3DCandles : public Chart3DType {
_device.Render(cube1.Ptr());

cube2.Ptr().GetTSR().translation.x = chart3d.GetBarPositionX(_shift);
float _line_height = chart3d.GetPriceScale(_ohlc.GetHigh()) - chart3d.GetPriceScale(_ohlc.GetLow());
cube2.Ptr().GetTSR().translation.y = chart3d.GetPriceScale(_ohlc.GetLow()) + _line_height / 2;
float _line_height = chart3d.GetPriceScale((float)_ohlc.GetHigh()) - chart3d.GetPriceScale((float)_ohlc.GetLow());
cube2.Ptr().GetTSR().translation.y = chart3d.GetPriceScale((float)_ohlc.GetLow()) + _line_height / 2;
cube2.Ptr().GetTSR().scale.y = _line_height;
cube2.Ptr().GetMaterial().SetColor(higher ? 0x22FF11 : 0xFF1122);
_device.Render(cube2.Ptr());
Expand Down
3 changes: 2 additions & 1 deletion Account/AccountBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@

// Includes.
//#include "../Serializer.mqh"
#include "../Refs.mqh"
#include "AccountBase.struct.h"

/**
* Class to provide functions that return parameters of the current account.
*/
class AccountBase {
class AccountBase : public Dynamic {
protected:
/**
* Init code (called on constructor).
Expand Down
40 changes: 0 additions & 40 deletions Account/AccountMt.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,46 +317,6 @@ class AccountMt {
*/
static string GetType() { return AccountMt::GetServerName() != "" ? (IsDemo() ? "Demo" : "Live") : "Off-line"; }

/* Setters */

double UpdateStats(ENUM_ACC_STAT_VALUE _type, double _value) {
static datetime _last_check = TimeCurrent();
bool _stats_rotate = false;
int _tindex = (int)_type;
for (unsigned int _pindex = 0; _pindex < FINAL_ENUM_ACC_STAT_PERIOD; _pindex++) {
acc_stats[_tindex][_pindex][(int)ACC_VALUE_MIN][(int)ACC_VALUE_CURR] =
fmin(acc_stats[_tindex][_pindex][(int)ACC_VALUE_MIN][(int)ACC_VALUE_CURR], _value);
acc_stats[_tindex][_pindex][(int)ACC_VALUE_MAX][(int)ACC_VALUE_CURR] =
fmin(acc_stats[_tindex][_pindex][(int)ACC_VALUE_MAX][(int)ACC_VALUE_CURR], _value);
acc_stats[_tindex][_pindex][(int)ACC_VALUE_AVG][(int)ACC_VALUE_CURR] =
(acc_stats[_tindex][_pindex][(int)ACC_VALUE_AVG][(int)ACC_VALUE_CURR] + _value) / 2;
switch (_pindex) {
case ACC_DAILY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_D1);
break;
case ACC_WEEKLY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_W1);
break;
case ACC_MONTHLY:
_stats_rotate = _last_check < ChartStatic::iTime(_Symbol, PERIOD_MN1);
break;
}
if (_stats_rotate) {
acc_stats[_tindex][_pindex][(int)ACC_VALUE_MIN][(int)ACC_VALUE_PREV] =
acc_stats[_tindex][_pindex][(int)ACC_VALUE_MIN][(int)ACC_VALUE_CURR];
acc_stats[_tindex][_pindex][(int)ACC_VALUE_MAX][(int)ACC_VALUE_PREV] =
acc_stats[_tindex][_pindex][(int)ACC_VALUE_MAX][(int)ACC_VALUE_CURR];
acc_stats[_tindex][_pindex][(int)ACC_VALUE_AVG][(int)ACC_VALUE_PREV] =
acc_stats[_tindex][_pindex][(int)ACC_VALUE_AVG][(int)ACC_VALUE_CURR];
acc_stats[_tindex][_pindex][(int)ACC_VALUE_MIN][(int)ACC_VALUE_CURR] = _value;
acc_stats[_tindex][_pindex][(int)ACC_VALUE_MAX][(int)ACC_VALUE_CURR] = _value;
acc_stats[_tindex][_pindex][(int)ACC_VALUE_AVG][(int)ACC_VALUE_CURR] = _value;
_last_check = TimeCurrent();
}
}
return _value;
}

/* Class getters */

/**
Expand Down
3 changes: 3 additions & 0 deletions Array.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,9 @@ template <typename X>
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);
} else if (_idx < 0) {
Print("_idx cannot be negative! " + IntegerToString(_idx) + " passed.");
DebugBreak();
}

array[_idx] = value;
Expand Down
Loading

0 comments on commit 5b9c843

Please sign in to comment.