Disliked{quote} Has it been tried to re-code it so that it does not repaint?Ignored
Trading Equity Millipede Concept by Concept 99 replies
Proof of concept to make good pips 12 replies
Expert Advisor 8 replies
Can someone create for me an easy Expert Advisor? 0 replies
Interbank FX Expert Advisor how to program? 15 replies
//+------------------------------------------------------------------+ //| cl_vertex_auto_basis.mqh | //| Copyright 2018, the EDSTO team | //| https://www.forexfactory.com/showthread.php?t=800204 | //+------------------------------------------------------------------+ /*-- * This indicator can effectively show when to enter a new trade. * It is based on the indicator "vertex_mod_3.01 alerts + arrows". * * +-----------------------------------------------------------------+ * 06-08-2017 Version 1.00 * Initial version * +--------------------------------------------------------------+ */ #property copyright "Copyright 2018, the EDSTO team" #property link "https://www.forexfactory.com/showthread.php?t=800204" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+
// These are the buffers in the indicator:
// SetIndexBuffer(0, values);
// SetIndexBuffer(1, signal);
// SetIndexBuffer(2, band_up);
// SetIndexBuffer(3, band_dn);
// SetIndexBuffer(4, trend1);
// SetIndexBuffer(5, trend2);
enum MODE_VA {
VA_VALUE = 0, // Calculated raw values [Red]
VA_SIGNAL = 1, // Signal [Blue]
VA_BAND_UP = 2, // Bollinger Band High [Grey]
VA_BAND_DN = 3, // Bollinger Band Low [Grey]
VA_TREND1 = 4, // Trend 1
VA_TREND2 = 5 // Trend 2
};
// It's a custom indicator so we include the exact name
const string cVA_IndicatorName = "bim\\edsto\\vertex_mod_3.01_auto";
// A structure for holding all values
struct VA_VALUES {
double value;
double signal;
double band_high;
double band_low;
double trend1;
double trend2;
}; class cl_va_basis {
private:
// Parameters for iCustom
string _symbol;
ENUM_TIMEFRAMES _tframe;
// Parameters for the Indicator
int _processed; // Processed (2000)
int _ctrl_per; // Control period (14)
int _signal_period; // Signal period (5)
int _signal_method; // Signal method (SMA=0)
int _bb_period; // BB Period up/down (12)
int _bb_deviation; // BB Deviation (2)
double _lvl_ob; // Level Overbought (6)
double _lvl_os; // Level Oversold (-6)
double _xlvl_ob; // Level Extreme Overbought (10)
double _xlvl_os; // Level Extreme Oversold (-10) public:
cl_va_basis() { clear(); }
cl_va_basis(string &isym, ENUM_TIMEFRAMES itf);
~cl_va_basis() {}
void clear();
void setup(const string isym, const ENUM_TIMEFRAMES itf,
const int i_procd, const int i_ctrlper,
const int i_sigper, const int i_sigmethod,
const int i_bbper, const int i_bbdev,
const double lvlob, const double lvlos,
const double lvlxob, const double lvlxos,
);
// Setters
void set_symbol(const string &symbol) { _symbol = symbol; }
void set_tframe(const ENUM_TIMEFRAMES tf) { _tframe = tf; }
// Setters specific to this indicator
void set_processed(const int p) { _processed = p; }
void set_ctrl_per(const int p) { _ctrl_per = p; }
void set_signal_period(const int p) { _signal_period = p; }
void set_signal_method(const int m) { _signal_method = m; }
void set_bb_period(const int p) { _bb_period = p; }
void set_bb_deviation(const int d) { _bb_deviation = d; }
void set_lvl_ob(const double ob) { _lvl_ob = ob; }
void set_lvl_os(const double os) { _lvl_os = os; }
void set_xlvl_ob(const double ob) { _xlvl_ob = ob; }
void set_xlvl_os(const double os) { _xlvl_os = os; }
// Getters
string get_symbol() const { return _symbol; }
ENUM_TIMEFRAMES get_tframe() const { return _tframe; }
// Getters specific to this indicator
int get_processed() const { return _processed; }
int get_ctrl_per() const { return _ctrl_per; }
int get_signal_period() const { return _signal_period; }
int get_signal_method() const { return _signal_method; }
int get_bb_period() const { return _bb_period; }
int get_bb_deviation() const { return _bb_deviation; }
double get_lvl_ob() const { return _lvl_ob; }
double get_lvl_os() const { return _lvl_os; }
double get_xlvl_ob() const { return _xlvl_ob; }
double get_xlvl_os() const { return _xlvl_os; }
// Checkers
bool check_indi() const;
// Basic functions
double value(const string sym, const ENUM_TIMEFRAMES tf, const MODE_VA mode, const int i_shift=0) const;
double value(const ENUM_TIMEFRAMES tf, const MODE_VA mode, const int i_shift=0) const;
double value(const MODE_VA i_mode, const int i_shift=0) const;
void all_values(const string i_sym, const ENUM_TIMEFRAMES i_tf, const int i_shift, VA_VALUES &i_vals) const;
void all_values(const ENUM_TIMEFRAMES i_tf, const int i_shift, VA_VALUES &i_vals) const;
void all_values(const int i_shift, VA_VALUES &i_vals) const;
};
//---------------------------------------------------------------------
void cl_va_basis::setup(const string isym, const ENUM_TIMEFRAMES itf,
const int i_procd, const int i_ctrlper,
const int i_sigper, const int i_sigmethod,
const int i_bbper, const int i_bbdev,
const double i_lvlob, const double i_lvlos,
const double i_lvlxob, const double i_lvlxos) {
// Parameters for the iCustom command
_symbol = isym;
_tframe = itf;
//_mode = 0;
//_shift = 0;
// Parameters for the Indicator
_processed = i_procd; // Processed (2000)
_ctrl_per = i_ctrlper; // Control period (14)
_signal_period = i_sigper; // Signal period (5)
_signal_method = i_sigmethod; // Signal method (SMA=0)
_bb_period = i_bbper; // BB Period up/down (12)
_bb_deviation = i_bbdev; // BB Deviation (2)
_lvl_ob = i_lvlob; // Level Overbought (6)
_lvl_os = i_lvlos; // Level Oversold (-6)
_xlvl_ob = i_lvlxob; // Level Extreme Overbought (10)
_xlvl_os = i_lvlxos; // Level Extreme Oversold (-10)
}
// Fill the values with default values
void cl_va_basis::clear() {
setup(_Symbol, PERIOD_CURRENT, 2000, 14, 5, 0, 12, 2, 6.0, -6.0, 10.0, -10.0);
}
//---------------------------------------------------------------------
cl_va_basis::cl_va_basis(string &isym, ENUM_TIMEFRAMES itf) {
clear();
// Minimal set of parameters.
// Usually most other parameters will remain default.
_symbol = isym;
_tframe = itf;
//_shift = ishft;
}
// Test if the custom indicator works.
// Call it AFTER setup.
// 4055 = ERR_CUSTOM_INDICATOR_ERROR
// 4071 = ERR_INDICATOR_CANNOT_INIT
// 4072 = ERR_INDICATOR_CANNOT_LOAD
// 4075 = ERR_NO_MEMORY_FOR_INDICATOR
bool cl_va_basis::check_indi() const {
ResetLastError();
double x = value(VA_SIGNAL, 0);
int error = GetLastError();
if (error == 4055 || error == 4071 || error == 4072 || error == 4075) return true;
return false;
}
double cl_va_basis::value(
const string i_sym, // Symbol
const ENUM_TIMEFRAMES i_tf, // Timeframe
const MODE_VA i_mode, // Mode
const int i_shft=0 // Bar shift
) const {
return iCustom(
// Parameters for iCustom
i_sym, i_tf, cVA_IndicatorName,
// Parameters for the Indicator
_processed, // Processed (2000)
_ctrl_per, // Control period (14)
_signal_period, // Signal period (5)
_signal_method, // Signal method (SMA=0)
_bb_period, // BB Period up/down (12)
_bb_deviation, // BB Deviation (2)
_bb_period, // BB Period up/down (12)
_bb_deviation, // BB Deviation (2)
_lvl_ob, // Level Overbought (6)
_lvl_os, // Level Oversold (-6)
_xlvl_ob, // Level Extreme Overbought (10)
_xlvl_os, // Level Extreme Oversold (-10)
// Parameters for iCustom
(int)i_mode, i_shft
);
}
// Medium version of the standard value
double cl_va_basis::value(const ENUM_TIMEFRAMES i_tf, const MODE_VA i_mode, const int i_shift=0) const {
return value(_symbol, i_tf, i_mode, i_shift);
}
// Short version of the standard value
double cl_va_basis::value(const MODE_VA i_mode, const int i_shift=0) const {
return value(_symbol, _tframe, i_mode, i_shift);
}
// Collect all TDI values in one go - long version
void cl_va_basis::all_values(const string i_sym, const ENUM_TIMEFRAMES i_tf, const int i_shft, VA_VALUES &i_vals) const {
i_vals.value = value(i_sym, i_tf, VA_VALUE, i_shft);
i_vals.signal = value(i_sym, i_tf, VA_SIGNAL, i_shft);
i_vals.band_high = value(i_sym, i_tf, VA_BAND_UP, i_shft);
i_vals.band_low = value(i_sym, i_tf, VA_BAND_DN, i_shft);
i_vals.trend1 = value(i_sym, i_tf, VA_TREND1, i_shft);
i_vals.trend2 = value(i_sym, i_tf, VA_TREND2, i_shft);
}
// Collect all TDI values in one go - medium version
void cl_va_basis::all_values(const ENUM_TIMEFRAMES i_tf, const int i_shft, VA_VALUES &i_vals) const {
all_values(_symbol, i_tf, i_shft, i_vals);
}
// Collect all TDI values in one go - short version
void cl_va_basis::all_values(const int i_shft, VA_VALUES &i_vals) const {
all_values(_symbol, _tframe, i_shft, i_vals);
}
DislikedOne may ask, if this class is so simple, and just supports a simple interface, why not use iCustom directly in the Expert Advisor. These are my reasons: By using a class it is extremely easy to later change the indicator with a different one. I will use this class later in a child-class that has some more logic. In this way I separate the technicals (basic class) from the interpretation of what the values mean (advanced class).Ignored
It is important that we create an instance of the vertex-class only when the HA shows a signal. In this way we can be sure that the indicator is freshly refreshed. So the vertex class object must be defined as a local object.
Cheers...
DislikedJans, GitHub is free and very good. That works perfect in my opinion.Ignored
Disliked{quote} Yes, unfortunately and it works well in a trending market. Like the market is now....................... On 4hr in trending the repainting is very small as to be ignored. Try to confirm with other indies.Ignored
Dislikedmany thanks @ barryvdw, if one wants to setup an email or sms alert which email will one uses for the sender please?Ignored