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 28, 2024
2 parents f28c6f7 + aa368d3 commit a1ad4a0
Show file tree
Hide file tree
Showing 229 changed files with 6,283 additions and 4,917 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
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
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
98 changes: 50 additions & 48 deletions Bar.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ struct BarOHLC
#endif
{
datetime time;
float open, high, low, close;
double open, high, low, close;
// Struct constructor.
BarOHLC() : open(0), high(0), low(0), close(0), time(0){};
BarOHLC(float _open, float _high, float _low, float _close, datetime _time = 0)
BarOHLC(double _open, double _high, double _low, double _close, datetime _time = 0)
: time(_time), open(_open), high(_high), low(_low), close(_close) {
if (_time == 0) {
_time = TimeCurrent();
}
}
BarOHLC(ARRAY_REF(float, _prices), datetime _time = 0) : time(_time) {
BarOHLC(ARRAY_REF(double, _prices), datetime _time = 0) : time(_time) {
_time = _time == 0 ? TimeCurrent() : _time;
int _size = ArraySize(_prices);
close = _prices[0];
Expand All @@ -71,21 +71,21 @@ struct BarOHLC
}
// Struct methods.
// Getters
bool GetPivots(ENUM_PP_TYPE _type, float &_pp, float &_r1, float &_r2, float &_r3, float &_r4, float &_s1, float &_s2,
float &_s3, float &_s4) {
float _range = GetRange();
bool GetPivots(ENUM_PP_TYPE _type, double &_pp, double &_r1, double &_r2, double &_r3, double &_r4, double &_s1,
double &_s2, double &_s3, double &_s4) {
double _range = GetRange();
switch (_type) {
case PP_CAMARILLA:
// A set of eight very probable levels which resemble support and resistance values for a current trend.
_pp = GetPivot();
_r1 = (float)(close + _range * 1.1 / 12);
_r2 = (float)(close + _range * 1.1 / 6);
_r3 = (float)(close + _range * 1.1 / 4);
_r4 = (float)(close + _range * 1.1 / 2);
_s1 = (float)(close - _range * 1.1 / 12);
_s2 = (float)(close - _range * 1.1 / 6);
_s3 = (float)(close - _range * 1.1 / 4);
_s4 = (float)(close - _range * 1.1 / 2);
_r1 = (double)(close + _range * 1.1 / 12);
_r2 = (double)(close + _range * 1.1 / 6);
_r3 = (double)(close + _range * 1.1 / 4);
_r4 = (double)(close + _range * 1.1 / 2);
_s1 = (double)(close - _range * 1.1 / 12);
_s2 = (double)(close - _range * 1.1 / 6);
_s3 = (double)(close - _range * 1.1 / 4);
_s4 = (double)(close - _range * 1.1 / 2);
break;
case PP_CLASSIC:
_pp = GetPivot();
Expand All @@ -100,12 +100,12 @@ struct BarOHLC
break;
case PP_FIBONACCI:
_pp = GetPivot();
_r1 = (float)(_pp + 0.382 * _range);
_r2 = (float)(_pp + 0.618 * _range);
_r1 = (double)(_pp + 0.382 * _range);
_r2 = (double)(_pp + 0.618 * _range);
_r3 = _pp + _range;
_r4 = _r1 + _range; // ?
_s1 = (float)(_pp - 0.382 * _range);
_s2 = (float)(_pp - 0.618 * _range);
_s1 = (double)(_pp - 0.382 * _range);
_s2 = (double)(_pp - 0.618 * _range);
_s3 = _pp - _range;
_s4 = _s1 - _range; // ?
break;
Expand Down Expand Up @@ -152,44 +152,46 @@ struct BarOHLC
return _r4 > _r3 && _r3 > _r2 && _r2 > _r1 && _r1 > _pp && _pp > _s1 && _s1 > _s2 && _s2 > _s3 && _s3 > _s4;
}
datetime GetTime() { return time; }
float GetAppliedPrice(ENUM_APPLIED_PRICE _ap) const { return BarOHLC::GetAppliedPrice(_ap, open, high, low, close); }
float GetBody() const { return close - open; }
float GetBodyAbs() const { return fabs(close - open); }
float GetBodyInPct(int _hundreds = 100) const { return GetRange() > 0 ? _hundreds / GetRange() * GetBodyAbs() : 0; }
float GetChangeInPct(int _hundreds = 100) const { return (close - open) / open * _hundreds; }
float GetClose() const { return close; }
float GetHigh() const { return high; }
float GetLow() const { return low; }
float GetMaxOC() const { return fmax(open, close); }
float GetMedian() const { return (high + low) / 2; }
float GetMinOC() const { return fmin(open, close); }
float GetOpen() const { return open; }
float GetPivot() const { return GetTypical(); }
float GetPivotDeMark() const {
double GetAppliedPrice(ENUM_APPLIED_PRICE _ap) const { return BarOHLC::GetAppliedPrice(_ap, open, high, low, close); }
double GetBody() const { return close - open; }
double GetBodyAbs() const { return fabs(close - open); }
double GetBodyInPct(int _hundreds = 100) const { return GetRange() > 0 ? _hundreds / GetRange() * GetBodyAbs() : 0; }
double GetChangeInPct(int _hundreds = 100) const {
return open > 0 ? ((close - open) / open * _hundreds) : 0 /* Error */;
}
double GetClose() const { return close; }
double GetHigh() const { return high; }
double GetLow() const { return low; }
double GetMaxOC() const { return fmax(open, close); }
double GetMedian() const { return (high + low) / 2; }
double GetMinOC() const { return fmin(open, close); }
double GetOpen() const { return open; }
double GetPivot() const { return GetTypical(); }
double GetPivotDeMark() const {
// If Close < Open Then X = H + 2 * L + C
// If Close > Open Then X = 2 * H + L + C
// If Close = Open Then X = H + L + 2 * C
float _pp = open > close ? (high + (2 * low) + close) / 4 : ((2 * high) + low + close) / 4;
double _pp = open > close ? (high + (2 * low) + close) / 4 : ((2 * high) + low + close) / 4;
return open == close ? (high + low + (2 * close)) / 4 : _pp;
}
float GetPivotWithOpen() const { return (open + high + low + close) / 4; }
float GetPivotWithOpen(float _open) const { return (_open + high + low + close) / 4; }
float GetRange() const { return high - low; }
float GetRangeChangeInPct(int _hundreds = 100) const {
double GetPivotWithOpen() const { return (open + high + low + close) / 4; }
double GetPivotWithOpen(double _open) const { return (_open + high + low + close) / 4; }
double GetRange() const { return high - low; }
double GetRangeChangeInPct(int _hundreds = 100) const {
return _hundreds - (_hundreds / open * fabs(open - GetRange()));
}
float GetRangeInPips(float _ppp) const { return GetRange() / _ppp; }
float GetTypical() const { return (high + low + close) / 3; }
float GetWeighted() const { return (high + low + close + close) / 4; }
float GetWickMin() const { return fmin(GetWickLower(), GetWickUpper()); }
float GetWickLower() const { return GetMinOC() - low; }
float GetWickLowerInPct() const { return GetRange() > 0 ? 100 / GetRange() * GetWickLower() : 0; }
float GetWickMax() const { return fmax(GetWickLower(), GetWickUpper()); }
float GetWickSum() const { return GetWickLower() + GetWickUpper(); }
float GetWickUpper() const { return high - GetMaxOC(); }
float GetWickUpperInPct() const { return GetRange() > 0 ? 100 / GetRange() * GetWickUpper() : 0; }
double GetRangeInPips(double _ppp) const { return GetRange() / _ppp; }
double GetTypical() const { return (high + low + close) / 3; }
double GetWeighted() const { return (high + low + close + close) / 4; }
double GetWickMin() const { return fmin(GetWickLower(), GetWickUpper()); }
double GetWickLower() const { return GetMinOC() - low; }
double GetWickLowerInPct() const { return GetRange() > 0 ? 100 / GetRange() * GetWickLower() : 0; }
double GetWickMax() const { return fmax(GetWickLower(), GetWickUpper()); }
double GetWickSum() const { return GetWickLower() + GetWickUpper(); }
double GetWickUpper() const { return high - GetMaxOC(); }
double GetWickUpperInPct() const { return GetRange() > 0 ? 100 / GetRange() * GetWickUpper() : 0; }
short GetType() const { return IsBull() ? 1 : (IsBear() ? -1 : 0); }
void GetValues(ARRAY_REF(float, _out)) {
void GetValues(ARRAY_REF(double, _out)) {
ArrayResize(_out, 4);
int _index = ArraySize(_out) - 4;
_out[_index++] = open;
Expand Down
1 change: 0 additions & 1 deletion Buffer/BufferCandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
*/
template <typename TV>
class BufferCandle : public BufferStruct<CandleOCTOHLC<TV>> {
protected:
protected:
/* Protected methods */

Expand Down
Loading

0 comments on commit a1ad4a0

Please sign in to comment.