TDesk Universal Drones - Usage Lessons

Locked
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

TDesk Universal Drones - Usage Lessons

Post by tomele »

 
Overview

This thread holds all usage advice for TDesk Universal Drones. It is organized in small lessons each addressing a single general or drone-specific aspect.

General Lessons
How to select the right Universal Drone
What you must know about indicator buffers
How to pass parameters to custom indicators

UBD (Universal Buffers Drone) Lessons
How to get started with UBD
How to use Metaquotes' built-in indicators
What the UBD inputs mean

USD (Universal Signals Drone) Lessons
How to get started with USD
Remarks on using HGI with USD
What the USD inputs mean
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

General Lesson - Drone Selection

Post by tomele »

How to select the right Universal Drone

Coming soon ...
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

General Lesson - Indicator Buffers

Post by tomele »

 
What you must know about indicator buffers

Buffers are data series very similar to price series like CLOSE, HIGH, LOW etc. Each buffer holds exactly one value for each bar in the chart. Each value is either a floating number or empty.

Imagine a moving average in your chart. This is in fact a buffer holding a calculated value for each bar. The graphical subsystem plots this as a curve that connects all those data points. Indicators that plot more than one line must have at least one buffer for each line.

A bi-colored curve or histogram is slightly different. One buffer is for the first color, another one for the second color. As one of them holds a value (and is plotted), the other usually is empty. But empty is not empty in the Empty4 world, as you will see.

Indicators like HGI use buffers to draw solitary symbols like arrows in the chart. They usually have one buffer for each symbol they can draw. All the buffers are empty most of the time. Only when a symbol gets drawn the respective buffer contains a single value for this one bar.

An empty buffer value is in fact not empty, but holds a value that is declared to be the EMPTY_VALUE. Per default that is the highest possible integer value (2147483647), but it can have been re-defined by the coder of the indicator. This can get important for defining the rules that Universal Drones shall follow. In some cases we will have to test a buffer for being "empty" or "not empty" and possibly don't know what empty means in hard numbers. More on this later.

Empty4 can display the buffers content in the so-called "Data Window". Load any indicator that draws curves (like Stochastics) on a chart. Now press Ctrl+D or click the crosshairs button to call up the Data Window. Hover the mouse over the chart and you will see your indicator and some values displayed there:
datawindow.jpg
Indicator buffers are counted from zero upwards, so the Stochastics main value (blue) line is the upper of the two. This value is held in buffer 0. Buffer 1 holds the value of the signal line - helpfully displayed as "Signal". Not all indicators are so helpful, but you can hover over any line in the chart to see a tooltip that helps you associate lines and buffers.

The left Data Window column shows the actual value (the last bar in the chart) while the second column shows the value for the bar your mouse is hovering over. Slowly hover from bar to bar and observe how the values in the buffers change. This way you can analyze how the indi buffers work and decide which Universal Drone and which rules to use for sending TDesk signals.
You do not have the required permissions to view the files attached to this post.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

General Lesson - Indicator Parameters

Post by tomele »

 
How to pass parameters to custom indicators

The following applies only to custom indicators, not to Empty4 built-in indicators. Latter are treated in the next topic. It applies to UBD (Universal Buffers Drone) and USD (Universal Signals Drone) only.

If UBD/USD makes a call to an indicator, the indicator default values as given in the source code are used. There is no chance to use a set file or pass parameters in an easy way like from an input field in UBD/USD. If you have the source code (.mq4 file) of the indicator, you can always edit those default values in the indicator inputs section and re-compile the indicator. As soon as you restart UBD/USD, the indicator will use those new default values.

If you don't want to do that or don't have the source code of an indicator, UBD offers a (relative) simple way to pass your desired parameters to that indicator. There should be a file "TDesk UBD (USD) Custom Parameters.mq4" in your \Libraries directory. Open this file in the MetaEditor and follow the instructions. You can define a maximum of 8 indicator parameter sets for each of both drones across one terminal. After you have made your changes, you must re-compile that file and also select the right parameter set for the respective indicator in the UBD inputs.


Step by step guide

First load the indicator you want to use with UBD/USD in any chart of your terminal. Now open the indicator window (Ctrl-I) and double-click the indicator's name. Now select the inputs tab. You will see something like this (probaly in another language):
inputs.jpg
These are the indicator inputs in the expected sequence line by line. If you have the source code of the indicator, the relevant section will look like this:

Code: Select all

extern ENUM_TIMEFRAMES   TimeFrame             = PERIOD_CURRENT;   // Time frame
extern int               HMAPeriod             = 15;               // Hma Period to use
input enPrices           HMAPrice              = pr_haweighted;    // Price to use
input enMaTypes          HMAMethod             = ma_lwma;          // Hma average type
input double             HMASpeed              = 1.8;              // Hma Speed
input int                HistoWidth            = 3;                // Histogram bars width
input color              UpHistoColor          = clrLimeGreen;     // Up histogram color
input color              DnHistoColor          = clrRed;           // Down histogram color
input bool               alertsOn              = false;            // Turn alerts on?
input bool               alertsOnCurrent       = false;            // Alerts on still open bar?
input bool               alertsMessage         = false;            // Alerts should show popup message?
input bool               alertsSound           = false;            // Alerts should play a sound?
input bool               alertsEmail           = false;            // Alerts should send email?
input bool               alertsPushNotif       = false;            // Alerts should send notification?
input bool               verticalLinesVisible  = false;            // Show vertical lines
input bool               linesOnNewest         = false;            // Vertical lines drawn on newest bar of higher time frame bar?
input string             verticalLinesID       = "hma Lines";      // Lines ID
input color              verticalLinesUpColor  = clrDeepSkyBlue;   // Lines up color 
input color              verticalLinesDnColor  = clrPaleVioletRed; // Lines down color
input ENUM_LINE_STYLE    verticalLinesStyle    = STYLE_DOT;        // Lines style
input int                verticalLinesWidth    = 0;                // lines width
For the following steps let's assume we want UBD/USD to use this indicator with a HMAPeriod of 20 and a HMAPrice being the median price.

There should be a file "TDesk UBD (USD) Custom Parameters.mq4" in your \Libraries directory. Open MetaEditor, find the file in the navigator window and open it. There are detailed instructions in it. Read them thoroughly. You will then see the section with the 8 parameter sets you can use across your terminal for each drone:

Code: Select all

#define Params_1 0,0,0
#define Params_2 0,0,0
#define Params_3 0,0,0
#define Params_4 0,0,0
#define Params_5 0,0,0
#define Params_6 0,0,0
#define Params_7 0,0,0
#define Params_8 0,0,0
We simply take the first unused one (Params_1) and overwrite the placeholder 0,0,0 with our desired parameters. Having read the instruction in the file, we know that we have to enter a complete comma-separated lists that holds all parameters up to the last one we want to pass. So we have to enter something like timeframe, 20, medianprice.

Our first parameter is a timeframe, as the indicator in this example is a multi-timeframe one. For use with UBD/USD the indicator timeframe must always be the current timeframe. So the first of our parameters must be PERIOD_CURRENT (or simply 0 as this is the respective index in the timeframes enumeration, see MQL4 reference).

Our second parameter is a simple value of 20.

Our last parameter is an enumeration of possible prices to use. For indicator-specific enumerations we have to use the numerical representation of the desired value as parameter. We find that by looking into the source code. If we don't have the source code, we can look into the list in the indicators input window. In this case, we have the source code and there is an enumeration enPrices just above. Unless nothing else is defined within the enumeration, the first element has the index 0 and then the index is increased by 1 for each following element. Now we count and find that the median price has the index 4:

Code: Select all

enum enPrices
{
   pr_close,      // Close
   pr_open,       // Open
   pr_high,       // High
   pr_low,        // Low
   pr_median,     // Median
   pr_typical,    // Typical
   pr_weighted,   // Weighted
   pr_average,    // Average (high+low+open+close)/4
   pr_medianb,    // Average median body (open+close)/2
   pr_tbiased,    // Trend biased price
   pr_tbiased2,   // Trend biased (extreme) price
   pr_haclose,    // Heiken ashi close
   pr_haopen ,    // Heiken ashi open
   pr_hahigh,     // Heiken ashi high
   pr_halow,      // Heiken ashi low
   pr_hamedian,   // Heiken ashi median
   pr_hatypical,  // Heiken ashi typical
   pr_haweighted, // Heiken ashi weighted
   pr_haaverage,  // Heiken ashi average
   pr_hamedianb,  // Heiken ashi median body
   pr_hatbiased,  // Heiken ashi trend biased price
   pr_hatbiased2, // Heiken ashi trend biased (extreme) price
   pr_habclose,   // Heiken ashi (better formula) close
   pr_habopen ,   // Heiken ashi (better formula) open
   pr_habhigh,    // Heiken ashi (better formula) high
   pr_hablow,     // Heiken ashi (better formula) low
   pr_habmedian,  // Heiken ashi (better formula) median
   pr_habtypical, // Heiken ashi (better formula) typical
   pr_habweighted,// Heiken ashi (better formula) weighted
   pr_habaverage, // Heiken ashi (better formula) average
   pr_habmedianb, // Heiken ashi (better formula) median body
   pr_habtbiased, // Heiken ashi (better formula) trend biased price
   pr_habtbiased2 // Heiken ashi (better formula) trend biased (extreme) price
};
Therefore our parameter string must be PERIOD_CURRENT,20,4 (or 0,20,4). We now enter this as Params_1 and make a comment to remember us for which indicator this was meant:

Code: Select all

#define Params_1 PERIOD_CURRENT, 20, 4 // HMA Histo
#define Params_2 0,0,0
#define Params_3 0,0,0
#define Params_4 0,0,0
#define Params_5 0,0,0
#define Params_6 0,0,0
#define Params_7 0,0,0
#define Params_8 0,0,0
Now we save and compile the file by pressing F7.

Our next step is to tell UBD/USD to use this indicator with parameter set 1. We open the input window of UBD/USD, enter the indicator name and select the parameter set like this:
parameters.jpg
Our last step is to protocol the settings in the appropriate input fields at the end of the UBD/USD input section. This way others (and we ourselves) always see at a glance which parameters are required for this UBD/USD setting:
notes1.jpg
Et voilà, we are done. In most cases this process will be much easier and you will only have to enter some numerical values. But you had to learn the handling of timeframes and enumerations, hence this complicated example.
You do not have the required permissions to view the files attached to this post.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

UBD Lesson - Getting Started

Post by tomele »

 
How to get started with UBD

UBD is the interface to nearly all indicators that use buffers to draw lines or histograms in the main chart or a subchart. I estimate that 90 percent of all indicators belong to that group. All built-in indicators like MACD, Stochastics, Moving Averages and most custom indicators like SuperSlope belong to this group. UBD is multi-pair and multi-timeframe and needs to run in only one instance. The indicator itself is not needed to be running.

UBD uses iCustom calls to receive values from specific indicators and buffers for specific pairs, timeframes and candles. It then uses two user-specified rules to decide whether a LONG, SHORT or FLAT signal will be sent to TDesk. One of these two rules defines the condition for a LONG signal while the other defines the condition for a SHORT signal. Should none (or both) of the conditions be met, a FLAT signal is sent to TDesk.

Each rule consists of two operands that get compared by an operator. The possible operators are the usual ones like Greater, LessOrEqual, NotEqual and so on. Two special operators are CrossUp and CrossDown, which indicate a crossover of the two operands in a certain direction.

The possible operands on the left comparison side of each rule can be one of these:

* indicator buffer value (indicator identifier, buffer number¹, bar shift)
* indicator buffer average (indicator identifier, buffer number¹, bar shift, smoothing period)
* price series (price series identifier, bar shift)

The possible operands on the left comparison side of each rule can be one of these:

* indicator buffer value (indicator identifier, buffer number¹, bar shift)
* indicator buffer average (indicator identifier, buffer number¹, bar shift, smoothing period)
* price series (price series identifier, bar shift)
* constant value (value)
* constant value range (upper value, lower value)
* the "empty value" of the indicator (default 2147483647)

¹ only relevant for custom indicators, for built-in indicators see here.

As UBD allows to use two different custom indicators with 8 sets of parameters and 8 sets of built-in indicators/parameters, you can compare nearly everything to everything. From simple comparisons like a buffer value to a constant value up to complicated ones like two different buffer averages of two different indicators.


How to create an UBD rule set

Creating an UBD rule set is much easier than you might think. First analyze the indicator buffers as described in What you must know about indicator buffers. As soon as you have an idea how the buffers work, decide about the operands you need to use and the operators for the LONG and SHORT condition. Most likely the first operand will be an indicator buffer value (called "the line"). The second one depends on the situation. Here are some examples:

* You want to send a directional signal if the line is sloping up or down. Your operator in the conditions needs to be "Greater" for LONG and "Less" for SHORT and your second operand in both conditions needs to be the same as the first operand, but shifted by 1 (indicating the previous bar).

* You want to send a directional signal if the line is an oscillator in a subwindow and goes above/below a constant value of 80/-80. Your operator in the LONG condition needs to be "Greater" and your second operand a constant value of 80. Your operand in the SHORT condition needs to be "Less" and your second operand a constant value of -80.

* You want to send a directional signal if the line goes above/below its own average. Your operator in the conditions would again be "Greater"/"Less" , but your second operand would be an average of the same indicator buffer.

* You want to send a directional signal if the commodity close price goes above/below an indicator line in the main chart. This time your first operand would be the desired price series, your operator would again be "Greater"/"Less" and your second operand would be the value of the indicator buffer.

A special situation exists if you need to send directional signals having two or more buffers for multi-colored lines ore histograms. Now you need to define rules based on which buffers are empty or not. As described above, "empty" is a constant value. Per default this EMPTY_VALUE is 2147483647. In this case, "not empty" would mean being anything different to this. If this doesn't work, you will have to find out the EMPTY_VALUE value. Each chart has a plausible maximum and minimum and the EMPTY_VALUE mut be outside of this range. It is either above or below the range and "not empty" means a value within the range. So just test "Greater"/"Less" as operator and values just outside the range. One of these will work.


Step by step guide

Let's assume we want to send signals to TDesk based on the indicator i-BandsPrice. This is the first example indicator in this post: viewtopic.php?f=106&t=5654&p=167167#p167167.

This is a custom indicator and we have the source code. Would we want to alter the settings for UBD usage, we would now do so in the source code and re-compile or we would follow these steps: How to pass parameters to custom indicators.

Would this indicator be a built-in one, we would have to follow these steps first: How to use Metaquotes' built-in indicators

Now we analyze the buffers as described in What you must know about indicator buffers and know that this indicator is an oscillator with one buffer that draws a line in a subwindow.

Now we have to decide what should be a long and short signal. This could be the indicator sloping up or down, the indicator being above or below the 0.5 center line or (inversed) the indicator being below 0.25 or above 0.75 as an oversold/overbought signal. We decide to do something more special. The signal shall be LONG if the indicator is above its own 15-period average and SHORT if it is below.

This means the following LONG condition: The value of our indicator buffer 0 must be greater than the average (15) of our indicator buffer 0. For the SHORT condition it must be less.

Now we enter our rules in the UBD input window. We call the signal IBP and append/enter this in the first two fields. We enter the pairs, timeframes etc as well as the indicator name in the respective fields:
ubd1.jpg
Now we enter our LONG and SHORT rules. First operand for both is BufferValue, the indicator is (custom) indicator 1, the buffer is 0, the shift is 0, the rest is irrelevant and can stay unchanged. Second operand for both is BufferAverage, the indicator is also (custom) indicator 1, the buffer is also 0, the shift is also 0, the smoothing is 15, the rest is again irrelevant and can stay unchanged. Operator for LONG is Greater, for SHORT is Less:
ubd2.jpg
Now we are done. UBD will compute the rules and show them to us for checking:
und3.jpg
That's all, folks.
You do not have the required permissions to view the files attached to this post.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

UBD Lesson - Built-in Indicators

Post by tomele »

 
How to use Metaquotes' built-in indicators

The following applies only to Empty4 built-in indicators, not to custom indicators.

It is not easy for UBD to use the built-in indicators, as each of those around 30 indicators has to be called by its own function with its own unique parameter set. The ancient way to integrate them would be a list of probably 200 inputs to provide every parameter for every indicator. There are experts out there that do just that - real monsters.

Universal Drones have to be as sleek and simple as possible. Thus the integration of the built-in indicators had to take a different way. Starting with UBD 1.4, there should be a file "TDesk UBD Builtin Indicators.mq4" in your \Libraries directory. Open this file in the MetaEditor and follow the instructions. You can define a maximum of 8 built-in function/parameter sets across one terminal. After you have made your changes, you must re-compile that file and also select the right built-in set in the UBD inputs.


Step by step guide

First you have to find out the name of the function for the built-in indicator you want to use in UBD. My preferred way to do this is to open the MetaEditor and use the menus Help -> MQL4 Reference to open the language reference. In the first tab click on the group "Technical Indicators" which offers all available indicators. You can use all of them except iCustom, iFractals, iOsMA and the ...OnArray ones. Usable are: iAC, iAD, iADX, iAlligator, iAO, iATR, iBearsPower, iBands, iBullsPower, iCCI, iDeMarker, iEnvelopes, iForce, iGator, iIchimoku, iBWMFI, iMomentum, iMFI, iMA, iMACD, iOBV, iSAR, iRSI, iRVI, iStdDev, iStochastic and iWPR.

Click the indicator function you want to use to open a page with more information and a list of parameters that have to be passed when calling the function.

There should be a file "TDesk UBD Builtin Indicators.mq4" in your \Libraries directory. Open MetaEditor, find the file in the navigator window and open it. There are detailed instructions in it. Read them thoroughly. You will then see the section with the 8 function/parameter sets you can use across your terminal:

Code: Select all

#define Builtin_Functn_1 iDummy
#define Builtin_Params_1 0,0,0

#define Builtin_Functn_2 iDummy
#define Builtin_Params_2 0,0,0

#define Builtin_Functn_3 iDummy
#define Builtin_Params_3 0,0,0

#define Builtin_Functn_4 iDummy
#define Builtin_Params_4 0,0,0

#define Builtin_Functn_5 iDummy
#define Builtin_Params_5 0,0,0

#define Builtin_Functn_6 iDummy
#define Builtin_Params_6 0,0,0

#define Builtin_Functn_7 iDummy
#define Builtin_Params_7 0,0,0

#define Builtin_Functn_8 iDummy
#define Builtin_Params_8 0,0,0
Having read the instruction in the file, you know that you have to enter the function name and a complete comma-separated list that holds all parameters per the language reference except the first two (symbol and timeframe) and the last one (shift). The buffer that shall be used (if more than one are defined for this indicator) is part of the parameters here. The UBD setting doesn't matter.

Now simply select the first unused function/parameter set and overwrite the placeholder iDummy with the function name (for example iMACD) and the placeholder 0,0,0 with the needed parameters (for example 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL):

Code: Select all

#define Builtin_Functn_1 iMACD
#define Builtin_Params_1 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL
There ares four functions that don't need any parameters. Those are iAC, iAD, iAO, iBWMFI, For these, comment out the second (parameters) line:

Code: Select all

#define Builtin_Functn_1 iAC
// #define Builtin_Params_1 0,0,0
When you are done, you must compile (F7) this library into the \Libraries folder. If you made any mistakes, you will get a compiler error hinting to the problem.

The next step is to tell UBD to use this function/parameter set. Open the input window of UBD and select the correct function/parameter set for any operand:
builtin.jpg
The last step is to protocol the functions and parameters in the appropriate input fields at the end of the UBD input section. This way others (and you) always see at a glance what functions and parameters are required for this UBD setting:
notes2.jpg
Et voilà, you are done.
You do not have the required permissions to view the files attached to this post.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

UBD Lesson - Inputs Description

Post by tomele »

 
What the UBD inputs mean

General Settings

ProviderName
SignalName

Provider and signal name that get delivered to TDesk. A number (1..4) for the timeframe will get appended to the signal name.

SignalMaxAgeBars
A new signal signal sent to TDesk will only be existent for the "SignalMaxAgeBars" number of bars. After this span it will flip back to FLAT. If you don't want to restrict the max age, set it to 0.

IgnoreOpenCandles
RefreshSeconds
MagicNumber

They are self-explaining, aren't they?

Symbols And Timeframes

CurrenciesToCombine
Enter all currencies (not pairs) you want to trade as a comma separated list. All valid combinations of theses currencies (symbols/pairs) will be added to the trade list. For example, if you enter AUD,USD,EUR in this field, the trade list will contain AUDUSD, EURAUD and EURUSD.

SymbolsToInclude
Enter all additional symbols you want to trade. These can be pairs that are not generated from the CurrenciesToCombine list or CFDs, metals, commodities and the like. They will be added to the trade list.

SymbolsToIgnore
Enter all symbols pairs that are generated from the CurrenciesToCombine list, but you don’t want to trade. They will be deleted from the trade list.


SymbolPrefix
SymbolSuffix
If needed, symbol prefix and/or suffix can be entered in the respective field.

Timeframe_1
Timeframe_2
Timeframe_3
Timeframe_4

Timeframes for mult-timeframe operation. If you need less, set the unused to "Unused".

Indicator 1 Settings

Indicator 1 is the first of two custom indicators UBD can interface to. Metaquotes' built-in indicators can not be used here. Built-in indicators can be selected as operands below.

Indi_1_Name
Enter the file name of the indicator without extension. The indicator must be in the \Indicators directory as a compiled file.

Indi_1_Params
UBD offers a very sophisticated method of passing arguments to indicators. For more details see How to pass parameters to custom indicators

Indi_1_EmptyValue
Enter the EMPTY_VALUE of the indicator here if it is different to the default of 2147483647.


Indicator 2 Settings

You only need this section if you want to compare two indicators.

Indi_2_Name
Indi_2_Params
Indi_2_EmptyValue

See section above.

LONG Signal Condition

In this section you have to define the rules for a LONG signal.

LONG_Operand_1_Type
Enter the type of the operand on the left side of the comparison. Possible types are BufferValue, BufferAverage and PriceSeries.

LONG_Operand_1_Indi
If the operand type on the left side of the comparison is BufferValue or BufferAverage, specify which indicator to use here or "None" if you don't use buffers here. You can select one of the two custom indicators specified above or one of eight built-in indicator/parameter sets. For more details see How to use Metaquotes' built-in indicators

LONG_Operand_1_Buffer
If the operand type on the left side of the comparison is BufferValue or BufferAverage and the indicator is a custom indicator, specify which of the indicator buffers to use (most probably buffer 0 is right). If the indicator is a built-in indicator, see more details at How to use Metaquotes' built-in indicators

LONG_Operand_1_Shift
If the operand type on the left side of the comparison is BufferValue or BufferAverage or PriceSeries, specify the bar shift to use here (most probaly 0 is right, as open candles get excluded in the general settings section).

]LONG_Operand_1_Smooth
UBD offers use of buffer averages as rule operands. Enter the smoothing period for the buffer here. Smoothing method is always SMA.

LONG_Operand_1_Price
If the type of operand on the left side of the comparison is PriceSeries, specify the price series to use or "Void" if you don't use prices here.

LONG_Operator
Specify the operator to use for the comparison. Possible operators are Greater, GreaterOrEqual, Equal, NotEqual, LessOrEqual, Less, UpCross and DownCross. If you are dealing with ranges, "equal" means "within range", "less" means "less than lower border" and "greater" means "greater than upper border".Note that the last two (crosses) only give a signal for exactly one bar, while the others give a signal for multiple bars, as long as the condition is fulfilled.

LONG_Operand_2_Type
Enter the type of the operand on the right side of the comparison. Possible types are BufferValue, BufferAverage, PriceSeries, ConstantValue, ConstantRange and EmptyValue (EMPTY_VALUE of the indicator).

LONG_Operand_2_Indi
LONG_Operand_2_Buffer
LONG_Operand_2_Shift
LONG_Operand_2_Smooth
LONG_Operand_2_Price
Analogue to the left side

LONG_Operand_2_Const
If the type of operand on the right side of the comparison is ConstantValue, specify the value to use here.

LONG_Operand_2_Upper
LONG_Operand_2_Lower
If the type of operand on the right side of the comparison is ConstantRange, specify the upper and lower value of the range to use here.


SHORT Signal Condition

In this section you have to define the rules for a SHORT signal.

SHORT_Operand_1_Type
SHORT_Operand_1_Indi
SHORT_Operand_1_Buffer
SHORT_Operand_1_Shift
SHORT_Operand_1_Smooth
SHORT_Operand_1_Price
SHORT_Operator
SHORT_Operand_2_Type
SHORT_Operand_2_Indi
SHORT_Operand_2_Buffer
SHORT_Operand_2_Shift
SHORT_Operand_2_Smooth
SHORT_Operand_2_Price
SHORT_Operand_2_Const
SHORT_Operand_2_Upper
SHORT_Operand_2_Lower

Inputs for the SHORT condition. Analogue to LONG condition.

Library Plugins Advice

These fields have no effect on UBD. They are protocol fields where you can note which functions and/or parameters are required for this setting in the library plugins and make other comments that help users (and yourself to remember).

ParamsForCustomIndi_1
ParamsForCustomIndi_2
These fileds let you protocol what parameters are needed for the custom indicators Indi_1 and Indi_2 in "TDesk UBD Custom Parameters" (if any).

FirstBuiltinIndiName
FirstBuiltinIndiParams
SecondBuiltinIndiName
SecondBuiltinIndiParams
These fileds let you protocol which functions and parameters are needed for a maximum of two built-in indicators in "TDesk UBD Builtin Indicators" (if any).

CommentLine_1
CommentLine_2
CommentLine_3
These fields offer you a possibility to note any comments users should know.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

USD Lesson - Getting Started

Post by tomele »

 
How to get started with USD

USD is the interface to nearly all indicators that use buffers to draw solitary symbols in the main chart or a subchart as entry and exit signals. HGI is an example for this type of indicators. USD is multi-pair and multi-timeframe and needs to run in only one instance. The indicators themselves are not needed to be running.

USD uses iCustom calls to receive values from specific indicators and buffers for specific pairs, timeframes and candles. It uses three user-specified rules. The first of these rules defines the condition for a LONG signal, the second defines the condition for a SHORT signal and the third defines the condition for a EXIT (FLAT) signal. USD sifts through the history to determine which signal was the most recent valid one. This signal is then sent to TDesk.

Each of the three rules rule consists of two operands that get compared by an operator. The possible operators are the usual ones like Greater, LessOrEqual, NotEqual and so on.

The operands on the left side of the comparison are up to five indicator buffers (signals) that can get connected by one of the following three logics:

* any (only one of the buffers must have met the condition)
* most (more than half of the buffers must have met the condition)
* all (all buffers must have met the condition)

The operands on the right side of the comparison can be one of these:

* constant value (value)
* constant value list (comma-separated list of values)
* price series (price series identifier)
* the "empty value" of the indicator (default 2147483647)

Although the indicator buffer signals are usually existent for only one bar (like an entry arrow), "meeting the condition" is defined different in USD. As soon as a incoming signal appears, this value for this buffer is kept valid over a certain number of bars. Thus you can define that certain incoming signals must appear within a specified number of bars to give a valid outgoing signal. The overall (outgoing) signal that is sent to TDesk is also kept valid for a specified number of bars. May sound complicated, but in fact is not. Imagine the following: As soon as an entry arrow appears on a bar, identical arrows are plotted on all subsequent bars until an exit signal appears. More details below.


How to create an USD rule set

Creating an USD rule set is not difficult. First analyze the indicator buffers as described in What you must know about indicator buffers. As soon as you have an idea how the buffers work, decide about the operands you need to use and the operators for the three condition. The first operands are always one or more indicator buffers, eventually connected by some logic. The second operands are most likely a price series or the "empty value". Here are some examples (based on HGI, which most of you are familiar with):

* You want to send a directional signal if a big "Trend Buy" or "Trend Sell" arrow appears. As these are two different buffers (0 and 1), you can compare them to the indicator's "empty value" to detect whether each signal is present or not. For the LONG condition, your first operand is buffer 0, your operater is "NotEqual" and your second operand is "EmptyValue". For the SHORT condition, your first operand is buffer 1, your operater is "NotEqual" and your second operand is "EmptyValue".

* You want to send a directional signal if a "Wavy Trend" symbol appears above or below the price bar. As LONG and SHORT wavies are held in the same buffer (7), you can't simply compare them to the indicator's "empty value". You must detect whether the wavy is above or below the bar. Thus for the LONG condition, your first operand is buffer 7, your operater is "Less" and your second operand is "PriceSeries" "Median_Price". For the SHORT condition, your first operand is also buffer 7, your operater is "Greater" and your second operand is "PriceSeries" "Median_Price".

* You want to send a EXIT (FLAT) signal if a "Wavy Range", a "Range Buy" or a "Range Sell" symbol appears. These are three different buffers (2, 3 and 6) and you can compare them to the indicator's "empty value" to detect whether each signal is present or not. For the EXIT (FLAT) condition, your first operand is a combination of buffers 2, 3 and 6 with the logic "Any", your operater is "NotEqual" and your second operand is "EmptyValue".


Step by step guide

Let's assume we want to send signals to TDesk based on HGI_v16.09. This is a custom indicator and we don't have the source code.

First we analyze the buffers as described in What you must know about indicator buffers. Luckily the HGI buffers have very speaking names. By hovering the mouse over the arrows in the chart, we quickly understand how arrows and buffers are correlated:
buffers.jpg
Now we have to define a strategy and decide what should be our LONG, SHORT and EXIT (FLAT) conditions. Let's say the LONG condition is having a big "Trend Buy" AND a "Wavy Trend" subsequently in the same direction, the SHORT condition is having a big "Trend Sell" AND a "Wavy Trend" subsequently in the same direction and the EXIT (FLAT) condition is the appearence of a "Wavy Range"or one of the "Range Buy/Sell" signals.

As all "Wavy Trend" values are held in the same buffer for LONG and SHORT, we can't base our conditions on comparing the buffer to the "empty value". Thus we must check whether the symbols are plotted below (LONG) or above (SHORT) the price to have the directional information. The FLAT condition is simpler, as we can test for any buffer being not empty. This leads to the following conditions:

* LONG: The value of ALL buffers 0, 7 must be LESS than MEDIAN PRICE.
* SHORT: The value of ALL buffers 0, 7 must be GREATER than MEDIAN PRICE.
* EXIT (FLAT): The value of ANY buffers 2, 3, 6 must be NOT EQUAL to EMPTY VALUE.

First we need to set the first HGI input (isiCustom) to true for USD (iCustom) usage according to these steps: How to pass parameters to custom indicators. We create a parameter set for HGI and enter it in "TDesk USD Custom Parameters":

Code: Select all

#define Params_1 true // HGI_v16.09
Now we enter our settings in the USD input window. We call the signal HGI and append/enter this in the first two fields. We enter the pairs, timeframes etc as well as the indicator name and the custom parameter set from above in the respective fields:
inputs.jpg
Now we enter our conditions. First operands for LONG and SHORT are buffers 0/1 and 7 (-1 means unused), the logic is "All". Second operand for both is "PriceSeries", the price is "Median_Price", the rest is irrelevant and can stay unchanged. Operator for LONG is "Less", for SHORT is "Greater":
longshort.jpg
First operand for EXIT (FLAT) are buffers 2, 3 and 6 , the logic is "Any". Second operand is "EmptyValue", the rest is irrelevant and can stay unchanged. Operator is "NotEqual":
flat.jpg
Now we are nearly done. To complete our work, we enter some instructions and comments at the end of the inputs section:
comments.jpg
After clicking OK, USD will compute the rules and show them to us for checking:
window.jpg
That's all, folks.
You do not have the required permissions to view the files attached to this post.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

USD Lesson - Using HGI

Post by tomele »

 
Remarks on using HGI with USD

It has been discussed forth and back at SHF and should be well-known that HGI "repaints". Everyone complaining about this must know that he is attracting the immediate ire of huge dragons. HGI is only meant to be used in the here and now. It can't be used for backtesting because some historical signals might not be at the same position they had been a while before. They are wandering around.

This has some implications for USD.

In the post above, I have (as an example) shown you how to use HGI with USD by calling it via iCustom calls. This is a very fast method, but has a serious drawdown: It works like having HGI on a chart without ever refreshing it. Instead of a signal that is wandering around, you will have umpteen identical signals around a specific position in the chart. What USD "sees", is this:
1.png
The better way to use HGI is to refresh the whole chart on each calculation. The HGI originators have provided us with the library "hgi_lib" for this purpose. Using this library ensures that the whole calculation is reset and started anew from the beginning on each call. All the HGI-based tools that René, myself and others have published over the time, are based on this library. What USD "sees", would look like the same chart after refreshing:
2.png
I have added the option to use this library in USD. Simply enter "HGI" as indicator name and all calls will be re-directed to the library instead to the indicator. The buffer logic will be emulated and stay the same as if you would call the indicator. Custom parameters are not needed.

So why would anyone wish to still use the iCustom indicator calls? Simple answer: Because using the library is very CPU-intensive. On each call for each bar in the lookback range and each timeframe and each pair there is a lot to compute. The library doesn't just calculate the last bar, it re-calculates all bars.

On my machine, which is not the slowest one, calculating 4 timeframes for 28 pairs and a lookback of 100 bars (11,200 HGI library calls) takes 6-9 seconds, although the code is already optimized. This happens every refresh cycle (default 60 seconds) and the terminal doesn't respond for this period. This can (and will) become an issue for you. Keep that in mind.

Examples for both settings are at TDesk Universal Drones Examples


Executive Summary:

Using HGI via iCustom calls (Indicator_Name = HGI_v16.09 or else) is fast. But the results will differ from other HGI providers like "MTF HGI Bars TD V2". Whoever complains about this, will be shot by a standing command because he did not RTFM.

Using HGI via the library calls (Indicator_Name = HGI) is slow. But the results will be exactly the same as those of other HGI providers like "MTF HGI Bars TD V2". Keep the load down by reducing the number of timeframes and pairs. Try to reduce the number of lookback bars (50 should be enough, even 25 work with only small deviations). Otherwise you will be shot by the parts of your exploding machine.
You do not have the required permissions to view the files attached to this post.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

USD Lesson - Inputs Description

Post by tomele »

 
What the USD inputs mean

General Settings

ProviderName
SignalName

Provider and signal name that get delivered to TDesk. A number (1..4) for the timeframe will get appended to the signal name.

SignalMaxAgeBars
A new signal signal sent to TDesk will only be existent for the "SignalMaxAgeBars" number of bars. After this span it will flip back to FLAT. If you don't want to restrict the max age, set it to 0.

LookBackBars
USD has to sift through history to find the most recent signal. You can limit the number of bars here.

IgnoreOpenCandles
RefreshSeconds
MagicNumber

They are self-explaining, aren't they?

Symbols And Timeframes

CurrenciesToCombine
Enter all currencies (not pairs) you want to trade as a comma separated list. All valid combinations of theses currencies (symbols/pairs) will be added to the trade list. For example, if you enter AUD,USD,EUR in this field, the trade list will contain AUDUSD, EURAUD and EURUSD.

SymbolsToInclude
Enter all additional symbols you want to trade. These can be pairs that are not generated from the CurrenciesToCombine list or CFDs, metals, commodities and the like. They will be added to the trade list.

SymbolsToIgnore
Enter all symbols pairs that are generated from the CurrenciesToCombine list, but you don’t want to trade. They will be deleted from the trade list.


SymbolPrefix
SymbolSuffix
Comma-separated list of symbols for multi-pair operation. If needed, symbol prefix and/or suffix can be entered in the respective field.

Timeframe_1
Timeframe_2
Timeframe_3
Timeframe_4

Timeframes for mult-timeframe operation. If you need less, set the unused to "Unused".

Indicator Settings

Indicator_Name
Enter the file name of the indicator without extension. The indicator must be in the \Indicators directory as a compiled file. Enter "HGI" for the built-in HGI function.

Indicator_Params
UBD offers a very sophisticated method of passing arguments to indicators. For more details see How to pass parameters to custom indicators

Indicator_EmptyValue
Enter the EMPTY_VALUE of the indicator here if it is different to the default of 2147483647.

Indicator_MaxAgeBars
Enter a number of bars after which a signal expires. "0" means "no expiry". This is used if you want two or more indicator signals to appear within a given number of bars to create a valid output signal. If you don't want to restrict the span, set it to 0.

LONG Signal Condition

In this section you have to define the rules for a LONG signal.

LONG_Buffer_A
LONG_Buffer_B
LONG_Buffer_C
LONG_Buffer_D
LONG_Buffer_E
Enter the buffer numbers you want to use on the left side of the comparison. "-1" means "unused".

LONG_Buffers_Logic
You have three options to logically connect the buffers above:

* Any (only one of the buffers must have met the condition)
* Most (more than half of the buffers must have met the condition)
* All (all buffers must have met the condition)

LONG_Operator
Specify the operator to use for the comparison. Possible operators are Greater, GreaterOrEqual, Equal, NotEqual, LessOrEqual, Less. If you are dealing with lists, "equal" means "contained in list", "less" means "less than lowest of list" and "greater" means "greater than highest of list".

LONG_Operand_Type
Enter the type of the operand on the right side of the comparison. Possible types are ConstantValue, ConstantValueList, PriceSeries and EmptyValue.

LONG_Operand_Const
If the operand type on the right side of the comparison is ConstantValue, specify the value to use here.

LONG_Operand_List
If the operand type on the right side of the comparison is ConstantValueList, specify the values to use here as a comma-separated list.

LONG_Operand_Price
If the type of operand on the right side of the comparison is PriceSeries, specify the price series to use or "Void" if you don't use prices here.

SHORT Signal Condition

SHORT_Buffer_A
SHORT_Buffer_B
SHORT_Buffer_C
SHORT_Buffer_D
SHORT_Buffer_E
SHORT_Buffers_Logic
SHORT_Operator
SHORT_Operand_Type
SHORT_Operand_Const
SHORT_Operand_Price
Inputs for the SHORT condition. Analogue to LONG condition.

EXIT Signal Condition

EXIT_Buffer_A
EXIT_Buffer_B
EXIT_Buffer_C
EXIT_Buffer_D
EXIT_Buffer_E
EXIT_Buffers_Logic
EXIT_Operator
EXIT_Operand_Type
EXIT_Operand_Const
EXIT_Operand_Price
Inputs for the EXIT (FLAT) condition. Analogue to LONG condition.

Library Plugins Advice

These fields have no effect on USD. They are protocol fields where you can note which functions and/or parameters are required for this setting in the library plugins and make other comments that help users (and yourself to remember).

ParamsForIndicator
This field lets you protocol what parameters are needed for the custom indicator in "TDesk USD Custom Parameters" (if any).

CommentLine_1
CommentLine_2
CommentLine_3
These fields offer you a possibility to note any comments users should know.
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
Locked

Return to “TDesk: A Thomas Special. The greatest trading tool ever.”