Updated for RangeBars ver. 3.00
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#property copyright "Copyright 2017, AZ-iNVEST"
|
||||
#property copyright "Copyright 2018-2020, Level Up Software"
|
||||
#property link "http://www.az-invest.eu"
|
||||
#property version "2.02"
|
||||
#property version "3.00"
|
||||
|
||||
input bool UseOnRangeBarChart = true; // Use this indicator on RangeBar chart
|
||||
|
||||
//#define DEVELOPER_VERSION
|
||||
#include <AZ-INVEST/SDK/RangeBars.mqh>
|
||||
|
||||
class RangeBarIndicator
|
||||
@@ -19,8 +20,12 @@ class RangeBarIndicator
|
||||
bool useAppliedPrice;
|
||||
ENUM_APPLIED_PRICE applied_price;
|
||||
|
||||
bool firstRun;
|
||||
bool dataReady;
|
||||
|
||||
datetime prevTime;
|
||||
int prevRatesTotal;
|
||||
|
||||
public:
|
||||
|
||||
datetime Time[];
|
||||
@@ -34,8 +39,21 @@ class RangeBarIndicator
|
||||
double Buy_volume[];
|
||||
double Sell_volume[];
|
||||
double BuySell_volume[];
|
||||
|
||||
datetime GetTime(int index) { return GetArrayValueDateTime(Time, index); };
|
||||
double GetOpen(int index) { return GetArrayValueDouble(Open, index); };
|
||||
double GetLow(int index) { return GetArrayValueDouble(Low, index); };
|
||||
double GetHigh(int index) { return GetArrayValueDouble(High, index); };
|
||||
double GetClose(int index) { return GetArrayValueDouble(Close, index); };
|
||||
double GetPrice(int index) { return GetArrayValueDouble(Price, index); };
|
||||
long GetTick_volume(int index) { return GetArrayValueLong(Tick_volume, index); };
|
||||
long GetReal_volume(int index) { return GetArrayValueLong(Real_volume, index); };
|
||||
double GetBuy_volume(int index) { return GetArrayValueDouble(Buy_volume, index); };
|
||||
double GetSell_volume(int index) { return GetArrayValueDouble(Sell_volume, index); };
|
||||
double GetBuySell_volume(int index) { return GetArrayValueDouble(BuySell_volume, index); };
|
||||
|
||||
bool IsNewBar;
|
||||
|
||||
|
||||
RangeBarIndicator();
|
||||
~RangeBarIndicator();
|
||||
|
||||
@@ -44,8 +62,11 @@ class RangeBarIndicator
|
||||
void SetGetVolumeBreakdownFlag() { this.getVolumeBreakdown = true; };
|
||||
void SetGetTimeFlag() { this.getTime = true; };
|
||||
|
||||
bool OnCalculate(const int rates_total,const int prev_calculated, const datetime &_Time[]);
|
||||
bool OnCalculate(const int _rates_total,const int _prev_calculated, const datetime &_Time[], const double &_Close[]);
|
||||
void OnDeinit(const int reason);
|
||||
bool BufferSynchronizationCheck(const double &buffer[]);
|
||||
int GetPrevCalculated() { return prev_calculated; };
|
||||
int GetRatesTotal() { return ArraySize(Open); };
|
||||
void BufferShiftLeft(double &buffer[]);
|
||||
|
||||
private:
|
||||
@@ -67,6 +88,9 @@ class RangeBarIndicator
|
||||
|
||||
ENUM_TIMEFRAMES TFMigrate(int tf);
|
||||
datetime iTime(string symbol,int tf,int index);
|
||||
double GetArrayValueDouble(double &arr[], int index);
|
||||
long GetArrayValueLong(long &arr[], int index);
|
||||
datetime GetArrayValueDateTime(datetime &arr[], int index);
|
||||
};
|
||||
|
||||
RangeBarIndicator::RangeBarIndicator(void)
|
||||
@@ -80,6 +104,9 @@ RangeBarIndicator::RangeBarIndicator(void)
|
||||
getTime = false;
|
||||
|
||||
dataReady = false;
|
||||
firstRun = true;
|
||||
prevTime = 0;
|
||||
prevRatesTotal = 0;
|
||||
}
|
||||
|
||||
RangeBarIndicator::~RangeBarIndicator(void)
|
||||
@@ -112,10 +139,8 @@ bool RangeBarIndicator::NeedsReload(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RangeBarIndicator::OnCalculate(const int _rates_total,const int _prev_calculated, const datetime &_Time[])
|
||||
bool RangeBarIndicator::OnCalculate(const int _rates_total,const int _prev_calculated, const datetime &_Time[], const double &_Close[])
|
||||
{
|
||||
static bool firstRun = true;
|
||||
|
||||
if(firstRun)
|
||||
{
|
||||
Canvas_IsNewBar(_Time);
|
||||
@@ -153,36 +178,25 @@ bool RangeBarIndicator::OnCalculate(const int _rates_total,const int _prev_calcu
|
||||
{
|
||||
GetOLHC(0,_rates_total);
|
||||
firstRun = false;
|
||||
NeedsReload();
|
||||
}
|
||||
|
||||
if(NeedsReload() || !this.dataReady)
|
||||
{
|
||||
GetOLHC(0,_rates_total);
|
||||
this.prev_calculated = 0;
|
||||
|
||||
if(NeedsReload() || !this.dataReady)
|
||||
{
|
||||
Print("NeedsReload/DataReady block failed");
|
||||
return false;
|
||||
}
|
||||
firstRun = true;
|
||||
ChartSetSymbolPeriod(ChartID(), _Symbol, _Period); // try to force reload
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if(needsReload || IsNewBar || canvasIsNewTime || (change != 0))
|
||||
{
|
||||
Print("reload="+needsReload+", renkoisnewbar="+IsNewBar+", canvasIsNewTime="+canvasIsNewTime+", change="+change);
|
||||
GetOLHC(0,_rates_total);
|
||||
this.prev_calculated = ArraySize(this.Open);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool change = Canvas_RatesTotalChangedBy(_rates_total);
|
||||
|
||||
if(change != 0)
|
||||
{
|
||||
#ifdef DISPLAY_DEBUG_MSG
|
||||
Print("rates total changed to:"+_rates_total);
|
||||
#endif
|
||||
|
||||
if(change == 1)
|
||||
{
|
||||
#ifdef DISPLAY_DEBUG_MSG
|
||||
@@ -197,7 +211,8 @@ bool RangeBarIndicator::OnCalculate(const int _rates_total,const int _prev_calcu
|
||||
#endif
|
||||
GetOLHC(0,_rates_total);
|
||||
}
|
||||
this.prev_calculated = 0;//_prev_calculated;
|
||||
|
||||
this.prev_calculated = 0;
|
||||
Canvas_IsNewBar(_Time);
|
||||
return true;
|
||||
}
|
||||
@@ -211,7 +226,7 @@ bool RangeBarIndicator::OnCalculate(const int _rates_total,const int _prev_calcu
|
||||
{
|
||||
GetOLHC(0,_rates_total);
|
||||
this.prev_calculated = 0;
|
||||
return true; ///////// false
|
||||
return true;
|
||||
}
|
||||
|
||||
OLHCShiftRight();
|
||||
@@ -224,9 +239,9 @@ bool RangeBarIndicator::OnCalculate(const int _rates_total,const int _prev_calcu
|
||||
{
|
||||
GetOLHC(0,_rates_total);
|
||||
this.prev_calculated = 0;
|
||||
firstRun = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Only recalculate last bar
|
||||
@@ -238,6 +253,19 @@ bool RangeBarIndicator::OnCalculate(const int _rates_total,const int _prev_calcu
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RangeBarIndicator::BufferSynchronizationCheck(const double &buffer[])
|
||||
{
|
||||
if(ArraySize(buffer) != ArraySize(Close))
|
||||
{
|
||||
#ifdef DEVELOPER_VERSION
|
||||
Print("### buffers out of synch - refreshing...");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int RangeBarIndicator::GetOLHC(int start, int count)
|
||||
{
|
||||
if((start == 0) && (count == 0) && dataReady)
|
||||
@@ -255,6 +283,7 @@ int RangeBarIndicator::GetOLHC(int start, int count)
|
||||
this.Low[last] = tempRates[0].low;
|
||||
this.High[last] = tempRates[0].high;
|
||||
this.Close[last] = tempRates[0].close;
|
||||
|
||||
if(getTime)
|
||||
{
|
||||
this.Time[last] = tempRates[0].time;
|
||||
@@ -300,10 +329,13 @@ void RangeBarIndicator::OLHCShiftRight()
|
||||
this.High[i] = this.High[i-1];
|
||||
this.Low[i] = this.Low[i-1];
|
||||
this.Close[i] = this.Close[i-1];
|
||||
|
||||
if(getTime)
|
||||
this.Time[i] = this.Time[i-1];
|
||||
|
||||
if(useAppliedPrice)
|
||||
this.Price[i] = this.Price[i-1];
|
||||
|
||||
if(getVolumes)
|
||||
{
|
||||
this.Tick_volume[i] = this.Tick_volume[i-1];
|
||||
@@ -324,8 +356,10 @@ void RangeBarIndicator::OLHCShiftRight()
|
||||
|
||||
if(getTime)
|
||||
this.Time[0] = 0;
|
||||
|
||||
if(useAppliedPrice)
|
||||
this.Price[0] = 0.0;
|
||||
|
||||
if(getVolumes)
|
||||
{
|
||||
this.Tick_volume[0] = 0.0;
|
||||
@@ -353,8 +387,10 @@ void RangeBarIndicator::OLHCResize()
|
||||
|
||||
if(getTime)
|
||||
ArrayResize(this.Time,count+1);
|
||||
|
||||
if(useAppliedPrice)
|
||||
ArrayResize(this.Price,count+1);
|
||||
|
||||
if(getVolumes)
|
||||
{
|
||||
ArrayResize(this.Tick_volume,count+1);
|
||||
@@ -376,8 +412,6 @@ bool RangeBarIndicator::Canvas_IsNewBar(const datetime &_Time[])
|
||||
datetime now = _Time[0];
|
||||
ArraySetAsSeries(_Time,false);
|
||||
|
||||
static datetime prevTime = 0;
|
||||
|
||||
if(prevTime != now)
|
||||
{
|
||||
prevTime = now;
|
||||
@@ -389,8 +423,6 @@ bool RangeBarIndicator::Canvas_IsNewBar(const datetime &_Time[])
|
||||
|
||||
bool RangeBarIndicator::Canvas_IsRatesTotalChanged(int ratesTotalNow)
|
||||
{
|
||||
static int prevRatesTotal = 0;
|
||||
|
||||
if(prevRatesTotal == 0)
|
||||
prevRatesTotal = ratesTotalNow;
|
||||
|
||||
@@ -406,7 +438,6 @@ bool RangeBarIndicator::Canvas_IsRatesTotalChanged(int ratesTotalNow)
|
||||
int RangeBarIndicator::Canvas_RatesTotalChangedBy(int ratesTotalNow)
|
||||
{
|
||||
int changedBy = 0;
|
||||
static int prevRatesTotal = 0;
|
||||
|
||||
if(prevRatesTotal == 0)
|
||||
prevRatesTotal = ratesTotalNow;
|
||||
@@ -464,11 +495,11 @@ int RangeBarIndicator::GetOLHCForIndicatorCalc(double &o[],double &l[],double &h
|
||||
handle = rangeBars.GetHandle();
|
||||
if(handle == INVALID_HANDLE)
|
||||
return -1;
|
||||
int _count = CopyBuffer(handle,RANGEBAR_OPEN,start,count,temp);
|
||||
if(_count == -1)
|
||||
|
||||
int __count = CopyBuffer(handle,RANGEBAR_OPEN,start,count,temp);
|
||||
if(__count == -1)
|
||||
{
|
||||
int errorCode = GetLastError();
|
||||
if(errorCode == ERR_INDICATOR_DATA_NOT_FOUND)
|
||||
if(GetLastError() == ERR_INDICATOR_DATA_NOT_FOUND)
|
||||
{
|
||||
Print("Waiting for buffers ready flag");
|
||||
return -2;
|
||||
@@ -477,95 +508,109 @@ int RangeBarIndicator::GetOLHCForIndicatorCalc(double &o[],double &l[],double &h
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(_count < count)
|
||||
if(__count < count)
|
||||
{
|
||||
#ifdef DISPLAY_DEBUG_MSG
|
||||
Print("Fixing offset (req:"+count+" res:"+_count+")");
|
||||
Print("Fixing offset (req:"+count+" res:"+__count+")");
|
||||
#endif
|
||||
|
||||
ArrayInitialize(o,0x0);
|
||||
ArrayInitialize(l,0x0);
|
||||
ArrayInitialize(h,0x0);
|
||||
ArrayInitialize(c,0x0);
|
||||
|
||||
if(getTime)
|
||||
ArrayInitialize(t,0x0);
|
||||
|
||||
if(getVolumes)
|
||||
{
|
||||
ArrayInitialize(tickVolume,0x0);
|
||||
ArrayInitialize(realVolume,0x0);
|
||||
}
|
||||
|
||||
if(getVolumeBreakdown)
|
||||
{
|
||||
ArrayInitialize(buyVolume,0x0);
|
||||
ArrayInitialize(sellVolume,0x0);
|
||||
ArrayInitialize(buySellVolume,0x0);
|
||||
}
|
||||
|
||||
// less data - indicator requres more
|
||||
|
||||
ArrayCopy(o,temp,(count-_count),0);
|
||||
ArrayCopy(o,temp,(count-__count),0);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_LOW,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_LOW,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(l,temp,(count-_count),0);
|
||||
ArrayCopy(l,temp,(count-__count),0);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_HIGH,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_HIGH,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(h,temp,(count-_count),0);
|
||||
ArrayCopy(h,temp,(count-__count),0);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_CLOSE,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_CLOSE,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(c,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(c,temp,(count-__count),0);
|
||||
|
||||
if(getTime)
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_BAR_OPEN_TIME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_BAR_OPEN_TIME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(t,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(t,temp,(count-__count),0);
|
||||
}
|
||||
|
||||
if(getVolumes)
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_TICK_VOLUME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_TICK_VOLUME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(tickVolume,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(tickVolume,temp,(count-__count),0);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_REAL_VOLUME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_REAL_VOLUME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(realVolume,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(realVolume,temp,(count-__count),0);
|
||||
}
|
||||
|
||||
#ifdef P_RANGEBAR_BR
|
||||
#ifdef P_RANGEBAR_BR_PRO
|
||||
if(getVolumeBreakdown)
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_BUY_VOLUME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_BUY_VOLUME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(buyVolume,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(buyVolume,temp,(count-__count),0);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_SELL_VOLUME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_SELL_VOLUME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(sellVolume,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(sellVolume,temp,(count-__count),0);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_BUYSELL_VOLUME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_BUYSELL_VOLUME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(buySellVolume,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(buySellVolume,temp,(count-__count),0);
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
#else
|
||||
if(getVolumeBreakdown)
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_BUY_VOLUME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_BUY_VOLUME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(buyVolume,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(buyVolume,temp,(count-__count),0);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_SELL_VOLUME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_SELL_VOLUME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(sellVolume,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(sellVolume,temp,(count-__count),0);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_BUYSELL_VOLUME,start,_count,temp) == -1)
|
||||
if(CopyBuffer(handle,RANGEBAR_BUYSELL_VOLUME,start,__count,temp) == -1)
|
||||
return -1;
|
||||
ArrayCopy(buySellVolume,temp,(count-_count),0);
|
||||
|
||||
ArrayCopy(buySellVolume,temp,(count-__count),0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -574,10 +619,13 @@ int RangeBarIndicator::GetOLHCForIndicatorCalc(double &o[],double &l[],double &h
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_OPEN,start,count,o) == -1)
|
||||
return -1;
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_LOW,start,count,l) == -1)
|
||||
return -1;
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_HIGH,start,count,h) == -1)
|
||||
return -1;
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_CLOSE,start,count,c) == -1)
|
||||
return -1;
|
||||
|
||||
@@ -585,6 +633,7 @@ int RangeBarIndicator::GetOLHCForIndicatorCalc(double &o[],double &l[],double &h
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_BAR_OPEN_TIME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(t,temp);
|
||||
}
|
||||
|
||||
@@ -592,9 +641,12 @@ int RangeBarIndicator::GetOLHCForIndicatorCalc(double &o[],double &l[],double &h
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_TICK_VOLUME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(tickVolume,temp);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_REAL_VOLUME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(realVolume,temp);
|
||||
}
|
||||
|
||||
@@ -604,14 +656,17 @@ int RangeBarIndicator::GetOLHCForIndicatorCalc(double &o[],double &l[],double &h
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_BUY_VOLUME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(buyVolume,temp);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_SELL_VOLUME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(sellVolume,temp);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_BUYSELL_VOLUME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(buySellVolume,temp);
|
||||
}
|
||||
#else
|
||||
@@ -621,14 +676,17 @@ int RangeBarIndicator::GetOLHCForIndicatorCalc(double &o[],double &l[],double &h
|
||||
{
|
||||
if(CopyBuffer(handle,RANGEBAR_BUY_VOLUME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(buyVolume,temp);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_SELL_VOLUME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(sellVolume,temp);
|
||||
|
||||
if(CopyBuffer(handle,RANGEBAR_BUYSELL_VOLUME,start,count,temp) == -1)
|
||||
return -1;
|
||||
|
||||
ArrayCopy(buySellVolume,temp);
|
||||
}
|
||||
#endif
|
||||
@@ -645,11 +703,11 @@ int RangeBarIndicator::GetOLHCAndApplPriceForIndicatorCalc(double &o[],double &l
|
||||
{
|
||||
dataReady = true;
|
||||
|
||||
int _count = GetOLHCForIndicatorCalc(o,l,h,c,t,tickVolume,realVolume,buyVolume,sellVolume,buySellVolume,start,count);
|
||||
if(_count < 0)
|
||||
int __count = GetOLHCForIndicatorCalc(o,l,h,c,t,tickVolume,realVolume,buyVolume,sellVolume,buySellVolume,start,count);
|
||||
if(__count < 0)
|
||||
{
|
||||
dataReady = false;
|
||||
return _count;
|
||||
return __count;
|
||||
}
|
||||
if(applied_price == PRICE_CLOSE)
|
||||
{
|
||||
@@ -669,22 +727,25 @@ int RangeBarIndicator::GetOLHCAndApplPriceForIndicatorCalc(double &o[],double &l
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ArrayResize(price,_count) == -1)
|
||||
if(ArrayResize(price,__count) == -1)
|
||||
return -1;
|
||||
|
||||
for(int i=0; i<_count; i++)
|
||||
for(int i=0; i<__count; i++)
|
||||
{
|
||||
price[i] = CalcAppliedPrice(o[i],l[i],h[i],c[i],_applied_price);
|
||||
}
|
||||
}
|
||||
|
||||
return _count;
|
||||
return __count;
|
||||
}
|
||||
|
||||
// TFMigrate:
|
||||
// https://www.mql5.com/en/forum/2842#comment_39496
|
||||
//
|
||||
ENUM_TIMEFRAMES RangeBarIndicator::TFMigrate(int tf)
|
||||
{
|
||||
{
|
||||
switch(tf)
|
||||
{
|
||||
{
|
||||
case 0: return(PERIOD_CURRENT);
|
||||
case 1: return(PERIOD_M1);
|
||||
case 5: return(PERIOD_M5);
|
||||
@@ -712,18 +773,30 @@ ENUM_TIMEFRAMES RangeBarIndicator::TFMigrate(int tf)
|
||||
case 16408: return(PERIOD_D1);
|
||||
case 32769: return(PERIOD_W1);
|
||||
case 49153: return(PERIOD_MN1);
|
||||
|
||||
default: return(PERIOD_CURRENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
datetime RangeBarIndicator::iTime(string symbol,int tf,int index)
|
||||
{
|
||||
if(index < 0) return(-1);
|
||||
if(index < 0)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
|
||||
|
||||
datetime Arr[];
|
||||
if(CopyTime(symbol, timeframe, index, 1, Arr)>0)
|
||||
return(Arr[0]);
|
||||
else return(-1);
|
||||
|
||||
if(CopyTime(symbol, timeframe, index, 1, Arr) > 0)
|
||||
{
|
||||
return(Arr[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -778,3 +851,43 @@ void RangeBarIndicator::BufferShiftLeft(double &buffer[])
|
||||
buffer[i-1] = buffer[i];
|
||||
|
||||
}
|
||||
|
||||
long RangeBarIndicator::GetArrayValueLong(long &arr[], int index)
|
||||
{
|
||||
int size = ArraySize(arr);
|
||||
if(index < size)
|
||||
{
|
||||
return(arr[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
double RangeBarIndicator::GetArrayValueDouble(double &arr[], int index)
|
||||
{
|
||||
int size = ArraySize(arr);
|
||||
if(index < size)
|
||||
{
|
||||
return(arr[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
datetime RangeBarIndicator::GetArrayValueDateTime(datetime &arr[], int index)
|
||||
{
|
||||
int size = ArraySize(arr);
|
||||
if(index < size)
|
||||
{
|
||||
return(arr[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user