Skip to content

Commit

Permalink
Got rid of u(char, int, long)s so we have `unsigned (char, int, lon…
Browse files Browse the repository at this point in the history
…g)`s
  • Loading branch information
nseam committed Feb 18, 2022
1 parent ee5037b commit bb36286
Show file tree
Hide file tree
Showing 43 changed files with 337 additions and 327 deletions.
12 changes: 6 additions & 6 deletions 3D/Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ struct DXQuaternion {
//| DViewport |
//+------------------------------------------------------------------+
struct DViewport {
ulong x;
ulong y;
ulong width;
ulong height;
unsigned long x;
unsigned long y;
unsigned long width;
unsigned long height;
float minz;
float maxz;
};
Expand Down Expand Up @@ -2336,7 +2336,7 @@ float DXSHDot(int order, const float &a[], const float &b[]) {
//+------------------------------------------------------------------+
//| weightedcapintegrale |
//+------------------------------------------------------------------+
void weightedcapintegrale(float &out[], uint order, float angle) {
void weightedcapintegrale(float &out[], unsigned int order, float angle) {
float coeff[3];
coeff[0] = (float)cos(angle);

Expand Down Expand Up @@ -3031,7 +3031,7 @@ void DXSHMultiply4(float &out[], const float &a[], const float &b[]) {
//+------------------------------------------------------------------+
//| rotate_X |
//+------------------------------------------------------------------+
void rotate_X(float &out[], uint order, float a, float &in[]) {
void rotate_X(float &out[], unsigned int order, float a, float &in[]) {
out[0] = in[0];
out[1] = a * in[2];
out[2] = -a * in[1];
Expand Down
4 changes: 2 additions & 2 deletions Account.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class Account {
* Returns the limit orders (0 for unlimited).
*/
static long AccountLimitOrders() { return AccountInfoInteger(ACCOUNT_LIMIT_ORDERS); }
long GetLimitOrders(uint _max = 999) {
long GetLimitOrders(unsigned int _max = 999) {
long _limit = AccountLimitOrders();
return _limit > 0 ? _limit : _max;
}
Expand Down Expand Up @@ -322,7 +322,7 @@ class Account {
double UpdateStats(ENUM_ACC_STAT_VALUE _type, double _value) {
static datetime _last_check = TimeCurrent();
bool _stats_rotate = false;
for (uint _pindex = 0; _pindex < FINAL_ENUM_ACC_STAT_PERIOD; _pindex++) {
for (unsigned int _pindex = 0; _pindex < FINAL_ENUM_ACC_STAT_PERIOD; _pindex++) {
acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR] =
fmin(acc_stats[_type][_pindex][ACC_VALUE_MIN][ACC_VALUE_CURR], _value);
acc_stats[_type][_pindex][ACC_VALUE_MAX][ACC_VALUE_CURR] =
Expand Down
6 changes: 3 additions & 3 deletions Buffer/BufferTick.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ class BufferTick : public BufferStruct<TickAB<TV>> {
/**
* Group ticks by seconds.
*/
DictStruct<uint, DictStruct<uint, TickAB<TV>>> GroupBySecs(uint _spc) {
// DictStruct<uint, DictStruct<TickAB<TV>>> _result;
DictStruct<unsigned int, DictStruct<unsigned int, TickAB<TV>>> GroupBySecs(unsigned int _spc) {
// DictStruct<unsigned int, DictStruct<TickAB<TV>>> _result;
// @todo: for each iter
// for (DictStructIterator<uint, DictStruct<TickAB<TV>>> iter(Begin()); iter.IsValid(); ++iter) {
// for (DictStructIterator<unsigned int, DictStruct<TickAB<TV>>> iter(Begin()); iter.IsValid(); ++iter) {
// Load timestamp from key, TickAB from value
// foreach some timestamp mod % _spc - calculate shift
// _result.Push(_shift, TickAB<TV>)
Expand Down
38 changes: 23 additions & 15 deletions Chart.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class Chart : public Market {
*
* @param
* _tf ENUM_TIMEFRAMES Timeframe to use.
* _shift uint _shift Shift to use.
* _shift unsigned int _shift Shift to use.
* _symbol string Symbol to use.
*
* @return
Expand All @@ -219,7 +219,7 @@ class Chart : public Market {
* Gets chart entry.
*
* @param
* _shift uint _shift Shift to use.
* _shift unsigned int _shift Shift to use.
*
* @return
* Returns ChartEntry struct.
Expand Down Expand Up @@ -287,7 +287,7 @@ class Chart : public Market {
/* Timeseries */
/* @see: https://docs.mql4.com/series */

datetime GetBarTime(ENUM_TIMEFRAMES _tf, uint _shift = 0) { return ChartStatic::iTime(symbol, _tf, _shift); }
datetime GetBarTime(ENUM_TIMEFRAMES _tf, unsigned int _shift = 0) { return ChartStatic::iTime(symbol, _tf, _shift); }
datetime GetBarTime(unsigned int _shift = 0) {
return ChartStatic::iTime(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift);
}
Expand All @@ -298,8 +298,10 @@ class Chart : public Market {
*
* If local history is empty (not loaded), function returns 0.
*/
double GetOpen(ENUM_TIMEFRAMES _tf, uint _shift = 0) { return ChartStatic::iOpen(symbol, _tf, _shift); }
double GetOpen(uint _shift = 0) { return ChartStatic::iOpen(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift); }
double GetOpen(ENUM_TIMEFRAMES _tf, unsigned int _shift = 0) { return ChartStatic::iOpen(symbol, _tf, _shift); }
double GetOpen(unsigned int _shift = 0) {
return ChartStatic::iOpen(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift);
}

/**
* Returns close price value for the bar of indicated symbol.
Expand All @@ -316,16 +318,20 @@ class Chart : public Market {
*
* If local history is empty (not loaded), function returns 0.
*/
double GetLow(ENUM_TIMEFRAMES _tf, uint _shift = 0) { return ChartStatic::iLow(symbol, _tf, _shift); }
double GetLow(uint _shift = 0) { return ChartStatic::iLow(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift); }
double GetLow(ENUM_TIMEFRAMES _tf, unsigned int _shift = 0) { return ChartStatic::iLow(symbol, _tf, _shift); }
double GetLow(unsigned int _shift = 0) {
return ChartStatic::iLow(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift);
}

/**
* Returns low price value for the bar of indicated symbol.
*
* If local history is empty (not loaded), function returns 0.
*/
double GetHigh(ENUM_TIMEFRAMES _tf, uint _shift = 0) { return ChartStatic::iHigh(symbol, _tf, _shift); }
double GetHigh(uint _shift = 0) { return ChartStatic::iHigh(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift); }
double GetHigh(ENUM_TIMEFRAMES _tf, unsigned int _shift = 0) { return ChartStatic::iHigh(symbol, _tf, _shift); }
double GetHigh(unsigned int _shift = 0) {
return ChartStatic::iHigh(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift);
}

/**
* Returns the current price value given applied price type.
Expand All @@ -339,8 +345,10 @@ class Chart : public Market {
*
* If local history is empty (not loaded), function returns 0.
*/
long GetVolume(ENUM_TIMEFRAMES _tf, uint _shift = 0) { return ChartStatic::iVolume(symbol, _tf, _shift); }
long GetVolume(uint _shift = 0) { return ChartStatic::iVolume(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift); }
long GetVolume(ENUM_TIMEFRAMES _tf, unsigned int _shift = 0) { return ChartStatic::iVolume(symbol, _tf, _shift); }
long GetVolume(unsigned int _shift = 0) {
return ChartStatic::iVolume(symbol, Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift);
}

/**
* Returns the shift of the maximum value over a specific number of periods depending on type.
Expand Down Expand Up @@ -849,7 +857,7 @@ class Chart : public Market {
*/
bool SaveChartEntry() {
// @todo: Use MqlRates.
uint _last = ArraySize(chart_saves);
unsigned int _last = ArraySize(chart_saves);
if (ArrayResize(chart_saves, _last + 1, 100)) {
chart_saves[_last].bar.ohlc.time = ChartStatic::iTime();
chart_saves[_last].bar.ohlc.open = (float)Chart::GetOpen();
Expand All @@ -866,16 +874,16 @@ class Chart : public Market {
* Load stored BarOHLC values.
*
* @param
* _index uint Index of the element in BarOHLC array.
* _index unsigned int Index of the element in BarOHLC array.
* @return
* Returns BarOHLC struct element.
*/
ChartEntry LoadChartEntry(uint _index = 0) { return chart_saves[_index]; }
ChartEntry LoadChartEntry(unsigned int _index = 0) { return chart_saves[_index]; }

/**
* Return size of BarOHLC array.
*/
ulong SizeChartEntry() { return ArraySize(chart_saves); }
unsigned long SizeChartEntry() { return ArraySize(chart_saves); }

/* Serializers */

Expand Down
10 changes: 5 additions & 5 deletions Chart.struct.static.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct ChartStatic {
*
* If local history is empty (not loaded), function returns 0.
*/
static double iHigh(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, uint _shift = 0) {
static double iHigh(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, unsigned int _shift = 0) {
#ifdef __MQL4__
return ::iHigh(_symbol, _tf, _shift); // Same as: High[_shift]
#else // __MQL5__
Expand All @@ -103,7 +103,7 @@ struct ChartStatic {
* Returns the shift of the maximum value over a specific number of periods depending on type.
*/
static int iHighest(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, int _type = MODE_HIGH,
uint _count = WHOLE_ARRAY, int _start = 0) {
unsigned int _count = WHOLE_ARRAY, int _start = 0) {
#ifdef __MQL4__
return ::iHighest(_symbol, _tf, _type, _count, _start);
#else // __MQL5__
Expand Down Expand Up @@ -146,7 +146,7 @@ struct ChartStatic {
*
* If local history is empty (not loaded), function returns 0.
*/
static double iLow(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, uint _shift = 0) {
static double iLow(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, unsigned int _shift = 0) {
#ifdef __MQL4__
return ::iLow(_symbol, _tf, _shift); // Same as: Low[_shift]
#else // __MQL5__
Expand Down Expand Up @@ -203,7 +203,7 @@ struct ChartStatic {
*
* If local history is empty (not loaded), function returns 0.
*/
static double iOpen(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, uint _shift = 0) {
static double iOpen(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, unsigned int _shift = 0) {
#ifdef __MQL4__
return ::iOpen(_symbol, _tf, _shift); // Same as: Open[_shift]
#else // __MQL5__
Expand Down Expand Up @@ -261,7 +261,7 @@ struct ChartStatic {
*
* If local history is empty (not loaded), function returns 0.
*/
static datetime iTime(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, uint _shift = 0) {
static datetime iTime(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, unsigned int _shift = 0) {
#ifdef __MQL4__
return ::iTime(_symbol, _tf, _shift); // Same as: Time[_shift]
#else // __MQL5__
Expand Down
2 changes: 1 addition & 1 deletion Chart.struct.tf.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ struct ChartTf {
* @return ENUM_TIMEFRAMES
* Returns enum representing chart's timeframe value.
*/
static ENUM_TIMEFRAMES SecsToTf(uint _secs = 0) {
static ENUM_TIMEFRAMES SecsToTf(unsigned int _secs = 0) {
switch (_secs) {
case 0:
return PERIOD_CURRENT;
Expand Down
4 changes: 0 additions & 4 deletions Common.define.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@
// Data types.
#include <string>
typedef std::string string;
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned short ushort;
#endif
2 changes: 1 addition & 1 deletion Common.extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

extern void DebugBreak();
// Errors.
extern void SetUserError(ushort user_error);
extern void SetUserError(unsigned short user_error);
// Exceptions.
extern int NotImplementedException();
// Print-related functions.
Expand Down
22 changes: 12 additions & 10 deletions Convert.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ class Convert {
/**
* Points per pip given digits after decimal point of a symbol price.
*/
static uint PointsPerPip(uint digits) { return (uint)pow((unsigned int)10, digits - (digits < 4 ? 2 : 4)); }
static unsigned int PointsPerPip(unsigned int digits) {
return (unsigned int)pow((unsigned int)10, digits - (digits < 4 ? 2 : 4));
}

/**
* Returns number of points per pip.
*/
static uint PointsPerPip(string _symbol = NULL) {
return PointsPerPip((uint)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
static unsigned int PointsPerPip(string _symbol = NULL) {
return PointsPerPip((unsigned int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
}

/**
Expand All @@ -134,31 +136,31 @@ class Convert {
* Convert pips into price value.
*/
static double PipsToValue(double pips, string _symbol = NULL) {
return PipsToValue(pips, (uint)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
return PipsToValue(pips, (unsigned int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
}

/**
* Convert value into pips given price value and digits.
*/
static double ValueToPips(double value, uint digits) { return value * pow(10, digits < 4 ? 2 : 4); }
static double ValueToPips(double value, unsigned int digits) { return value * pow(10, digits < 4 ? 2 : 4); }

/**
* Convert value into pips.
*/
static double ValueToPips(double value, string _symbol = NULL) {
return ValueToPips(value, (uint)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
return ValueToPips(value, (unsigned int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
}

/**
* Convert pips into points.
*/
static uint PipsToPoints(double pips, int digits) { return (uint)pips * PointsPerPip(digits); }
static unsigned int PipsToPoints(double pips, int digits) { return (unsigned int)pips * PointsPerPip(digits); }

/**
* Convert pips into points.
*/
static uint PipsToPoints(double pips, string _symbol = NULL) {
return PipsToPoints(pips, (uint)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
static unsigned int PipsToPoints(double pips, string _symbol = NULL) {
return PipsToPoints(pips, (unsigned int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
}

/**
Expand All @@ -170,7 +172,7 @@ class Convert {
* Convert points into pips.
*/
static double PointsToPips(long pts, string _symbol = NULL) {
return PointsToPips(pts, (uint)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
return PointsToPips(pts, (unsigned int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Data.enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ enum ENUM_DATATYPE {
TYPE_LONG, // long
TYPE_SHORT, // short
TYPE_STRING, // string
TYPE_UCHAR, // uchar
TYPE_UINT, // uint
TYPE_ULONG, // ulong
TYPE_USHORT, // ushort
TYPE_UCHAR, // unsigned char
TYPE_UINT, // unsigned int
TYPE_ULONG, // unsigned long
TYPE_USHORT, // unsigned short
};
#endif
Loading

0 comments on commit bb36286

Please sign in to comment.