Different bots running within the system produce data products that others may consume. These products are available for you to use within your strategies.
Datasets are stored as a collection of sequential records and you may access any of the properties (fields) of each record.
To do that, you will use the following syntax:
The above syntax returns the value of the property of the declared product at the latest closed candle. This is common throughout all available datasets.
Specifying the Time Frame
When building conditions and formulas, you may want to use analysis concerning different time frames. This is perfectly possible.
The variables explained further down this section, written as described for each indicator, are not valid unless they are preceeded by the declaration of the time frame they refer to.
To do that, you need to preceed the above syntax with the following:
Therefore, the complete syntax to build a valid statement is:
time frame +
chart.at04hs.candle.close > chart.at04hs.candle.previous.close
The above statement compares the current 4 hours candle to the previous 4 hours candle.
The complete list of time frames available is:
previous property is a property common to all products that allows you to retrieve the value of the candle that closed previous to the last one.
The property is used with the following syntax:
time frame +
.propertyName. You may use the property on any of the indicators in a similar way.
In addition, you may use the
previous property more than once, to retrieve values further in the past:
time frame +
.previous.previous... ...previous +
chart.at1hs.candle.previous.previous.max returns the maximum value of two candles before the last closed candle at the 1-hour chart.
Alternative to the Previous Property
There is a cool alternative to the previous property, that you can use to fetch the value of a property beyond the last closed candle.
The syntax is
productName.[currentCandleIndex-n].propertyName where currentCandleIndex represents the last closed candle and n may be replaced by any integer number.
chart.at1hs.candle.[currentCandleIndex-5].max retrieves the maximum value of the fifth candle previous to the last closed candle at the 1-hour chart.
Comparison and Logical Operators
To define conditions you will use statements using the syntax described above. You will use the properties of indicators that will be introduced later on. The data behind those indicators describe what is happening with the market.
Remember, conditions need to evaluate either true or false.
To create such statements you will use comparison and logical operators:
|===||equal value and equal type|
|>=||greater than or equal to|
|<=||less than or equal to|
chart.at01hs.candle.close > chart.at01hs.bollingerBand.MovingAverage(the latest candle at the 1 hour chart closed above the Bollinger Bands moving average).
chart.at01hs.candle.previous.max > chart.at01hs.bollingerBand.previous.MovingAverage(the maximum value of the candle before the last one, was higher than the Bollinger Bands moving average)
In the example above, conditions A and B are comparison statements that may evaluate either true or false. In the case both would evaluate true then Situation 1 would be true as well.
- Condition C:
chart.at04hs.candle.max <= 10000 && chart.at04hs.candle.min >= 9000(the entire candle at the 4 hours chart fits within the price range between 9000 and 10000)
In the example above, condition C would be true if the whole 4-hour candle falls within the range between 9000 and 10000. If this is true, then situation 2 is true as well, as there is only one condition to check.