Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Welcome to the documentation for creating custom indicators in Forex Tester Online (FTO).
This guide is designed to help developers and strategy testers understand the structure, lifecycle, and capabilities of custom scripts written for FTO. You’ll learn how to set up your environment, build your own indicators, and access key platform features via the available API.
This documentation is for:
Developers building and debugging trading indicators
Algorithmic traders backtesting and optimizing their strategies
Power users looking to customize and extend FTO’s capabilities
This is a separate guide on how to upload your indicator to FTO.
If you have created an indicator that you want to upload and have run the npm build
command in the terminal, a file named my-indicator-project.js
(indicator's file name) will appear in the dist
folder. Upload this file to FTO (see Picture #1 and #2).
From there, your indicator should appear in "My Indicators" dropdown menu (Picture #3).
To set up global rules for Cursor, click the setting icon (Picture #1)
From here, click the Rules setting (Picture #2)
In the User Rules field (Picture #3), download and paste contents of the file below called Rules.txt
Get started with setting up your development environment and creating your first indicator using a simple Moving Average example.
Understand the lifecycle of an indicator through core functions like Init
, Calculate
, Done
, and more.
Learn how to create and manage visible buffers to display your indicator’s values on the chart.
Understand how to retrieve bar data, price arrays, and time series to power your custom logic.
Customize the behavior and appearance of indicators through parameters and configuration blocks.
Use external inputs to make your indicators dynamic and easily customizable by users.
Retrieve metadata about the active instrument, such as symbol name, point size, and tick value.
Use the FTODate
structure to manage time-based logic and align calculations with bar timestamps.
Explore helper functions and additional features available to streamline development.
Start with the guide and move on to the to see how it all works in action.
The feature in Cursor IDE allows users to define custom guidelines or behaviors that the AI should follow when generating code. By setting up rules that describe how indicators work in FTO, you can effectively teach Cursor the context it needs to produce accurate and consistent indicators.
Main methods of each indicator are and , Init is called once when the indicator is created, and Calculate is called on each tick. Other methods are optional and can be used to add additional logic to the indicator.
In this tutorial, we will look at an example implementation of the MovingAverage
indicator.
To get acquainted with the implementation example, download the archive with the indicator example and open it in IDE of your choice, we suggest you use Cursor IDE.
You can download the archive of Moving Average from here
After their creation, you need to tell how many buffers will be displayed on the chart and bind them by index, starting from 0 (the indices must be unique) In this case, there is one buffer
The OnParamsChange
method is called automatically when the user changes any parameter of your indicator — for example, the period, color, MA type, etc.
It allows you to respond to these changes and adjust your indicator's behavior or visuals accordingly.
This method is called after the user updates the settings in the indicator panel.
Use it to:
Recalculate internal values
Adjust or re-create custom chart objects
Apply shifts, styling, or any other dynamic behavior
Update dependencies between parameters
Let’s say your indicator displays a shifted line or a custom label. When the user updates the "Shift" parameter, you want the line or label to move accordingly — that logic would go inside OnParamsChange
.
It only runs when the user changes something manually in the settings window.
If you don’t need any custom logic after parameter changes — you can leave it empty.
Think of OnParamsChange
as the method that reacts to user edits in the settings panel.
It gives you a place to respond to those changes and adjust the indicator’s behavior.
For more details on how to open it in Cursor IDE, you can refer to this .
A custom indicator is built by extending the IndicatorImplementation
class, provided by the forex-tester-custom-indicator-api
library.
You can find this implementation in the source code of the Moving Average example described in the section.
These parameters can be of different types, they are determined by the class, and they will be displayed in the indicator addition/editing window
For this, they need to be registered in the function.
You can see the methods for registering parameters in the
are used to store and display indicator values on the chart.
They need to be declared with all class fields and initialized in the function
Each registered buffer can be
Also, other methods for configuring the indicator are used in the function. To ensure the indicator recalculates on each tick, use the function . If this setting is not used, each buffer index will be calculated only once to save resources, but some indicators may be calculated inaccurately. If the calculations do not heavily load the processor, we recommend always using it.
Set the indicator name, which will be displayed in the indicator settings window and in the context menu: .
We want the Moving Average indicator to be displayed on the main chart, so we use .
Using this call, specify that values equal to 0 will not be drawn on the chart: .
The main function of the indicator is the function, where the indicator values are calculated on each tick.
To add custom logic after changing the indicator parameters, we use the method. In Moving average, it is applied to the horizontal shift of the indicator. This method is often used to work with custom objects or to shift the indicator.
This is a separate guide on how to set up the environment to write your custom indicator for FTO.
Open it with Cursor or any IDE of your choice — we suggest Cursor. Then, by clicking the icon shown in Picture #1, open the terminal and install the dependencies using the command npm install
.
After installing the dependencies, build the project using the command npm run build
.
If you get an error that goes like this:
Then you need to enter command Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
and then trynpm install
and then npm run build
command again.
After building the project, a file my-indicator-project.js
(Indicator file name) will appear in the dist
folder.
These are indicator examples you can download
To to use our custom indicator API, you need to first download indicator example. You can find some of the examples or download the suggested example file below.
If you want to know how to upload your indicator to FTO, you can go to .
The OnHide
method is called automatically when the indicator is hidden from the chart — for example, when the user disables its visibility.
This gives you a place to clean up any visual elements or perform other logic when the indicator is no longer visible.
Use OnHide
when you want to:
Remove custom chart objects (labels, lines, shapes) added by the indicator
Free resources or stop background logic tied to visualization
Prepare for a clean re-render when the indicator is shown again
OnHide
only runs when the indicator becomes hidden — not when it is removed completely.
It pairs naturally with OnShow
, helping you manage custom visual elements.
Indicator parameters are configurable settings that allow users to customize how an indicator behaves and looks. They appear in the indicator’s settings panel and can be modified without changing the code.
To make a parameter configurable, it must be created using one of the TOptValue
types , created and registered inside the Init()
method.
Any variable that does not extend TOptValue
is considered internal and will not be visible or editable in the user interface.
Here are some of the commonly used TOptValue
types:
TOptValue_number
— numeric values (e.g., period, shift)
TOptValue_bool
— true/false switches
TOptValue_string
— string input
Parameters control how the indicator works and looks — use them for anything the user might want to tweak
Only -based parameters are configurable
You must register each parameter inside the method using
This tutorial will guide you through the process of creating a new indicator using Cursor IDE.
Cursor IDE is a fork of VS Code that has powerful AI capabilities, allowing it to access your code directly and have information about your project.
Cursor can also be provided with FTO custom indicator documentation to assist in creating new indicators.
To set up global rules for Cursor, click the setting icon (Picture #1)
From here, click the Rules setting (Picture #2)
In the User Rules field (Picture #3), download and paste contents of the file below called Rules.txt
You can upload the FTO indicator documentation to Cursor, and Cursor will be able to use it to help you create new indicators.
To upload the FTO indicator documentation to Cursor, you need to follow these steps:
1. Click the setting icon in the top right corner of the Cursor IDE. (Picture #4)
2. Select "Features" on the left sidebar (Picture #5).
Scroll down until you see Docs (Picture #6)
Click on the "Add new doc" button and insert link https://fto-2.gitbook.io/fto-indicators-docs to the FTO indicator documentation (Picture #7).
After some indexing, Cursor will be able to refer to the documentation to help you create new indicators.
To open Cursors AI window, you can press Ctrl+L
or click on the icon in the top right corner of the Cursor IDE (Picture #8)
This panel has a chat interface and in Cursor version 0.47.8 it has 3 modes, Agent, Ask and Edit,
each catering to different needs during development (Picture #9).
Agent Mode: This mode allows for automated code generation and completion by interacting with the AI. It helps streamline the coding process by providing intelligent suggestions and solutions. I access your project files directly and suggests code which you can accept or reject
Ask Mode: In this mode, developers can ask questions about their codebase, programming concepts, or any development-related topics. The AI will respond with helpful guidance and explanations.
Edit Mode: Edit Mode assists in making modifications to the existing code. It aids in refactoring, simplifying, or improving code sections as needed.
What makes these modes powerful is the ability to add context directly from your project or documentation
For now, select the Ask mode
Next to the "select mode menu" there is also an option to select a model of AI that we want to use, for now we should choose Auto-select (Picture#10).
In the result, we got code below
The current logic seems correct, but it's using only the Close price, and there is currently no way for the user to specify their own price type. Let's ask it to fix that (Picture #12).
The code that Cursor wrote in his second response is below
And with the addition of this new parameter and internal method, we get a nice dropdown with price types (Picture #13).
Start by selecting the Ask mode and add context to your query by typing @ and selecting Docs from the drop-down menu (Picture #14).
And provide add a file in which you want to create the indicator, you can do it by drag and dropping it from explorer window on the left onto the chat window or finding it in the @ drop-down menu under Files & folders (Picture #16)
How to install Cursor and set up the project is described in guide. If you don’t yet know how to set up your environment to work with the FTO API for indicators, that is also covered in the same guide.
The feature in Cursor IDE allows users to define custom guidelines or behaviors that the AI should follow when generating code. By setting up rules that describe how indicators work in FTO, you can effectively teach Cursor the context it needs to produce accurate and consistent indicators.
To become more familiar with how to use this added documentation in your requests to Cursor, go to the section below.
Before we begin writing the indicator, it is expected that you are familiar with how to set up the environment to access the FTO Indicator API. If not, please read guide first before continuing.
For this example, we will ask Cursor to implement the On Balance Volume (OBV) indicator for us. In this guide, we will start with an empty file, but for future indicator implementations, you can use some of our indicator foundations provided in .
In the request to create the OBV indicator for us, I included the FTO documentation for and added the discussed earlier. In the screenshot, you can see the sections of the documentation it decided to use (Picture #11).
So in the end, we got a proper indicator with just two simple requests by setting up Cursor properly and providing it with and documentation for context.
For Cursor to use the documentation that we provided in we need to do the following:
In the drop-down menu, select FTO Indicator documentation, which we added earlier in (Picture#15)
The Calculate
method is one of the core functions used in a custom indicator. It’s responsible for calculating the logic of your indicator for each bar (candle) on the chart.
This function runs automatically on each price update (tick) and recalculates values for the given bar.
index
— This parameter tells you which bar you’re working with.
index = 0
→ the latest bar (rightmost on the chart).
index = 1
→ the previous bar, and so on.
The method runs once per tick (price change) and calculates the indicator value only for the specified bar.
Checks if there are enough bars to calculate the moving average.
(We need Period
number of candles; otherwise, we skip.)
Calculates a Moving Average value using GetMA()
.
Stores the result in the SMA
buffer, which is used for drawing on the chart.
Applies a vertical shift (VShift
) and stores the result in a second buffer (SSMA
).
This method is where you put your main logic.
It runs automatically for each bar.
You should use it to calculate and store indicator values.
Buffers like SMA
and SSMA
are how your indicator shows up visually on the chart.
The Init
method is called once, right when your custom indicator is created or loaded onto the chart.
This is where you set everything up — like naming your indicator, creating buffers, creating parameters and registering them, and more.
Init
This method is like a constructor for your indicator. Here’s what usually happens inside:
Set the name and description of the indicator
Create buffers that store the calculated values
Create and register input parameters like period, color, or line style
Set the number of plots, line types, and other configurations
Without Init
, your indicator won't show anything.
It's required to tell the system how many lines you draw and what inputs you need.
Think of it as your setup stage — it only runs once when the indicator is loaded.
Avoid heavy calculations or per-bar logic here. Use Calculate()
for that.
Init
is only for defining the structure and settings of the indicator.
The Done
method is called once, after the indicator has finished calculating all bars.
It marks the end of the calculation cycle and is typically used for final steps or cleanup.
Use Done
when you need to:
Perform post-processing after all Calculate()
calls are complete
Draw or update custom chart objects that rely on full data
Clean up temporary data or buffers
Log or store final values
This method is especially useful if your indicator logic depends on seeing the entire dataset.
Done
is called after all bars have been processed in Calculate()
.
It runs once per full calculation cycle — not on every tick.
It’s safe to use this method to add chart decorations, logs, or summary calculations.
The OnShow
method is called when the indicator is made visible on the chart.
This includes the moment it’s re-enabled after being hidden.
Use OnShow
when you need to:
Re-create or re-draw custom chart objects
Restore visual elements that were removed or hidden earlier
Trigger any logic that should happen only when the indicator is visible
This method is helpful when your indicator includes dynamic elements (like shapes, labels, or highlights) that should appear only when the indicator is active.
This method is not called during every tick or calculation — only when visibility changes.
If your indicator does not rely on custom objects or UI elements, you may not need to implement OnShow
.
This page will guide you how to install Cursor IDE and how to upload your custom indicator to FTO.
After installing node.js, download the archive with the indicator example below and extract it to a convenient location.
Open the extracted folder "Moving Average" and inside of it you should find another folder "custom_indicator", open it with Cursor (Picture #2 and #3).
If you get a pop-up like this, click "Yes, I trust the authors"
Then, by clicking the icon shown on Picture #5 you should open the terminal and install the dependencies using the command npm install
.
After installing the dependencies, you can start writing your indicator in the index.ts
file.
Once the implementation is complete, you can build the project using the command npm run build
.
If you get an error that goes like this:
Then you need to enter command Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
and then trynpm install
and then npm run build
command again.
After building the project, a file my-indicator-project.js
(Indicator file name) will appear in the dist
folder.
Upload this file to the FTO (Picture #6 and #7).
From there, your indicator should appear in "My Indicators" dropdown menu (Picture #8).
Download and install the Cursor editor: , while installing make sure to check all the checkmarks (Picture #1)
Then, you have to install Node.js if you don't already have it. Use the link below.
This is documentation for different types of TOptValue classes which are used to create parameters for indicators.
TOptValue_number
is a class used to define numeric parameters for custom indicators.
These parameters appear in the indicator settings panel and allow the user to input or adjust numbers such as periods, shifts, price types, and more.
You must use the createTOptValue_number()
method of the api
object inside Init()
method to create an instance.
Use TOptValue_number
when you need a configurable parameter of type number
, such as:
Period length for moving averages
Shift values
Enum values (e.g., MA type, price type)
Any numeric input from the user
In this example:
Period
controls how many bars are used in the moving average calculation.
Shift
can offset the indicator horizontally.
MAtype
selects the type of moving average (e.g., SMA, EMA).
ApplyToPrice
defines which price (close, open, high, low) the MA should use.
VShift
applies a vertical offset to the line.
You can access the value using this.MyParameter.value
.
After creating a parameter, don’t forget to register it using in the method.
TOptValue_bool
is a class used to define boolean (true/false) parameters in custom indicators.
It allows users to enable or disable certain features through the indicator settings panel.
Use the createTOptValue_bool()
method from the api
object inside Init()
method to create an instance.
Use TOptValue_bool
when you want to let the user:
Toggle a feature on or off
Show or hide additional elements
Enable conditional behavior in your indicator
In this example:
IsEnabled
allows the user to toggle indicator logic on or off.
Inside Calculate()
, the logic runs only if the toggle is true
.
Access the value with this.MyFlag.value
.
To display indicator values on the chart in Forex Tester Online, you need to use buffers. Buffers store the calculated values and define how they should be visualized (e.g., lines, histograms, dots).
Each buffer is created as a TIndexBuffer
and configured through API calls.
All buffers must be declared as class fields using the TIndexBuffer
type.
Init()
Create the buffer instance using the CreateIndexBuffer()
method.
Tell the API how many buffers you plan to use. In this case — one:
This must be called before setting buffer styles or assignments.
Each buffer must be assigned a unique index:
You can now customize how the buffer will appear on the chart:
Each buffer must be declared, created, and registered properly to be visible on the chart.
Indices must be unique and zero-based (0
, 1
, 2
, etc.).
You can use multiple buffers to display several lines or visual elements.
Don't forget to register string parameters using inside the method.
You can use the value directly in , , or other methods as needed.
Returns the volume for a specific bar.
shift
: A number representing the shift from the current bar
Returns a number
representing the trading volume during the specified bar.
The Volume
method returns the trading volume for a bar at the specified shift from the current bar. Volume represents the total amount of trading activity during the bar's timeframe. The shift parameter determines which bar's volume to return:
0: Current bar
1: Previous bar
2: Two bars ago
And so on
Returns the opening time of a bar in the specified symbol's price history.
Symbol
: The symbol to get data for
TimeFrame
: The timeframe of the data (in minutes)
index
: The index of the bar (0 is current/last bar, 1 is previous bar, etc.)
The iTime
method retrieves the opening time of a bar at the specified index from the price history of a given symbol and timeframe. The index parameter uses zero-based indexing where 0 represents the current (most recent) bar. The returned time is in UTC timezone.
TOptValue_str
is a class used to define string parameters in custom indicators.
It allows users to enter or modify text values in the indicator settings panel.
Use the createTOptValue_str()
method from the api
object inside Init()
method to create an instance.
Use TOptValue_str
when you want to let the user:
Input custom labels or names
Define identifiers or tags
Set any free-form text value
In this example:
Name
is a string parameter that can be changed by the user.
The value can be accessed via this.Name.value
.
You can use the value directly in Calculate
, OnShow
, or other methods as needed.
Returns an object representing the opening time of the specified bar.
Don't forget to register string parameters using inside the method.
Returns the lowest price of a bar in the specified symbol's price history.
Symbol
: The symbol to get data for
TimeFrame
: The timeframe of the data (in minutes)
index
: The index of the bar (0 is current/last bar, 1 is previous bar, etc.)
Returns a number
representing the lowest price of the specified bar.
The iLow
method retrieves the lowest price reached during a bar at the specified index from the price history of a given symbol and timeframe. The index parameter uses zero-based indexing where 0 represents the current (most recent) bar.
Returns the tick volume of a bar in the specified symbol's price history.
Symbol
: The symbol to get data for
TimeFrame
: The timeframe of the data (in minutes)
index
: The index of the bar (0 is current/last bar, 1 is previous bar, etc.)
Returns a number
representing the tick volume of the specified bar.
The iVolume
method retrieves the tick volume of a bar at the specified index from the price history of a given symbol and timeframe. The index parameter uses zero-based indexing where 0 represents the current (most recent) bar. The volume represents the number of price changes (ticks) that occurred during the bar period.
Returns the close price of a bar in the specified symbol's price history.
Symbol
: The symbol to get data for
TimeFrame
: The timeframe of the data (in minutes)
index
: The index of the bar (0 is current/last bar, 1 is previous bar, etc.)
Returns a number
representing the close price of the specified bar.
The iClose
method retrieves the closing price of a bar at the specified index from the price history of a given symbol and timeframe. The index parameter uses zero-based indexing where 0 represents the current (most recent) bar.
Returns the open price of a bar in the specified symbol's price history.
Symbol
: The symbol to get data for
TimeFrame
: The timeframe of the data (in minutes)
index
: The index of the bar (0 is current/last bar, 1 is previous bar, etc.)
Returns a number
representing the open price of the specified bar.
The iOpen
method retrieves the opening price of a bar at the specified index from the price history of a given symbol and timeframe. The index parameter uses zero-based indexing where 0 represents the current (most recent) bar.
Returns the total number of bars available in the specified symbol's price history.
Symbol
: The symbol to get data for
TimeFrame
: The timeframe of the data (in minutes)
Returns a number
representing the total count of available bars.
The iBars
method returns the total number of bars available in the price history for a given symbol and timeframe. This count includes all bars from the oldest available bar up to the current (most recent) bar. The method is useful for determining the size of the historical data and for implementing lookback periods in technical analysis.
Returns the lowest price for a specific bar.
shift
: A number representing the shift from the current bar
Returns a number
representing the lowest price reached during the specified bar.
The Low
method returns the lowest price reached during a bar at the specified shift from the current bar. The shift parameter determines which bar's low price to return:
0: Current bar
1: Previous bar
2: Two bars ago
And so on
Returns the index of the bar with the highest value over a specified range.
symbol
: The symbol to get data for
timeFrame
: The timeframe of the data (in minutes)
type
: The price type to compare (0=OPEN, 1=HIGH, 2=LOW, 3=CLOSE, 4=VOLUME)
count
: Number of bars to search through
index
: The starting bar index (0 is current/last bar, 1 is previous bar, etc.)
Returns a number
representing the index of the bar with the highest value. Returns -1 if no valid bar is found.
The iHighest
method searches for the bar with the highest value of the specified price type (open, high, low, close, or volume) within a range of bars. The search starts from the specified index and looks back for the specified number of bars. The method is useful for finding local maxima and implementing various technical analysis strategies.
Returns the highest price of a bar in the specified symbol's price history.
Symbol
: The symbol to get data for
TimeFrame
: The timeframe of the data (in minutes)
index
: The index of the bar (0 is current/last bar, 1 is previous bar, etc.)
Returns a number
representing the highest price of the specified bar.
The iHigh
method retrieves the highest price reached during a bar at the specified index from the price history of a given symbol and timeframe. The index parameter uses zero-based indexing where 0 represents the current (most recent) bar.
Returns the bar index for a specified time in the symbol's price history.
symbol
: The symbol to get data for
timeframe
: The timeframe of the data (in minutes)
exact
: Whether to require an exact match
Returns a number
representing the index of the bar corresponding to the specified time. Returns -1 if no matching bar is found.
The iBarShift
method searches for a bar with a specific opening time and returns its index. If exact
is true, only bars with exactly matching times will be considered. If exact
is false, the method will return the index of the nearest bar that opened before the specified time.
time
: The time to search for
Returns the index of the bar with the lowest value over a specified range.
symbol
: The symbol to get data for
timeFrame
: The timeframe of the data (in minutes)
type
: The price type to compare (0=OPEN, 1=HIGH, 2=LOW, 3=CLOSE, 4=VOLUME)
count
: Number of bars to search through
index
: The starting bar index (0 is current/last bar, 1 is previous bar, etc.)
Returns a number
representing the index of the bar with the lowest value. Returns -1 if no valid bar is found.
The iLowest
method searches for the bar with the lowest value of the specified price type (open, high, low, close, or volume) within a range of bars. The search starts from the specified index and looks back for the specified number of bars. The method is useful for finding local minima and implementing various technical analysis strategies.
Returns the highest price for a specific bar.
shift
: A number representing the shift from the current bar
Returns a number
representing the highest price reached during the specified bar.
The High
method returns the highest price reached during a bar at the specified shift from the current bar. The shift parameter determines which bar's high price to return:
0: Current bar
1: Previous bar
2: Two bars ago
And so on
: Gets the volume value of the current bar.
: Retrieves volume value from a specific bar index.
: Retrieves the timestamp of a specific bar.
: Retrieves the open price of a specific bar.
: Finds the lowest value over a range of bars.
: Gets the low price of a specific bar.
: Finds the highest value over a range of bars.
: Gets the high price of a specific bar.
: Retrieves the close price of a specific bar.
: Finds the index of a bar by time.
: Returns the number of bars between two dates.
: Gets the close price of the current bar.
: Gets the high price of the current bar.
: Gets the low price of the current bar.
: Gets the open price of the current bar.
: Returns the total number of bars.
: Gets the time of the current bar.
Removes all chart objects of a specified type.
objType
The type of objects to remove
isStatic
boolean
Optional. Whether to remove static objects (default: false)
The RemoveAllObjects
method removes all chart objects of a specified type from the chart. This is useful for cleaning up multiple objects at once. The method can remove either regular objects or static objects, depending on the isStatic
parameter.
Returns the total number of bars.
Returns a number
representing the total count of available bars.
The Bars
method returns the total number of price bars available in the current symbol's history. This count includes all bars from the earliest available data point up to and including the current bar.
Returns the opening price for a specific bar.
shift
: A number representing the shift from the current bar
Returns a number
representing the opening price of the specified bar.
The Open
method returns the opening price of a bar at the specified shift from the current bar. The shift parameter determines which bar's opening price to return:
0: Current bar
1: Previous bar
2: Two bars ago
And so on
Returns the text content of a chart object.
name
string
The name of the object
isStatic
boolean
Optional. Whether to look in static objects (default: false)
Returns a string
containing the object's text content.
The GetObjectText
method retrieves the text content of a specified chart object. This is primarily used with text-based objects like labels, but can also be used with other objects that have text properties.
Returns the closing price for a specific bar.
shift
: A number representing the shift from the current bar
Returns a number
representing the closing price of the specified bar.
The Close
method returns the closing price of a bar at the specified shift from the current bar. The shift parameter determines which bar's closing price to return:
0: Current bar
1: Previous bar
2: Two bars ago
And so on
Checks if a chart object with the specified name exists.
uniqueObjectName
string
The unique name of the object to check
isStatic
boolean
Optional. Whether to check static objects (default: false)
Returns a boolean
indicating whether the object exists (true
) or not (false
).
The DoesChartObjectExist
method checks for the existence of a chart object with the specified name. It can check for both regular and static objects, depending on the isStatic
parameter.
: Creates a new chart object.
: Removes all objects from a chart.
: Checks if a chart object exists.
: Retrieves the text of a chart object.
: Retrieves the type of a chart object.
: Retrieves the name of a chart object.
: Retrieves the count of objects on a chart.
: Removes a specific chart object.
: Sets the text of a chart object.
: Retrieves a property of a chart object.
: Sets a property of a chart object.
Returns the total number of chart objects.
isStatic
boolean
Optional. Whether to count static objects (default: false)
Returns a number
representing the total count of chart objects.
The GetObjectCount
method returns the total number of objects in the chart. It can count either regular objects or static objects, depending on the isStatic
parameter.
Creates a new chart object with specified parameters.
name
string
Unique identifier for the object
objType
Type of object to create (e.g., trend line, rectangle)
window
number
Chart window number where the object will be placed
ftoDate1
First time coordinate
price1
number
First price coordinate
ftoDate2
Optional. Second time coordinate (required for some objects)
price2
number
Optional. Second price coordinate (required for some objects)
ftoDate3
Optional. Third time coordinate (required for triangles)
price3
number
Optional. Third price coordinate (required for triangles)
isStatic
boolean
Optional. Whether the object is static (persists across timeframes)
Returns boolean
- true
if the object was created successfully, false
otherwise.
The СreateChartObject
method creates a new chart object with the specified parameters. Different object types require different sets of coordinates
Returns the time for a specific bar.
shift
: A number representing the shift from the current bar
timeZoneMode
: Optional. Default value is project timezone. A TimeZoneMode
enum value representing the timezone mode to use for the returned date
The Time
method returns the opening time of a bar at the specified shift from the current bar. The time is returned as an FTODate
object, which provides various date/time manipulation capabilities. The shift parameter determines which bar's time to return:
0: Current bar
1: Previous bar
2: Two bars ago
And so on
The timeZoneMode
parameter allows you to specify how the time should be interpreted:
TimeZoneMode.PROJECT
: Returns time in the project's timezone (default)
TimeZoneMode.UTC
: Returns time in UTC
Returns an object representing the bar's opening time.
uniqueObjectName
string
The unique name of the object to remove
isStatic
boolean
Optional. Whether the object is static (default: false)
Returns the name of a chart object by its index.
index
number
The index of the object
isStatic
boolean
Optional. Whether to look in static objects (default: false)
Returns a string
representing the object's name.
The GetObjectName
method retrieves the name of a chart object based on its index in the list of objects. Objects are indexed from 0 to GetObjectCount() - 1
. This method is useful for iterating through all objects on a chart.
Returns the type of a chart object.
name
string
The name of the object
isStatic
boolean
Optional. Whether to look in static objects (default: false)
The GetObjectType
method retrieves the type of a specified chart object. The type is returned as a TObjectType
enumeration value.
Returns a enum value representing the object's type.
Sets the visual style for a buffer.
bufferIndex
- A number representing the index of the buffer to style.
width
- A number representing the line width in pixels.
clr
- A string hex color value for the buffer.
isVisible
- (Optional) A boolean indicating whether the buffer should be visible.
This method does not return a value.
The SetIndexStyle
method sets the visual appearance of a buffer on the chart. This includes the drawing style (line, histogram, etc.), line style (solid, dashed, etc.), width, color, and visibility.
type
- A value from the enum specifying how to draw the buffer.
style
- A value from the enum specifying the line style.
See for available drawing styles, for line styles
Retrieves a property value from a chart object.
name
string
The name of the object
index
The property identifier
isStatic
boolean
Optional. Whether the object is static (default: false)
Returns either a number
or string
depending on the property type.
The GetObjectProperty
method retrieves a property value from a specified chart object. It can return either numeric or string properties depending on the property identifier provided.
| number
See for a complete list of available object properties.
Sets a property value for a chart object.
name
string
The name of the object
index
number
The property identifier
value
any
The value to set
isStatic
boolean
Optional. Whether the object is static (default: false)
Returns boolean
- true
if the property was set successfully, false
otherwise.
The SetObjectProperty
method sets a property value for a specified chart object. It can handle both numeric and string properties, and automatically converts time values from FTODate to the internal format.
: Adds a level to an indicator.
: Sets the style of an indicator index.
: Creates an index buffer with arguments.
: Sets the output window for an indicator.
: Sets the number of digits for an indicator.
: Retrieves the number of counted bars.
: Sets the buffer shift for an indicator.
: Retrieves information about a buffer.
: Sets the draw begin index for an indicator.
: Retrieves the minimum value of a buffer.
: Retrieves the count of a buffer.
: Retrieves the maximum value of a buffer.
: Sets a value in a buffer.
: Retrieves a value from a buffer.
: Sets the label for an indicator index.
: Sets the symbol for an indicator index.
: Sets the visibility of an indicator index.
: Sets the buffer for an indicator index.
: Creates an index buffer.
: Manages indicator buffers.
: Sets the value of a level.
: Sets the indicator to always recalculate.
: Sets the back offset for calculation.
: Sets fixed min and max values for an indicator.
: Sets the ID key for an indicator.
: Sets the empty value for an indicator.
: Sets the short name for an indicator.
Adds a horizontal level line to the indicator.
value
- A number representing the Y-value where the level should be drawn.
width
- A number representing the line width in pixels.
color
- A string hex color value for the level line.
opacity
- A number between 0 and 1 representing the opacity of the line.
This method does not return a value.
The AddLevel
method adds a horizontal level line to the indicator window. This is commonly used for indicators like RSI or Stochastic to mark overbought and oversold levels.
style
- A value from the enum specifying the line style.
See for available line styles
Sets the number of decimal places for indicator values.
digits
- A number representing the number of decimal digits to display for indicator values.
This method does not return a value.
The IndicatorDigits
method sets the number of decimal places that will be used when displaying indicator values. This affects how values are formatted in tooltips, indicator configuration panels, and other UI elements.
Setting the appropriate number of decimal places is important for readability and precision. For example, oscillators that range between 0 and 100 might use 1 or 2 decimal places, while price-based indicators might need 4 or 5 decimal places for currency pairs.
Sets the text content and formatting for a chart object.
name
string
The name of the object
text
string
The text content to set
fontSize
number
Optional. The font size (default: 14)
fontName
string
Optional. The font name (default: Roboto Flex)
fontColor
string
Optional. The font color in hex value (default: '#000000')
isStatic
boolean
Optional. Whether the object is static (default: false)
Returns boolean
- true
if the text was set successfully, false
otherwise.
The SetObjectText
method sets the text content and formatting properties for a specified chart object. This method is primarily used with text-based objects like labels, but can also be used with other objects that support text properties.
Sets the window where the indicator will be displayed.
This method does not return a value.
The SetOutputWindow
method determines where the indicator will be displayed on the chart. Indicators can be displayed either in the main chart window or in a separate window below the main chart.
outputWindow
- A value from the enum specifying where the indicator should be displayed.
See for the complete list of available window types.
Sets the horizontal shift for a buffer.
bufferIndex
- A number representing the index of the buffer.
shift
- A number representing the number of bars to shift the buffer.
This method does not return a value.
The SetBufferShift
method sets the horizontal shift for a buffer. This allows you to offset the display of the buffer by a specified number of bars. Positive values shift the buffer to the right (into the future), while negative values shift it to the left (into the past).
Returns the number of bars that have already been calculated in previous calls.
This method does not take any parameters.
Returns a number
representing the count of bars that have already been calculated.
The Counted_bars
method returns the number of bars that have already been processed in previous calls to the indicator's calculation function. This is useful for optimization, as it allows the indicator to only calculate values for new bars rather than recalculating all bars.
Creates a new buffer with specified display properties.
index
- A number representing the buffer index.
aLabel
- A string containing the label for the buffer.
width
- A number representing the line width in pixels.
color
- A string hex color value for the buffer.
Returns a TIndexBuffer
object that can be used to store indicator values.
The CreateIndexBufferWithArgs
method creates a new buffer with specified display properties and assigns it to the given index. This is a convenient way to create and configure a buffer in a single call.
drawStyle
- A value from the enum specifying how to draw the buffer.
style
- A value from the enum specifying the line style.
Sets the starting bar for drawing a buffer.
bufferIndex
- A number representing the index of the buffer.
paintFrom
- A number representing the bar index to start drawing from.
This method does not return a value.
The SetIndexDrawBegin
method sets the starting bar for drawing a buffer. This is useful for indicators that require a certain number of bars to initialize before they can produce meaningful values. By setting the draw begin point, you can prevent the indicator from displaying potentially misleading values during its initialization period.
Returns the number of values stored in a buffer.
buffer
- A number representing the buffer index.
Returns a number
representing the count of values stored in the specified buffer.
The GetBufferCount
method returns the number of values that have been stored in a specific buffer. This can be useful for determining how many bars have valid indicator values.
Finds the minimum value in a buffer within a specified range.
buffer
- A number representing the buffer index.
index1
- A number representing the start of the range.
index2
- A number representing the end of the range.
Returns a number
representing the minimum value found in the specified range of the buffer.
The GetBufferMin
method finds the minimum value in a buffer within the range specified by index1 and index2. This can be useful for scaling or normalizing indicator values.
Finds the maximum value in a buffer within a specified range.
buffer
- A number representing the buffer index.
index1
- A number representing the start of the range.
index2
- A number representing the end of the range.
Returns a number
representing the maximum value found in the specified range of the buffer.
The GetBufferMax
method finds the maximum value in a buffer within the range specified by index1 and index2. This can be useful for scaling or normalizing indicator values.
Retrieves information about a buffer.
index
- A number representing the buffer index.
The GetBufferInfo
method retrieves information about a buffer, such as its label, drawing style, line style, width, color, and visibility. This can be useful for dynamically adjusting buffer properties based on the current state.
Sets a value in a specific buffer at a given index.
index
- A number representing the position in the buffer to set the value at.
value
- A number representing the value to store.
This method does not return a value.
The setValue
method of a buffer object sets a value in a specific buffer at a given index. This is used to store calculated indicator values in the buffer for display on the chart.
Returns a object containing information about the buffer.
See for more information about the buffer information structure.
Retrieves a value from a specific buffer at a given index.
index
- A number representing the position in the buffer to retrieve the value from.
Returns a number
representing the value stored at the specified position in the buffer.
The getValue
method of a buffer object retrieves a value from a specific buffer at a given index. This is useful for accessing previously calculated values or values from other buffers during indicator calculations.
Sets a symbol to be used for drawing points in a buffer.
bufferIndex
- A number representing the index of the buffer.
symbol
- A number representing the symbol code to use.
xoffs
- A number representing the X-offset for the symbol.
yoffs
- A number representing the Y-offset for the symbol.
This method does not return a value.
The SetIndexSymbol
method sets a symbol to be used for drawing points in a buffer.
Creates a new buffer for storing indicator values.
This method does not take any parameters.
The CreateIndexBuffer
method creates a new buffer for storing indicator values. This buffer can then be assigned to a specific index using the SetIndexBuffer method. Each buffer represents a series of values that can be displayed on the chart.
Returns a object that can be used to store indicator values.
See for more information about working with indicator buffers.
Sets the visibility of a buffer.
index
- A number representing the index of the buffer.
isVisible
- A boolean indicating whether the buffer should be visible.
This method does not return a value.
The SetIndexVisibility
method sets whether a buffer should be visible on the chart. This can be used to hide buffers that are used for calculations but should not be displayed to the user.
Sets a label for a buffer.
bufferIndex
- A number representing the index of the buffer.
bufferName
- A string containing the label for the buffer.
This method does not return a value.
The SetIndexLabel
method sets a descriptive label for a buffer. This label is displayed in the indicator's legend and in tooltips when hovering over the indicator on the chart.
Changes the value of an existing level line.
index
- A number representing the index of the level to modify.
value
- A number representing the new Y-value for the level.
This method does not return a value.
The SetLevelValue
method changes the Y-value of an existing level line. This can be used to dynamically adjust level positions based on market conditions or user preferences.
Sets the indicator to be recalculated on every tick.
This method does not take any parameters.
This method does not return a value.
The RecalculateMeAlways
method configures the indicator to be recalculated on every tick, rather than only when a new bar forms. This is useful for indicators that need to update their values continuously, such as those that depend on the current price.
If this setting is not used, each buffer index will be calculated only once for resource saving, but some indicators may be calculated inaccurately.
If calculations do not significantly load the processor, we recommend using it always.
Assigns a buffer to a specific index.
bufferIndex
- A number representing the index to assign the buffer to.
This method does not return a value.
The SetIndexBuffer
method assigns a buffer to a specific index. This is necessary after creating a buffer with CreateIndexBuffer to specify which index the buffer should be associated with. The index must be less than the number of buffers specified with IndicatorBuffers.
buffer
- A object to be assigned to the specified index.
Sets the value to be used for empty or undefined indicator values.
emptyValue
- A number representing the value to use for empty or undefined indicator values.
This method does not return a value.
The SetEmptyValue
method defines what value should be used when an indicator value is empty, undefined, or cannot be calculated. This is commonly used to prevent drawing lines or markers when there is insufficient data to calculate the indicator.
Sets a unique identifier key for the indicator.
key
- A string containing a unique identifier for the indicator.
This method does not return a value.
The SetIndicatorIdKey
method assigns a unique identifier key to the indicator. This key can be used for internal reference, persistence, or to identify the indicator in various operations.
Sets the short name for the indicator.
shortName
- A string containing the short name for the indicator.
This method does not return a value.
The IndicatorShortName
method sets the short name that will be displayed for the indicator in the chart legend, indicator list, and other UI elements. This name helps users identify the indicator on the chart.
Sets fixed minimum and maximum values for the indicator's scale.
aMin
- A number representing the minimum value for the indicator's scale.
aMax
- A number representing the maximum value for the indicator's scale.
This method does not return a value.
The SetFixedMinMaxValues
method sets fixed minimum and maximum values for the indicator's scale. This is particularly useful for oscillators and other indicators that should be displayed within a specific range.
Sets the number of data buffers used by the indicator.
bufferCount
- A number representing the count of data buffers needed by the indicator.
This method does not return a value.
The IndicatorBuffers
method specifies how many data buffers the indicator will use. Each buffer represents a series of values that can be displayed on the chart. For example, a simple moving average uses one buffer, while Bollinger Bands use three buffers (middle line, upper band, lower band).
: Registers an option for an indicator.
: Adds a value to an option.
: Sets the number of digits for an option.
: Sets the range for an option.
Sets the valid range for a numeric option.
name
- A string containing the name of the option to set the range for.
lowValue
- A number representing the minimum allowed value.
highValue
- A number representing the maximum allowed value.
This method does not return a value.
The SetOptionRange
method sets the valid range for a numeric option. This is used to define the minimum and maximum values that users can input for a numeric option in an indicator or strategy.
Sets the number of additional bars to include in calculations.
offset
- A number representing the additional bars to include in calculations.
This method does not return a value.
The SetBackOffsetForCalculation
method sets the number of additional historical bars that should be included when calculating the indicator. This is useful for indicators that require more historical data than just the visible range to calculate correctly.
Registers a new option parameter for an indicator or strategy.
name
- A string containing the name of the option.
optPtrOrValue
- (Optional) The default value for the option.
inv
- (Optional) Visibility flag, defaults to true.
useInNameWithParams
- (Optional) Whether to include this option in the name with parameters, defaults to true.
This method does not return a value.
The RegOption
method registers a new option parameter for an indicator or strategy. This is used to define the configurable parameters that users can adjust when applying the indicator or strategy.
type
- The type of the option (from enum).
See for a complete list of option types.
Sets the number of decimal digits for a numeric option.
name
- A string containing the name of the option to set the digits for.
digits
- A number representing the number of decimal digits to display.
This method does not return a value.
The SetOptionDigits
method sets the number of decimal digits for a numeric option. This is used to define how many decimal places should be displayed and used for a numeric option in an indicator or strategy.
Adds a possible value for an enum-type option.
name
- A string containing the name of the option to add a value to.
value
- A string containing the value to add to the option.
This method does not return a value.
The AddOptionValue
method adds a possible value for an enum-type option. This is used to define the possible values that users can select for an enum option in an indicator or strategy.
: Retrieves the current ask price.
: Retrieves the current bid price.
: Retrieves the number of digits for a currency.
: Retrieves the point value for a currency.
: Retrieves the symbol name.
Returns the current ask price.
Returns a number
representing the current ask price.
The Ask
method returns the current ask price for the symbol. The ask price is the price at which the market is willing to sell the base currency (in forex) or the asset (in other markets).
Returns the number of decimal places in the symbol's price.
Returns a number
representing the count of decimal places.
The Digits
method returns the number of decimal places used in the symbol's price quotation. This value is important for proper price formatting and calculations.
Returns the current bid price.
Returns a number
representing the current bid price.
The Bid
method returns the current bid price for the symbol. The bid price is the price at which the market is willing to buy the base currency (in forex) or the asset (in other markets).
Returns the minimum price change (point) value.
Returns a number
representing the minimum price change value.
The Point
method returns the minimum price change value for the symbol. This is the smallest price movement possible and is used as a base for various calculations.
Returns an object representing the current time.
The TimeCurrent
method returns the current time as an object. This time represents the timestamp of the last processed tick in the project. The returned object provides various methods for date and time manipulation.
Outputs a message to the console with the current UTC time in testing.
message
- A string containing the message to be printed.
This method does not return a value.
The Print
method outputs a message to the console, prefixed with the current UTC time in testing. This is useful for debugging and logging information during strategy development and testing.
The timestamp format is "YYYY.MM.DD HH:nn:ss" and represents the last processed tick time in the testing environment.
: Defines the type of an option parameter.
: Defines the types of chart objects that can be created.
: Defines where an indicator should be displayed on the chart.
: Defines the style of lines used in indicators and chart objects.
: Defines how indicator values should be visually represented on the chart.
: Defines the properties that can be accessed for chart objects.
: Represents a buffer for storing indicator values.
: Represents the visual properties and information about an indicator buffer.
: Represents a date and time value in the format of the trading platform.
An enumeration of option types used for indicator and strategy parameters.
LONGWORD
Represents an unsigned 32-bit integer
INTEGER
Represents a signed integer value
DOUBLE
Represents a floating-point number
STRING
Represents a text string
BOOLEAN
Represents a true/false value
ENUM_TYPE
Represents a selection from a list of predefined values
TIMEFRAME
Represents a chart timeframe
CURRENCY
Represents a currency selection
LINE_STYLE
Represents a line style for drawing
SEPARATOR
Represents a visual separator in the options dialog
INDICATOR
Represents an indicator selection
COLOR
Represents a color selection
DATE_TIME
Represents a date and time value
LEVELS
Represents level settings
SESSION
Represents a trading session
SESSIONS_ARRAY
Represents an array of trading sessions
An enumeration that defines the different types of chart objects that can be created in the trading platform.
ANY_OBJECT
Represents any type of chart object
V_LINE
A vertical line on the chart
H_LINE
A horizontal line on the chart
TREND_LINE
A trend line connecting two points
RAY
A ray extending from one point in a direction
POLYLINE
A line consisting of multiple connected segments
FIBO_RETRACEMENT
Fibonacci retracement levels
FIBO_TIME_ZONES
Fibonacci time zones
FIBO_ARC
Fibonacci arcs
FIBO_FAN
Fibonacci fan lines
ANDREWS_PITCHFORK
Andrews' Pitchfork technical analysis tool
TEXT
Simple text object
TEXT_LABEL
Text label with additional formatting options
RECTANGLE
A rectangular shape
ELLIPSE
An elliptical shape
TRIANGLE
A triangular shape
FIBO_CHANNEL
Fibonacci channel
LR_CHANNEL
Linear regression channel
FIBO_EXTENSION
Fibonacci extension levels
GANN_BOX
Gann box analysis tool
: Prints a message to the console.
: Retrieves the current time.
: Retrieves the current timeframe.