Updated for RangeBars ver. 3.00
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,117 @@
|
||||
#include <AZ-INVEST/SDK/CommonSettings.mqh>
|
||||
|
||||
#ifdef DEVELOPER_VERSION
|
||||
#define CUSTOM_CHART_NAME "RangeBars_TEST"
|
||||
#else
|
||||
#define CUSTOM_CHART_NAME "Range Bars"
|
||||
#endif
|
||||
|
||||
//
|
||||
// Tick chart specific settings
|
||||
//
|
||||
#ifdef SHOW_INDICATOR_INPUTS
|
||||
#ifdef MQL5_MARKET_DEMO // hardcoded values
|
||||
|
||||
int barSizeInTicks = 180; // Range bar size (in points)
|
||||
ENUM_BOOL atrEnabled = false; // Enable ATR based bar size calculation
|
||||
ENUM_TIMEFRAMES atrTimeFrame = PERIOD_D1; // Use ATR period
|
||||
int atrPeriod = 14; // ATR period
|
||||
int atrPercentage = 10; // Use percentage of ATR
|
||||
int showNumberOfDays = 7; // Show history for number of days
|
||||
ENUM_BOOL resetOpenOnNewTradingDay = true; // Synchronize first bar's open on new day
|
||||
|
||||
#else // user defined settings
|
||||
|
||||
|
||||
input int barSizeInTicks = 100; // Range bar size (in points)
|
||||
input ENUM_BOOL atrEnabled = false; // Enable ATR based bar size calculation
|
||||
ENUM_TIMEFRAMES atrTimeFrame = PERIOD_D1; // Use ATR period
|
||||
input int atrPeriod = 14; // ATR period
|
||||
input int atrPercentage = 10; // Use percentage of ATR
|
||||
|
||||
input int showNumberOfDays = 5; // Show history for number of days
|
||||
input ENUM_BOOL resetOpenOnNewTradingDay = true; // Synchronize first bar's open on new day
|
||||
|
||||
#endif
|
||||
#else // don't SHOW_INDICATOR_INPUTS
|
||||
int barSizeInTicks = 180; // Range bar size (in points)
|
||||
ENUM_BOOL atrEnabled = false; // Enable ATR based bar size calculation
|
||||
ENUM_TIMEFRAMES atrTimeFrame = PERIOD_D1; // Use ATR period
|
||||
int atrPeriod = 14; // ATR period
|
||||
int atrPercentage = 10; // Use percentage of ATR
|
||||
int showNumberOfDays = 7; // Show history for number of days
|
||||
ENUM_BOOL resetOpenOnNewTradingDay = true; // Synchronize first bar's open on new day
|
||||
#endif
|
||||
|
||||
//
|
||||
// Remaining settings are located in the include file below.
|
||||
// These are common for all custom charts
|
||||
//
|
||||
#include <az-invest/sdk/CustomChartSettingsBase.mqh>
|
||||
|
||||
struct RANGEBAR_SETTINGS
|
||||
{
|
||||
int barSizeInTicks;
|
||||
ENUM_BOOL atrEnabled;
|
||||
ENUM_TIMEFRAMES atrTimeFrame;
|
||||
int atrPeriod;
|
||||
int atrPercentage;
|
||||
int showNumberOfDays;
|
||||
ENUM_BOOL resetOpenOnNewTradingDay;
|
||||
};
|
||||
|
||||
|
||||
class CRangeBarCustomChartSettigns : public CCustomChartSettingsBase
|
||||
{
|
||||
protected:
|
||||
|
||||
RANGEBAR_SETTINGS settings;
|
||||
|
||||
public:
|
||||
|
||||
CRangeBarCustomChartSettigns();
|
||||
~CRangeBarCustomChartSettigns();
|
||||
|
||||
RANGEBAR_SETTINGS GetCustomChartSettings() { return this.settings; };
|
||||
|
||||
virtual void SetCustomChartSettings();
|
||||
virtual string GetSettingsFileName();
|
||||
virtual uint CustomChartSettingsToFile(int handle);
|
||||
virtual uint CustomChartSettingsFromFile(int handle);
|
||||
};
|
||||
|
||||
void CRangeBarCustomChartSettigns::CRangeBarCustomChartSettigns()
|
||||
{
|
||||
settingsFileName = GetSettingsFileName();
|
||||
}
|
||||
|
||||
void CRangeBarCustomChartSettigns::~CRangeBarCustomChartSettigns()
|
||||
{
|
||||
}
|
||||
|
||||
string CRangeBarCustomChartSettigns::GetSettingsFileName()
|
||||
{
|
||||
return CUSTOM_CHART_NAME+(string)ChartID()+".set";
|
||||
}
|
||||
|
||||
uint CRangeBarCustomChartSettigns::CustomChartSettingsToFile(int file_handle)
|
||||
{
|
||||
return FileWriteStruct(file_handle,this.settings);
|
||||
}
|
||||
|
||||
uint CRangeBarCustomChartSettigns::CustomChartSettingsFromFile(int file_handle)
|
||||
{
|
||||
return FileReadStruct(file_handle,this.settings);
|
||||
}
|
||||
|
||||
void CRangeBarCustomChartSettigns::SetCustomChartSettings()
|
||||
{
|
||||
settings.barSizeInTicks = barSizeInTicks;
|
||||
|
||||
settings.atrEnabled = atrEnabled;
|
||||
settings.atrTimeFrame = atrTimeFrame;
|
||||
settings.atrPeriod = atrPeriod;
|
||||
settings.atrPercentage = atrPercentage;
|
||||
settings.showNumberOfDays = showNumberOfDays;
|
||||
settings.resetOpenOnNewTradingDay = resetOpenOnNewTradingDay;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,387 +0,0 @@
|
||||
#property copyright "Copyright 2017, AZ-iNVEST"
|
||||
#property link "http://www.az-invest.eu"
|
||||
|
||||
#include <AZ-INVEST/SDK/CommonSettings.mqh>
|
||||
#define CUSTOM_CHART_NAME "Range Bars"
|
||||
|
||||
#ifdef SHOW_INDICATOR_INPUTS
|
||||
|
||||
#ifdef MQL5_MARKET_DEMO
|
||||
int barSizeInTicks = 180; // Range bar size (in points)
|
||||
ENUM_BOOL atrEnabled = false; // Enable ATR based bar size calculation
|
||||
ENUM_TIMEFRAMES atrTimeFrame = PERIOD_D1; // Use ATR period
|
||||
int atrPeriod = 14; // ATR period
|
||||
int atrPercentage = 10; // Use percentage of ATR
|
||||
ENUM_BOOL useRealVolume = false; // Use real volume ( false for FX )
|
||||
ENUM_TICK_PRICE_TYPE plotPrice = tickBid; // Build chart using
|
||||
int showNumberOfDays = 7; // Show history for number of days
|
||||
ENUM_BOOL resetOpenOnNewTradingDay = true; // Synchronize first bar's open on new day
|
||||
|
||||
#ifdef USE_CUSTOM_SYMBOL
|
||||
string customChartName = ""; // Override default custom chart name with
|
||||
string applyTemplate = "default"; // Apply template to custom chart
|
||||
#endif
|
||||
#else
|
||||
input int barSizeInTicks = 100; // Range bar size (in points)
|
||||
input ENUM_BOOL atrEnabled = false; // Enable ATR based bar size calculation
|
||||
ENUM_TIMEFRAMES atrTimeFrame = PERIOD_D1; // Use ATR period
|
||||
input int atrPeriod = 14; // ATR period
|
||||
input int atrPercentage = 10; // Use percentage of ATR
|
||||
ENUM_BOOL useRealVolume = false; // Use real volume ( false for FX )
|
||||
ENUM_TICK_PRICE_TYPE plotPrice = tickBid; // Build chart using
|
||||
input int showNumberOfDays = 14; // Show history for number of days
|
||||
input ENUM_BOOL resetOpenOnNewTradingDay = true; // Synchronize first bar's open on new day
|
||||
|
||||
#ifdef USE_CUSTOM_SYMBOL
|
||||
input string customChartName = ""; // Override default custom chart name with
|
||||
input string applyTemplate = "default"; // Apply template to custom chart
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef USE_CUSTOM_SYMBOL
|
||||
input double TopBottomPaddingPercentage = 0.30; // Use padding top/bottom (0.0 - 1.0)
|
||||
input ENUM_PIVOT_POINTS showPivots = ppNone; // Show pivot levels
|
||||
input ENUM_PIVOT_TYPE pivotPointCalculationType = ppHLC3; // Pivot point calculation method
|
||||
input color RColor = clrDodgerBlue; // Resistance line color
|
||||
input color PColor = clrGold; // Pivot line color
|
||||
input color SColor = clrFireBrick; // Support line color
|
||||
input color PDHColor = clrHotPink; // Previous day's high
|
||||
input color PDLColor = clrLightSkyBlue; // Previous day's low
|
||||
input color PDCColor = clrGainsboro; // Previous day's close
|
||||
input ENUM_BOOL showNextBarLevels = true; // Show current bar's close projections
|
||||
input color HighThresholdIndicatorColor = clrLime; // Bullish bar projection color
|
||||
input color LowThresholdIndicatorColor = clrRed; // Bearish bar projection color
|
||||
input ENUM_BOOL showCurrentBarOpenTime = true; // Display chart info and current bar's open time
|
||||
input color InfoTextColor = clrNONE; // Current bar's open time info color
|
||||
|
||||
input ENUM_BOOL NewBarAlert = false; // Alert on new a bar
|
||||
input ENUM_BOOL ReversalBarAlert = false; // Alert on reversal bar
|
||||
input ENUM_BOOL MaCrossAlert = false; // Alert on MA crossover
|
||||
input ENUM_BOOL UseAlertWindow = false; // Display alert in Alert Window
|
||||
input ENUM_BOOL UseSound = false; // Play sound on alert
|
||||
input ENUM_BOOL UsePushNotifications = false; // Send alert via push notification to a smartphone
|
||||
|
||||
input string SoundFileBull = "news.wav"; // Use sound file for bullish bar close
|
||||
input string SoundFileBear = "timeout.wav"; // Use sound file for bearish bar close
|
||||
input ENUM_BOOL MA1on = false; // Show first MA
|
||||
input int MA1period = 20; // 1st MA period
|
||||
input ENUM_MA_METHOD_EXT MA1method = _MODE_SMA; // 1st MA method
|
||||
input ENUM_APPLIED_PRICE MA1applyTo = PRICE_CLOSE; // 1st MA apply to
|
||||
input int MA1shift = 0; // 1st MA shift
|
||||
input ENUM_BOOL MA2on = false; // Show second MA
|
||||
input int MA2period = 50; // 2nd MA period
|
||||
input ENUM_MA_METHOD_EXT MA2method = _MODE_EMA; // 2nd MA method
|
||||
input ENUM_APPLIED_PRICE MA2applyTo = PRICE_CLOSE; // 2nd MA apply to
|
||||
input int MA2shift = 0; // 2nd MA shift
|
||||
input ENUM_BOOL MA3on = false; // Show third MA
|
||||
input int MA3period = 20; // 3rd MA period
|
||||
input ENUM_MA_METHOD_EXT MA3method = _VWAP_TICKVOL; // 3rd MA method
|
||||
input ENUM_APPLIED_PRICE MA3applyTo = PRICE_CLOSE; // 3rd MA apply to
|
||||
input int MA3shift = 0; // 3rd MA shift
|
||||
input ENUM_CHANNEL_TYPE ShowChannel = _None; // Show Channel
|
||||
input string Channel_Settings = "-------------------"; // Channel settings
|
||||
input int DonchianPeriod = 20; // Donchian Channel period
|
||||
input ENUM_APPLIED_PRICE BBapplyTo = PRICE_CLOSE; // Bollinger Bands apply to
|
||||
input int BollingerBandsPeriod = 20; // Bollinger Bands period
|
||||
input double BollingerBandsDeviations = 2.0; // Bollinger Bands deviations
|
||||
input int SuperTrendPeriod = 10; // Super Trend period
|
||||
input double SuperTrendMultiplier=1.7; // Super Trend multiplier
|
||||
input string Misc_Settings = "-------------------"; // Misc settings
|
||||
input ENUM_BOOL DisplayAsBarChart = false; // Display as bar chart
|
||||
input ENUM_BOOL ShiftObj = false; // Shift objects with chart
|
||||
input ENUM_BOOL UsedInEA = false; // Indicator used in EA via iCustom()
|
||||
#endif
|
||||
#else
|
||||
|
||||
//
|
||||
// This block should always be set to the following values
|
||||
//
|
||||
|
||||
double TopBottomPaddingPercentage = 0;
|
||||
ENUM_PIVOT_POINTS showPivots = ppNone;
|
||||
ENUM_PIVOT_TYPE pivotPointCalculationType = ppHLC3;
|
||||
color RColor = clrNONE;
|
||||
color PColor = clrNONE;
|
||||
color SColor = clrNONE;
|
||||
color PDHColor = clrNONE;
|
||||
color PDLColor = clrNONE;
|
||||
color PDCColor = clrNONE;
|
||||
ENUM_BOOL showNextBarLevels = false;
|
||||
color HighThresholdIndicatorColor = clrNONE;
|
||||
color LowThresholdIndicatorColor = clrNONE;
|
||||
ENUM_BOOL showCurrentBarOpenTime = false;
|
||||
color InfoTextColor = clrNONE;
|
||||
|
||||
ENUM_BOOL NewBarAlert = false;
|
||||
ENUM_BOOL ReversalBarAlert = false;
|
||||
ENUM_BOOL MaCrossAlert = false;
|
||||
ENUM_BOOL UseAlertWindow = false;
|
||||
ENUM_BOOL UseSound = false;
|
||||
ENUM_BOOL UsePushNotifications = false;
|
||||
|
||||
string SoundFileBull = "";
|
||||
string SoundFileBear = "";
|
||||
ENUM_BOOL DisplayAsBarChart = true;
|
||||
ENUM_BOOL ShiftObj = false;
|
||||
ENUM_BOOL UsedInEA = true; // This should always be set to TRUE for EAs & Indicators
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
struct RANGEBAR_SETTINGS
|
||||
{
|
||||
int barSizeInTicks;
|
||||
ENUM_BOOL atrEnabled;
|
||||
ENUM_TIMEFRAMES atrTimeFrame;
|
||||
int atrPeriod;
|
||||
int atrPercentage;
|
||||
ENUM_BOOL useRealVolume;
|
||||
ENUM_TICK_PRICE_TYPE plotPrice;
|
||||
int showNumberOfDays;
|
||||
ENUM_BOOL resetOpenOnNewTradingDay;
|
||||
};
|
||||
|
||||
class RangeBarSettings
|
||||
{
|
||||
protected:
|
||||
|
||||
string settingsFileName;
|
||||
string chartTypeFileName;
|
||||
|
||||
RANGEBAR_SETTINGS settings;
|
||||
CHART_INDICATOR_SETTINGS chartIndicatorSettings;
|
||||
ALERT_INFO_SETTINGS alertInfoSettings;
|
||||
|
||||
public:
|
||||
|
||||
RangeBarSettings(void);
|
||||
~RangeBarSettings(void);
|
||||
|
||||
RANGEBAR_SETTINGS GetRangeBarSettings(void);
|
||||
ALERT_INFO_SETTINGS GetAlertInfoSettings(void);
|
||||
CHART_INDICATOR_SETTINGS GetChartIndicatorSettings(void);
|
||||
|
||||
void Set(void);
|
||||
|
||||
void Save(void);
|
||||
bool Load(void);
|
||||
void Delete(void);
|
||||
bool Changed(void);
|
||||
};
|
||||
|
||||
void RangeBarSettings::RangeBarSettings(void)
|
||||
{
|
||||
this.settingsFileName = CUSTOM_CHART_NAME+(string)ChartID()+".set";
|
||||
this.chartTypeFileName = (string)ChartID()+".id";
|
||||
}
|
||||
|
||||
void RangeBarSettings::~RangeBarSettings(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RangeBarSettings::Save(void)
|
||||
{
|
||||
if(IS_TESTING || this.chartIndicatorSettings.UsedInEA)
|
||||
return;
|
||||
|
||||
this.Delete();
|
||||
|
||||
//
|
||||
// Store indicator settings
|
||||
//
|
||||
|
||||
int handle = FileOpen(this.settingsFileName,FILE_SHARE_READ|FILE_WRITE|FILE_BIN);
|
||||
uint result = 0;
|
||||
|
||||
result += FileWriteStruct(handle,this.settings);
|
||||
result += FileWriteStruct(handle,this.chartIndicatorSettings);
|
||||
//FileWriteStruct(handle,this.alertInfoSettings);
|
||||
FileClose(handle);
|
||||
|
||||
//
|
||||
// Store chart type identifier
|
||||
//
|
||||
/*
|
||||
handle = FileOpen(this.chartTypeFileName,FILE_SHARE_READ|FILE_WRITE|FILE_ANSI);
|
||||
FileWriteString(handle,CUSTOM_CHART_NAME);
|
||||
FileClose(handle);
|
||||
*/
|
||||
}
|
||||
|
||||
void RangeBarSettings::Delete(void)
|
||||
{
|
||||
if(IS_TESTING || this.chartIndicatorSettings.UsedInEA)
|
||||
return;
|
||||
|
||||
if(FileIsExist(this.settingsFileName))
|
||||
FileDelete(this.settingsFileName);
|
||||
}
|
||||
|
||||
bool RangeBarSettings::Load(void)
|
||||
{
|
||||
#ifdef SHOW_INDICATOR_INPUTS
|
||||
Set();
|
||||
return true;
|
||||
#else
|
||||
|
||||
if(!FileIsExist(this.settingsFileName))
|
||||
return false;
|
||||
|
||||
int handle = FileOpen(this.settingsFileName,FILE_SHARE_READ|FILE_BIN);
|
||||
if(handle == INVALID_HANDLE)
|
||||
return false;
|
||||
|
||||
if(FileReadStruct(handle,this.settings) <= 0)
|
||||
{
|
||||
Print("Failed loading settings(1)!");
|
||||
FileClose(handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(FileReadStruct(handle,this.chartIndicatorSettings) <= 0)
|
||||
{
|
||||
Print("Failed loading settings(2)!");
|
||||
FileClose(handle);
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if(FileReadStruct(handle,this.alertInfoSettings) <= 0)
|
||||
{
|
||||
Print("Failed loading settings(3)!");
|
||||
FileClose(handle);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
FileClose(handle);
|
||||
return true;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
ALERT_INFO_SETTINGS RangeBarSettings::GetAlertInfoSettings(void)
|
||||
{
|
||||
return this.alertInfoSettings;
|
||||
}
|
||||
|
||||
CHART_INDICATOR_SETTINGS RangeBarSettings::GetChartIndicatorSettings(void)
|
||||
{
|
||||
return this.chartIndicatorSettings;
|
||||
}
|
||||
|
||||
RANGEBAR_SETTINGS RangeBarSettings::GetRangeBarSettings(void)
|
||||
{
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
void RangeBarSettings::Set(void)
|
||||
{
|
||||
#ifdef SHOW_INDICATOR_INPUTS
|
||||
|
||||
settings.barSizeInTicks = barSizeInTicks;
|
||||
settings.atrEnabled = atrEnabled;
|
||||
settings.atrTimeFrame = atrTimeFrame;
|
||||
settings.atrPeriod = atrPeriod;
|
||||
settings.atrPercentage = atrPercentage;
|
||||
settings.useRealVolume = useRealVolume;
|
||||
settings.plotPrice = plotPrice;
|
||||
settings.showNumberOfDays = showNumberOfDays;
|
||||
settings.resetOpenOnNewTradingDay = resetOpenOnNewTradingDay;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef USE_CUSTOM_SYMBOL
|
||||
chartIndicatorSettings.MA1on = MA1on;
|
||||
chartIndicatorSettings.MA1period = MA1period;
|
||||
chartIndicatorSettings.MA1method = MA1method;
|
||||
chartIndicatorSettings.MA1applyTo = MA1applyTo;
|
||||
chartIndicatorSettings.MA1shift = MA1shift;
|
||||
chartIndicatorSettings.MA2on = MA2on;
|
||||
chartIndicatorSettings.MA2period = MA2period;
|
||||
chartIndicatorSettings.MA2method = MA2method;
|
||||
chartIndicatorSettings.MA2applyTo = MA2applyTo;
|
||||
chartIndicatorSettings.MA2shift = MA2shift;
|
||||
/*
|
||||
chartIndicatorSettings.ShowVWAP = ShowVWAP;
|
||||
chartIndicatorSettings.VWAP_Period = VWAP_Period;
|
||||
chartIndicatorSettings.VWAPapplyTo = VWAPapplyTo;
|
||||
chartIndicatorSettings.VWAPvolume = VWAPvolume;
|
||||
*/
|
||||
chartIndicatorSettings.MA3on = MA3on;
|
||||
chartIndicatorSettings.MA3period = MA3period;
|
||||
chartIndicatorSettings.MA3method = MA3method;
|
||||
chartIndicatorSettings.MA3applyTo = MA3applyTo;
|
||||
chartIndicatorSettings.MA3shift = MA3shift;
|
||||
chartIndicatorSettings.ShowChannel = ShowChannel;
|
||||
chartIndicatorSettings.DonchianPeriod = DonchianPeriod;
|
||||
chartIndicatorSettings.BBapplyTo = BBapplyTo;
|
||||
chartIndicatorSettings.BollingerBandsPeriod = BollingerBandsPeriod;
|
||||
chartIndicatorSettings.BollingerBandsDeviations = BollingerBandsDeviations;
|
||||
chartIndicatorSettings.SuperTrendPeriod = SuperTrendPeriod;
|
||||
chartIndicatorSettings.SuperTrendMultiplier = SuperTrendMultiplier;
|
||||
chartIndicatorSettings.ShiftObj = ShiftObj;
|
||||
chartIndicatorSettings.UsedInEA = UsedInEA;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
alertInfoSettings.TopBottomPaddingPercentage = TopBottomPaddingPercentage;
|
||||
alertInfoSettings.showPiovots = showPivots;
|
||||
alertInfoSettings.pivotPointCalculationType = pivotPointCalculationType;
|
||||
alertInfoSettings.Rcolor = RColor;
|
||||
alertInfoSettings.Pcolor = PColor;
|
||||
alertInfoSettings.Scolor = SColor;
|
||||
alertInfoSettings.PDHColor = PDHColor;
|
||||
alertInfoSettings.PDLColor = PDLColor;
|
||||
alertInfoSettings.PDCColor = PDCColor;
|
||||
alertInfoSettings.showNextBarLevels = showNextBarLevels;
|
||||
alertInfoSettings.HighThresholdIndicatorColor = HighThresholdIndicatorColor;
|
||||
alertInfoSettings.LowThresholdIndicatorColor = LowThresholdIndicatorColor;
|
||||
alertInfoSettings.showCurrentBarOpenTime = showCurrentBarOpenTime;
|
||||
alertInfoSettings.InfoTextColor = InfoTextColor;
|
||||
|
||||
alertInfoSettings.NewBarAlert = NewBarAlert;
|
||||
alertInfoSettings.ReversalBarAlert = ReversalBarAlert;
|
||||
alertInfoSettings.MaCrossAlert = MaCrossAlert ;
|
||||
alertInfoSettings.UseAlertWindow = UseAlertWindow;
|
||||
alertInfoSettings.UseSound = UseSound;
|
||||
alertInfoSettings.UsePushNotifications = UsePushNotifications;
|
||||
|
||||
alertInfoSettings.SoundFileBull = SoundFileBull;
|
||||
alertInfoSettings.SoundFileBear = SoundFileBear;
|
||||
alertInfoSettings.DisplayAsBarChart = DisplayAsBarChart;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RangeBarSettings::Changed(void)
|
||||
{
|
||||
if(MQLInfoInteger((int)MQL5_TESTING))
|
||||
return false;
|
||||
|
||||
static datetime prevFileTime = 0;
|
||||
|
||||
if(!FileIsExist(this.settingsFileName))
|
||||
return false;
|
||||
|
||||
int handle = FileOpen(this.settingsFileName,FILE_SHARE_READ|FILE_BIN);
|
||||
datetime currFileTime = (datetime)FileGetInteger(handle,FILE_CREATE_DATE);
|
||||
FileClose(handle);
|
||||
|
||||
if(prevFileTime != currFileTime)
|
||||
{
|
||||
prevFileTime = currFileTime;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
+187
-105
@@ -1,48 +1,48 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| RangeBars.mqh ver:2.03.0 |
|
||||
//| Copyright 2017, AZ-iNVEST |
|
||||
//| http://www.az-invest.eu |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2017, AZ-iNVEST"
|
||||
#property copyright "Copyright 2018-2020, Level Up Software"
|
||||
#property link "http://www.az-invest.eu"
|
||||
|
||||
//#define RANGEBAR_INDICATOR_NAME "RangeBars\\RangeBarsOverlay213"
|
||||
#define RANGEBAR_INDICATOR_NAME "Market\\Range Bars Charting"
|
||||
#ifdef DEVELOPER_VERSION
|
||||
#define RANGEBAR_INDICATOR_NAME "RangeBars\\RangeBarsOverlay300"
|
||||
#else
|
||||
#define RANGEBAR_INDICATOR_NAME "Market\\Range Bars Charting"
|
||||
#endif
|
||||
|
||||
#define RANGEBAR_OPEN 00
|
||||
#define RANGEBAR_HIGH 01
|
||||
#define RANGEBAR_LOW 02
|
||||
#define RANGEBAR_CLOSE 03
|
||||
#define RANGEBAR_BAR_COLOR 04
|
||||
#define RANGEBAR_MA1 05
|
||||
#define RANGEBAR_MA2 06
|
||||
#define RANGEBAR_MA3 07
|
||||
#define RANGEBAR_CHANNEL_HIGH 08
|
||||
#define RANGEBAR_CHANNEL_MID 09
|
||||
#define RANGEBAR_CHANNEL_LOW 10
|
||||
#define RANGEBAR_BAR_OPEN_TIME 11
|
||||
#define RANGEBAR_TICK_VOLUME 12
|
||||
#define RANGEBAR_REAL_VOLUME 13
|
||||
#define RANGEBAR_BUY_VOLUME 14
|
||||
#define RANGEBAR_SELL_VOLUME 15
|
||||
#define RANGEBAR_BUYSELL_VOLUME 16
|
||||
#define RANGEBAR_SESSION_RECT_H 05
|
||||
#define RANGEBAR_SESSION_RECT_L 06
|
||||
#define RANGEBAR_MA1 07
|
||||
#define RANGEBAR_MA2 08
|
||||
#define RANGEBAR_MA3 09
|
||||
#define RANGEBAR_MA4 10
|
||||
#define RANGEBAR_CHANNEL_HIGH 11
|
||||
#define RANGEBAR_CHANNEL_MID 12
|
||||
#define RANGEBAR_CHANNEL_LOW 13
|
||||
#define RANGEBAR_BAR_OPEN_TIME 14
|
||||
#define RANGEBAR_TICK_VOLUME 15
|
||||
#define RANGEBAR_REAL_VOLUME 16
|
||||
#define RANGEBAR_BUY_VOLUME 17
|
||||
#define RANGEBAR_SELL_VOLUME 18
|
||||
#define RANGEBAR_BUYSELL_VOLUME 19
|
||||
#define RANGEBAR_RUNTIME_ID 20
|
||||
|
||||
#include <AZ-INVEST/SDK/RangeBarSettings.mqh>
|
||||
#include <az-invest/sdk/RangeBarCustomChartSettings.mqh>
|
||||
|
||||
class RangeBars
|
||||
{
|
||||
private:
|
||||
|
||||
RangeBarSettings * rangeBarSettings;
|
||||
CRangeBarCustomChartSettigns * rangeBarSettings;
|
||||
|
||||
//
|
||||
// Median renko indicator handle
|
||||
//
|
||||
|
||||
int rangeBarsHandle;
|
||||
int rangeBarsHandle; // range bar indicator handle
|
||||
string rangeBarsSymbol;
|
||||
bool usedByIndicatorOnRangeBarChart;
|
||||
|
||||
datetime prevBarTime;
|
||||
|
||||
public:
|
||||
|
||||
RangeBars();
|
||||
@@ -53,49 +53,60 @@ class RangeBars
|
||||
int Init();
|
||||
void Deinit();
|
||||
bool Reload();
|
||||
|
||||
void ReleaseHandle();
|
||||
|
||||
int GetHandle(void) { return rangeBarsHandle; };
|
||||
double GetRuntimeId();
|
||||
|
||||
bool IsNewBar();
|
||||
|
||||
bool GetMqlRates(MqlRates &ratesInfoArray[], int start, int count);
|
||||
bool GetBuySellVolumeBreakdown(double &buy[], double &sell[], double &buySell[], int start, int count);
|
||||
bool GetMA(int MaBufferId, double &MA[], int start, int count);
|
||||
bool GetChannel(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count);
|
||||
|
||||
// The following 6 functions are deprecated, please use GetMA & GetChannelData functions instead
|
||||
bool GetMA1(double &MA[], int start, int count);
|
||||
bool GetMA2(double &MA[], int start, int count);
|
||||
bool GetMA3(double &MA[], int start, int count);
|
||||
bool GetDonchian(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count);
|
||||
bool GetBollingerBands(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count);
|
||||
bool GetSuperTrend(double &SuperTrendHighArray[], double &SuperTrendArray[], double &SuperTrendLowArray[], int start, int count);
|
||||
|
||||
bool IsNewBar();
|
||||
//
|
||||
|
||||
private:
|
||||
|
||||
bool GetChannel(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count);
|
||||
int GetIndicatorHandle(void);
|
||||
bool GetChannelData(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count);
|
||||
};
|
||||
|
||||
RangeBars::RangeBars(void)
|
||||
{
|
||||
#define CONSTRUCTOR1
|
||||
rangeBarSettings = new RangeBarSettings();
|
||||
rangeBarSettings = new CRangeBarCustomChartSettigns();
|
||||
rangeBarsHandle = INVALID_HANDLE;
|
||||
rangeBarsSymbol = _Symbol;
|
||||
usedByIndicatorOnRangeBarChart = false;
|
||||
prevBarTime = 0;
|
||||
}
|
||||
|
||||
RangeBars::RangeBars(bool isUsedByIndicatorOnRangeBarChart)
|
||||
{
|
||||
rangeBarSettings = new RangeBarSettings();
|
||||
rangeBarSettings = new CRangeBarCustomChartSettigns();
|
||||
rangeBarsHandle = INVALID_HANDLE;
|
||||
rangeBarsSymbol = _Symbol;
|
||||
usedByIndicatorOnRangeBarChart = isUsedByIndicatorOnRangeBarChart;
|
||||
prevBarTime = 0;
|
||||
}
|
||||
|
||||
RangeBars::RangeBars(string symbol)
|
||||
{
|
||||
#define CONSTRUCTOR2
|
||||
rangeBarSettings = new RangeBarSettings();
|
||||
rangeBarSettings = new CRangeBarCustomChartSettigns();
|
||||
rangeBarsHandle = INVALID_HANDLE;
|
||||
rangeBarsSymbol = symbol;
|
||||
usedByIndicatorOnRangeBarChart = false;
|
||||
prevBarTime = 0;
|
||||
}
|
||||
|
||||
RangeBars::~RangeBars(void)
|
||||
@@ -104,6 +115,14 @@ RangeBars::~RangeBars(void)
|
||||
delete rangeBarSettings;
|
||||
}
|
||||
|
||||
void RangeBars::ReleaseHandle()
|
||||
{
|
||||
if(rangeBarsHandle != INVALID_HANDLE)
|
||||
{
|
||||
IndicatorRelease(rangeBarsHandle);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function for initializing the median renko indicator handle
|
||||
//
|
||||
@@ -117,6 +136,9 @@ int RangeBars::Init()
|
||||
//
|
||||
// Indicator on RangeBar chart uses the values of the RangeBar chart for calculations
|
||||
//
|
||||
|
||||
IndicatorRelease(rangeBarsHandle);
|
||||
|
||||
rangeBarsHandle = GetIndicatorHandle();
|
||||
return rangeBarsHandle;
|
||||
}
|
||||
@@ -157,28 +179,21 @@ int RangeBars::Init()
|
||||
// Load settings from EA inputs
|
||||
//
|
||||
rangeBarSettings.Load();
|
||||
#else
|
||||
//
|
||||
// Save indicator inputs for use by EA attached to same chart.
|
||||
//
|
||||
rangeBarSettings.Save();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
RANGEBAR_SETTINGS s = rangeBarSettings.GetRangeBarSettings();
|
||||
RANGEBAR_SETTINGS s = rangeBarSettings.GetCustomChartSettings();
|
||||
CHART_INDICATOR_SETTINGS cis = rangeBarSettings.GetChartIndicatorSettings();
|
||||
|
||||
//RangeBarSettings.Debug();
|
||||
|
||||
rangeBarsHandle = iCustom(this.rangeBarsSymbol,_Period,RANGEBAR_INDICATOR_NAME,
|
||||
rangeBarsHandle = iCustom(this.rangeBarsSymbol, _Period, RANGEBAR_INDICATOR_NAME,
|
||||
s.barSizeInTicks,
|
||||
s.atrEnabled,
|
||||
//s.atrTimeFrame,
|
||||
s.atrPeriod,
|
||||
s.atrPercentage,
|
||||
s.showNumberOfDays,
|
||||
s.resetOpenOnNewTradingDay,
|
||||
s.showNumberOfDays, s.resetOpenOnNewTradingDay,
|
||||
TradingSessionTime,
|
||||
TopBottomPaddingPercentage,
|
||||
showPivots,
|
||||
pivotPointCalculationType,
|
||||
@@ -188,55 +203,57 @@ int RangeBars::Init()
|
||||
PDHColor,
|
||||
PDLColor,
|
||||
PDCColor,
|
||||
showNextBarLevels,
|
||||
HighThresholdIndicatorColor,
|
||||
LowThresholdIndicatorColor,
|
||||
showCurrentBarOpenTime,
|
||||
InfoTextColor,
|
||||
NewBarAlert,
|
||||
ReversalBarAlert,
|
||||
MaCrossAlert,
|
||||
UseAlertWindow,
|
||||
UseSound,
|
||||
UsePushNotifications,
|
||||
AlertMeWhen,
|
||||
AlertNotificationType,
|
||||
SoundFileBull,
|
||||
SoundFileBear,
|
||||
cis.MA1on,
|
||||
cis.MA1lineType,
|
||||
cis.MA1period,
|
||||
cis.MA1method,
|
||||
cis.MA1applyTo,
|
||||
cis.MA1shift,
|
||||
cis.MA2on,
|
||||
cis.MA1priceLabel,
|
||||
cis.MA2on,
|
||||
cis.MA2lineType,
|
||||
cis.MA2period,
|
||||
cis.MA2method,
|
||||
cis.MA2applyTo,
|
||||
cis.MA2shift,
|
||||
cis.MA3on,
|
||||
cis.MA2priceLabel,
|
||||
cis.MA3on,
|
||||
cis.MA3lineType,
|
||||
cis.MA3period,
|
||||
cis.MA3method,
|
||||
cis.MA3applyTo,
|
||||
cis.MA3shift,
|
||||
cis.MA3priceLabel,
|
||||
cis.MA4on,
|
||||
cis.MA4lineType,
|
||||
cis.MA4period,
|
||||
cis.MA4method,
|
||||
cis.MA4applyTo,
|
||||
cis.MA4shift,
|
||||
cis.MA4priceLabel,
|
||||
cis.ShowChannel,
|
||||
"",
|
||||
cis.DonchianPeriod,
|
||||
cis.BBapplyTo,
|
||||
cis.BollingerBandsPeriod,
|
||||
cis.BollingerBandsDeviations,
|
||||
cis.SuperTrendPeriod,
|
||||
cis.SuperTrendMultiplier,
|
||||
"",
|
||||
DisplayAsBarChart,
|
||||
ShiftObj,
|
||||
UsedInEA);
|
||||
|
||||
cis.ChannelPeriod,
|
||||
cis.ChannelAtrPeriod,
|
||||
cis.ChannelAppliedPrice,
|
||||
cis.ChannelMultiplier,
|
||||
cis.ChannelBandsDeviations,
|
||||
cis.ChannelPriceLabel,
|
||||
cis.ChannelMidPriceLabel,
|
||||
true); // used in EA
|
||||
// DisplayAsBarChart & ShiftObj let at defaults
|
||||
|
||||
if(rangeBarsHandle == INVALID_HANDLE)
|
||||
{
|
||||
Print("RangeBar indicator init failed on error ",GetLastError());
|
||||
Print(RANGEBAR_INDICATOR_NAME+" indicator init failed on error ",GetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
Print("RangeBar indicator init OK");
|
||||
Print(RANGEBAR_INDICATOR_NAME+" indicator init OK");
|
||||
}
|
||||
|
||||
return rangeBarsHandle;
|
||||
@@ -248,14 +265,36 @@ int RangeBars::Init()
|
||||
|
||||
bool RangeBars::Reload()
|
||||
{
|
||||
if(rangeBarSettings.Changed())
|
||||
bool actionNeeded = false;
|
||||
int temp = GetIndicatorHandle();
|
||||
|
||||
if(temp != rangeBarsHandle)
|
||||
{
|
||||
if(Init() == INVALID_HANDLE)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
IndicatorRelease(rangeBarsHandle);
|
||||
rangeBarsHandle = INVALID_HANDLE;
|
||||
|
||||
actionNeeded = true;
|
||||
}
|
||||
|
||||
if(rangeBarSettings.Changed(GetRuntimeId()))
|
||||
{
|
||||
actionNeeded = true;
|
||||
}
|
||||
|
||||
if(actionNeeded)
|
||||
{
|
||||
if(rangeBarsHandle != INVALID_HANDLE)
|
||||
{
|
||||
IndicatorRelease(rangeBarsHandle);
|
||||
rangeBarsHandle = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if(Init() == INVALID_HANDLE)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -271,9 +310,9 @@ void RangeBars::Deinit()
|
||||
if(!usedByIndicatorOnRangeBarChart)
|
||||
{
|
||||
if(IndicatorRelease(rangeBarsHandle))
|
||||
Print("RangeBar indicator handle released");
|
||||
Print(RANGEBAR_INDICATOR_NAME+" indicator handle released");
|
||||
else
|
||||
Print("Failed to release RangeBar indicator handle");
|
||||
Print("Failed to release "+RANGEBAR_INDICATOR_NAME+" indicator handle");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,13 +322,13 @@ void RangeBars::Deinit()
|
||||
|
||||
bool RangeBars::IsNewBar()
|
||||
{
|
||||
MqlRates currentBar[1];
|
||||
static datetime prevBarTime;
|
||||
|
||||
MqlRates currentBar[1];
|
||||
GetMqlRates(currentBar,0,1);
|
||||
|
||||
if(currentBar[0].time == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(prevBarTime < currentBar[0].time)
|
||||
{
|
||||
@@ -297,7 +336,8 @@ bool RangeBars::IsNewBar()
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Get "count" Renko MqlRates into "ratesInfoArray[]" array starting from "start" bar
|
||||
@@ -380,23 +420,12 @@ bool RangeBars::GetBuySellVolumeBreakdown(double &buy[], double &sell[], double
|
||||
if(ArrayResize(bs,count) == -1)
|
||||
return false;
|
||||
|
||||
#ifdef P_RANGEBAR_BR
|
||||
#ifdef P_RANGEBAR_BR_PRO
|
||||
if(CopyBuffer(rangeBarsHandle,RANGEBAR_BUY_VOLUME,start,count,b) == -1)
|
||||
return false;
|
||||
if(CopyBuffer(rangeBarsHandle,RANGEBAR_SELL_VOLUME,start,count,s) == -1)
|
||||
return false;
|
||||
if(CopyBuffer(rangeBarsHandle,RANGEBAR_BUYSELL_VOLUME,start,count,bs) == -1)
|
||||
return false;
|
||||
#endif
|
||||
#else
|
||||
if(CopyBuffer(rangeBarsHandle,RANGEBAR_BUY_VOLUME,start,count,b) == -1)
|
||||
return false;
|
||||
if(CopyBuffer(rangeBarsHandle,RANGEBAR_SELL_VOLUME,start,count,s) == -1)
|
||||
return false;
|
||||
if(CopyBuffer(rangeBarsHandle,RANGEBAR_BUYSELL_VOLUME,start,count,bs) == -1)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if(ArrayResize(buy,count) == -1)
|
||||
return false;
|
||||
@@ -418,16 +447,48 @@ bool RangeBars::GetBuySellVolumeBreakdown(double &buy[], double &sell[], double
|
||||
ArrayFree(bs);
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Get "count" values for MaBufferId buffer into "MA[]" array starting from "start" bar
|
||||
//
|
||||
|
||||
bool RangeBars::GetMA(int MaBufferId, double &MA[], int start, int count)
|
||||
{
|
||||
double tempMA[];
|
||||
if(ArrayResize(tempMA, count) == -1)
|
||||
return false;
|
||||
|
||||
if(ArrayResize(MA, count) == -1)
|
||||
return false;
|
||||
|
||||
if(MaBufferId != RANGEBAR_MA1 && MaBufferId != RANGEBAR_MA2 && MaBufferId != RANGEBAR_MA3 && MaBufferId != RANGEBAR_MA4)
|
||||
{
|
||||
Print("Incorrect MA buffer id specified in "+__FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(CopyBuffer(rangeBarsHandle, MaBufferId,start,count,tempMA) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
MA[count-1-i] = tempMA[i];
|
||||
}
|
||||
|
||||
ArrayFree(tempMA);
|
||||
return true;
|
||||
}
|
||||
//
|
||||
// Get "count" MovingAverage1 values into "MA[]" array starting from "start" bar
|
||||
//
|
||||
|
||||
bool RangeBars::GetMA1(double &MA[], int start, int count)
|
||||
{
|
||||
Print(__FUNCTION__+" is deprecated, please use GetMA instead");
|
||||
|
||||
double tempMA[];
|
||||
if(ArrayResize(tempMA,count) == -1)
|
||||
return false;
|
||||
@@ -453,6 +514,8 @@ bool RangeBars::GetMA1(double &MA[], int start, int count)
|
||||
|
||||
bool RangeBars::GetMA2(double &MA[], int start, int count)
|
||||
{
|
||||
Print(__FUNCTION__+" is deprecated, please use GetMA instead");
|
||||
|
||||
double tempMA[];
|
||||
if(ArrayResize(tempMA,count) == -1)
|
||||
return false;
|
||||
@@ -478,6 +541,8 @@ bool RangeBars::GetMA2(double &MA[], int start, int count)
|
||||
|
||||
bool RangeBars::GetMA3(double &MA[], int start, int count)
|
||||
{
|
||||
Print(__FUNCTION__+" is deprecated, please use GetMA instead");
|
||||
|
||||
double tempMA[];
|
||||
if(ArrayResize(tempMA,count) == -1)
|
||||
return false;
|
||||
@@ -498,12 +563,13 @@ bool RangeBars::GetMA3(double &MA[], int start, int count)
|
||||
}
|
||||
|
||||
//
|
||||
// Get "count" Renko Donchian channel values into "HighArray[]", "MidArray[]", and "LowArray[]" arrays starting from "start" bar
|
||||
// Get "count" Donchian channel values into "HighArray[]", "MidArray[]", and "LowArray[]" arrays starting from "start" bar
|
||||
//
|
||||
|
||||
bool RangeBars::GetDonchian(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count)
|
||||
{
|
||||
return GetChannel(HighArray,MidArray,LowArray,start,count);
|
||||
Print(__FUNCTION__+" is deprecated, please use GetChannelData instead");
|
||||
return GetChannelData(HighArray,MidArray,LowArray,start,count);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -512,7 +578,8 @@ bool RangeBars::GetDonchian(double &HighArray[], double &MidArray[], double &Low
|
||||
|
||||
bool RangeBars::GetBollingerBands(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count)
|
||||
{
|
||||
return GetChannel(HighArray,MidArray,LowArray,start,count);
|
||||
Print(__FUNCTION__+" is deprecated, please use GetChannelData instead");
|
||||
return GetChannelData(HighArray,MidArray,LowArray,start,count);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -521,21 +588,27 @@ bool RangeBars::GetBollingerBands(double &HighArray[], double &MidArray[], doubl
|
||||
|
||||
bool RangeBars::GetSuperTrend(double &SuperTrendHighArray[], double &SuperTrendArray[], double &SuperTrendLowArray[], int start, int count)
|
||||
{
|
||||
return GetChannel(SuperTrendHighArray,SuperTrendArray,SuperTrendLowArray,start,count);
|
||||
Print(__FUNCTION__+" is deprecated, please use GetChannel function instead");
|
||||
return GetChannelData(SuperTrendHighArray,SuperTrendArray,SuperTrendLowArray,start,count);
|
||||
}
|
||||
|
||||
//
|
||||
// Get Channel values into "HighArray[]", "MidArray[]", and "LowArray[]" arrays starting from "start" bar
|
||||
//
|
||||
|
||||
bool RangeBars::GetChannel(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count)
|
||||
{
|
||||
return GetChannelData(HighArray,MidArray,LowArray,start,count);
|
||||
}
|
||||
|
||||
//
|
||||
// Private function used by GetRenkoDonchian and GetRenkoBollingerBands functions to get data
|
||||
//
|
||||
|
||||
bool RangeBars::GetChannel(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count)
|
||||
bool RangeBars::GetChannelData(double &HighArray[], double &MidArray[], double &LowArray[], int start, int count)
|
||||
{
|
||||
double tempH[], tempM[], tempL[];
|
||||
|
||||
#ifdef P_RANGEBAR_BR
|
||||
return false;
|
||||
#else
|
||||
if(ArrayResize(tempH,count) == -1)
|
||||
return false;
|
||||
if(ArrayResize(tempM,count) == -1)
|
||||
@@ -570,7 +643,6 @@ bool RangeBars::GetChannel(double &HighArray[], double &MidArray[], double &LowA
|
||||
ArrayFree(tempL);
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
int RangeBars::GetIndicatorHandle(void)
|
||||
@@ -584,12 +656,22 @@ int RangeBars::GetIndicatorHandle(void)
|
||||
iName = ChartIndicatorName(0,0,j);
|
||||
if(StringFind(iName,CUSTOM_CHART_NAME) != -1)
|
||||
{
|
||||
Print("Using handle of "+iName);
|
||||
return ChartIndicatorGet(0,0,iName);
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
Print("Failed getting handle of "+CUSTOM_CHART_NAME);
|
||||
return INVALID_HANDLE;
|
||||
}
|
||||
|
||||
double RangeBars::GetRuntimeId()
|
||||
{
|
||||
double runtimeId[1];
|
||||
|
||||
if(CopyBuffer(rangeBarsHandle, RANGEBAR_RUNTIME_ID, 0, 1, runtimeId) == -1)
|
||||
return -1;
|
||||
|
||||
return runtimeId[0];
|
||||
}
|
||||
Reference in New Issue
Block a user