Available translations

Target Rate

foundations.png
target-rate.png
The target rate is a reference rate that may affect simulations and that, in combination with the placement of managed stop loss and managed take profit targets, is used to determine whether the targets have been hit.
Content
Internal Use
The system needs to determine when the managed stop loss and managed take profit targets have been hit. To do this, the system observes how the user places the targets in relation to the target rate.
For example
If the phase 1 managed stop loss target is placed below the target rate and the phase 1 managed take profit target above it, the system assumes that:
  • the stop loss target is hit when the current rate is equal to or smaller than the managed stop loss value;
  • the stop loss target is hit when the current rate is equal to or greater than the managed take profit value;
This is how the system uses the target rate internally.
Fetching the Value from Formulas
Additionally, defining a target rate at the level of the stage may be of use so that you may retrieve the value from formulas while setting the rate of limit orders, using the path of the corresponding node at the trading engine.
For example, tradingEngine.tradingCurrent.position.entryTargetRate.value or tradingEngine.tradingCurrent.position.exitTargetRate.value.
Affecting How Simulations are Plotted
The target rates defined at the open and close stages affect how the Position Base Asset and Position Quoted Asset layers in the Simulation Objects layer manager draw the triangle representing the development of the trade.
The horizontal segment marks the target rate defined at the open stage. If you are using market orders to take the position, then using tradingEngine.tradingCurrent.tradingEpisode.candle.close.value may offer a good representation of the rate of market orders. If you are using limit orders, then you may decide at which rate you wish to take the position, and the horizontal segment of the triangle will match the chosen rate.
The third vertex of the triangle points to a [datetime, rate] coordinate. The datetime is given by the candle on which the manage stage closes, that is, the candle at which the stop loss or take profit targets are hit. The rate portion of the coordinate is given by the target rate defined in the close stage.
You may choose to apply a similar reasoning as with the open stage target rate for limit orders, but there is some nuance to consider if you are using market orders.
The issue arises when you run a testing session at a time frame higher than the time frame you use for live trading.
Why is that an issue?
Let's say your trading system makes decisions based on the close of the 1-hour candle. And let's say you are using stop loss and take profit targets. In such cases—when live trading—you may want to run your strategy in the 1-minute time frame, to detect the tagging of the take profit and stop targets as soon as possible, and act accordingly.
However, when backtesting, it is much faster to run sessions on the 1-hour time frame. This is particularly important when you wish to test significant time ranges.
When backtesting a strategy on the 1-hour time frame, the trading bot evaluates if stop loss and take profit targets have been hit at the close of the 1-hour candle, and may only act upon the evaluation on the next candle. This means that if you are using market orders to exit the position, the market order would be placed (in the simulation!) on the candle after one of the targets was hit.
The difference in rate between the moment in time the target is hit and the time the 1-hour candle closes may be significant. As a result, if the close stage target rate is defined as tradingEngine.tradingCurrent.tradingEpisode.candle.close.value, the resulting simulation may show significant slippage, and diverge from what the trade would look like if running on the 1-minute time frame, like you would when trading live.
To solve the above issue, you may use a more elaborate formula for the target rate in the close stage:
 targetRate()

function targetRate() {
    switch (tradingEngine.tradingCurrent.position.exitType.value) {
        case 'No Exit': {
            return tradingEngine.tradingCurrent.tradingEpisode.candle.close.value
            break
        }
        case 'Take Profit': {
            return tradingEngine.tradingCurrent.position.takeProfit.finalValue.value
            break
        }
        case 'Stop Loss': {
            return tradingEngine.tradingCurrent.position.stopLoss.finalValue.value
            break
        }
    }
}
This formula discriminates among three possible outcomes:
  • When no target has been hit, the value of the target rate is the close of the current candle.
  • When the take profit is hit, the value of the target rate is the last value of the take profit.
  • When the stop loss is hit, the value of the target rate is the last value of the stop loss.
Target Rate Menu
The Target Rate node has the following Node Menu items:
The Add Formula menu item has the following properties:
  • action: Add UI Object
  • disableIfPropertyIsDefined: true
  • propertyToCheckFor: formula
  • label: Add Formula
  • actionFunction: payload.executeAction
  • actionProject: Visual-Scripting
  • relatedUiObjectProject: Foundations
The Add Ask Portfolio Manager menu item has the following properties:
  • action: Add UI Object
  • label: Add Ask Portfolio Manager
  • disableIfPropertyIsDefined: true
  • propertyToCheckFor: askPortfolioFormulaManager
  • relatedUiObject: Ask Portfolio Formula Manager
  • actionFunction: payload.executeAction
  • relatedUiObjectProject: Portfolio-Management
  • actionProject: Visual-Scripting
The Add Outgoing Signals menu item has the following properties:
  • action: Add UI Object
  • actionProject: Visual-Scripting
  • disableIfPropertyIsDefined: true
  • propertyToCheckFor: outgoingSignals
  • actionFunction: payload.executeAction
  • label: Add Outgoing Signals
  • relatedUiObjectProject: Trading-Signals
The Add Incoming Signals menu item has the following properties:
  • action: Add UI Object
  • actionProject: Visual-Scripting
  • disableIfPropertyIsDefined: true
  • propertyToCheckFor: incomingSignals
  • actionFunction: payload.executeAction
  • label: Add Incoming Signals
  • relatedUiObjectProject: Trading-Signals
The Delete menu item has the following properties:
  • action: Delete UI Object
  • actionProject: Visual-Scripting
  • askConfirmation: true
  • confirmationLabel: Confirm to Delete
  • label: Delete
  • iconPathOn: delete-entity
  • iconPathOff: delete-entity
  • actionFunction: payload.executeAction
Target Rate Children
The Target Rate node has the following childrenNodesProperties:
The Formula node property features the following properties:
  • name: formula
  • type: node
  • autoAdd: true
The Ask Portfolio Formula Manager node property features the following properties:
  • name: askPortfolioFormulaManager
  • type: node
  • childType: Ask Portfolio Formula Manager
The Outgoing Signals node property features the following properties:
  • name: outgoingSignals
  • type: node
  • project: Trading-Signals
The Incoming Signals node property features the following properties:
  • name: incomingSignals
  • type: node
  • project: Trading-Signals
Target Rate Attaching Rules
The following are the Node Attaching Rules that govern the attachment of Target Rate with other nodes:
Compatible Types: