EAsiScript User Guide

Reference guide for EAsiScript — the built-in scripting language used to define entry, exit, stop loss, take profit, and position sizing logic in EAsiTrader preset files. Covers all operators, variables, functions, and indicators available to scripts. For a hands-on tutorial with worked examples, see Learn EAsiScript. For general EA configuration, see the EAsiTrader User Guide.

Table of Contents

  1. Introduction
  2. EAsiScript Scripts
  3. Script Execution Workflow
  4. UserVARs
  5. Operators
  6. Variables
  7. Functions
  8. Indicators
  9. Reading Indicator Buffer Data
  10. Indicator Creation Strings
  11. Reading Indicator Signal Flags
  12. Adding A Custom Indicator
  13. Execution Context
  14. Simulated Trading
  15. Learn EAsiScript
  16. Terms

1. Introduction

EAsiScript is a powerful and versatile scripting language integrated into EAsiTrader, designed to empower traders with unparalleled flexibility in creating, testing, and executing trading strategies. Whether you're trading across single or multiple markets and timeframes, EAsiScript provides the tools needed to tailor your approach to suit any market condition.

With built-in support for AI-assisted script generation, traders can leverage artificial intelligence to help develop and optimise their strategies while maintaining full control over implementation and testing.

Main Features

  1. 15 Essential Scripts:
    • EAsiScript supports 15 customizable scripts, each tailored to specific trading functions such as entry, exit, stop loss, take profit and lot size. These scripts allow you to define and automate every aspect of your trading strategy.
  2. Built-in Functions:
    • Access over 100 built-in functions to handle data retrieval, calculations, and trade execution seamlessly.
  3. Indicator Support:
    • Utilize 25 built-in indicators, including 14 proprietary ones, to enhance your strategies.
    • Add custom indicators for even greater customisation.
  4. Expression-Based Logic:
    • Create dynamic and complex strategies using numeric expressions combined with operators for precise control over your trading decisions.
  5. AI Integration:
    • Support for AI-assisted script and preset file generation
    • For detailed instructions on using AI with EAsiScript, see the Learn EAsiScript User Guide.
  6. Community Sharing:
    • Collaborate with other traders by sharing and discovering scripts through the EAsiTrader Community, fostering a culture of learning and improvement.

2. EAsiScript -> Scripts

The 7 'long' scripts and 7 'short' scripts are used to open and close trades and control the SL, TP and Breakeven values for buy and sell trades. The trade's lot size is dynamically calculated in accordance with the trader's risk management settings and the broker's margin requirement and lot size limits.

7 scripts for long trades, with their corresponding preset file setting name:

  1. Long Entry Script (InpTradeTool_ScriptLongEntry)
  2. Long Initial Stop Script (InpTradeTool_ScriptLongInitialStop)
  3. Long Trailing Stop Script (InpTradeTool_ScriptLongTrailingStop)
  4. Long Lots Script (InpTradeTool_ScriptLongLots)
  5. Long Take Profit Script (InpTradeTool_ScriptLongTakeProfit)
  6. Long Breakeven Script (InpTradeTool_ScriptLongBreakeven)
  7. Long Exit Script (InpTradeTool_ScriptLongExit)

7 scripts for short trades, with their corresponding preset file setting name: 8. Short Entry Script (InpTradeTool_ScriptShortEntry) 9. Short Initial Stop Script (InpTradeTool_ScriptShortInitialStop) 10. Short Trailing Stop Script (InpTradeTool_ScriptShortTrailingStop) 11. Short Lots Script (InpTradeTool_ScriptShortLots) 12. Short Take Profit Script (InpTradeTool_ScriptShortTakeProfit) 13. Short Breakeven Script (InpTradeTool_ScriptShortBreakeven) 14. Short Exit Script (InpTradeTool_ScriptShortExit)

1 AI script to control AI requests: 15. AITrigger Script (InpTradeTool_ScriptAITrigger)

See EAsiTrader GUI->Settings Tab in the EAsiTrader Manual for a list of all settings that work in conjunction with the scripts.

By default, all scripts use the following settings, unless overridden by the user, or overridden by a script, e.g. the Initial SL, Lots, TP and BE scripts:

  • % Risk: 1% Equity
  • Trade Types: Buys and Sells
  • Max Open Positions: 1
  • Lots: Max allowable by risk and margin.
  • SL: 3*ATR
  • TP: 2*ATR
  • Breakeven: 1*Risk
  • Min SL Move: 10 points

Scripts -> Long Entry Script, Short Entry Script

(setting name: InpTradeTool_ScriptLongEntry) (setting name: InpTradeTool_ScriptShortEntry)

These scripts are run to determine if a new position should be opened. Use the Long Entry script to open a new long Market, Stop or Limit order position and use the Short Entry script to open a new short Market, Stop or Limit order position.

These scripts are run either every bar or every tick according to the Settings -> Auto Trade -> Refresh Mode setting. Every Bar is the default and recommended setting for most strategies. Every Tick consumes more compute time and could affect performance, especially when trading multiple markets.

  • A Buy Market order is opened if the result of the Long Entry script is equal to the current ask price and a Sell Market order is opened if the result of the Short Entry script is equal to the current bid price.

  • A Buy Stop order is opened if the result of the Long Entry script is greater than the current ask price and a Sell Stop order is opened if the result of the Short Entry script is less than the current bid price.

  • A Buy Limit order is opened if the result of the Long Entry script is less than the current ask price and a Sell Limit order is opened if the result of the Short Entry script is greater than the current bid price.

  • If the result of the entry script is zero then no action is taken.

  • If the Long Entry and the Short Entry scripts both return a positive result on the same tick and they are both Market order trades then no action is taken.

  • If the Long Entry and the Short Entry scripts both return a positive result on the same tick and they are both pending orders (i.e. stop or limit orders) then they are treated as OCO (one cancels the other) orders. The first of the two orders that is filled will automatically cancel the other.

Scripts -> Long Initial SL Script, Short Initial SL Script

(setting name: InpTradeTool_ScriptLongInitialStop) (setting name: InpTradeTool_ScriptShortInitialStop)

These scripts are run once, immediately after the Entry Script has run and before the position has been opened, and are used to determine the initial stop loss (SL) value used for the new position. Use the Long Initial script to set the initial stop loss of a long position opened with the Long Entry script or use the Short Initial SL script to set the initial stop loss of a short position opened with the Short Entry script.

The Initial SL scripts are run once immediately after the Entry Script initiates a new trade, i.e. when the script returns a non-zero value.

  • If the script is not defined then the position's SL is calculated by running the Long Trailing SL script for long positions or the Short Trailing SL script for short positions. If this script is not defined then the position's SL is calculated using the Settings -> Stops ->SL setting.

  • The result is used as the SL for the new position if:

    • For long positions: the result of the Long Initial SL script is less than the entry price returned by the Long Entry script.
    • For short positions: the result of the Short Initial SL script is greater than the entry price returned by the Short Entry script.
  • No action is taken if:

    • For long positions: the result of the Long Initial SL script is zero or greater than or equal to the entry price returned by the Long Entry script.
    • For short positions: the result of the Short Initial SL script is less than or equal to the entry price returned by the Short Entry script.

Scripts -> Long Trailing SL Script, Short Trailing SL Script

(setting name: InpTradeTool_ScriptLongTrailingStop) (setting name: InpTradeTool_ScriptShortTrailingStop)

These scripts are run after a position has been opened and used to determine a new value for the stop loss (SL). These scripts can also be run immediately after an entry script if the Initial SL script is not defined. Use the Long Trailing SL script to set or update the SL of a long position opened with the Long Entry script or use the Short Trailing SL script to set or update the SL of a short position opened with the Short Entry script.

These scripts are run every tick on a new high for long positions and on a new low for short positions, whilst the position is open, regardless of the Settings -> Auto Trade -> Refresh Mode setting. These scripts are also run immediately after an entry script if the Initial SL script is not defined.

  • The position's SL price is updated if both of the following conditions are met:

    • For long positions: the result of the Long Trailing SL script is less than the current bid price. For short positions: the result of the Short Trailing SL is greater than the current ask price.
    • The difference between the old and new SL is greater than or equal to the Settings -> Stops -> Min Stop Move setting.
  • The position's SL is not changed if any of the following conditions are met:

    • For long positions: the result of the Long Trailing SL script is zero or greater than or equal to the current bid price. For short positions: the result of the Short Trailing SL script is zero or less than or equal to the current ask price.
    • The difference between the current SL and new SL is less than the Settings -> Stops -> Min Stop Move setting.

Scripts -> Long Lots Script, Short Lots Script

(setting name: InpTradeTool_ScriptLongLots) (setting name: InpTradeTool_ScriptShortLots)

These scripts are run once, immediately after the Initial SL Script and Trailing SL Script has run, if defined, and before the TP Scripts and are used to determine the position size for the trade in lots. Use the Long Lots script to set the lots size of a long position opened with the Long Entry script and use the Short Lots script to set the lots size of a short position opened with the Short Entry script.

This script is run once immediately after the Initial SL script and the Trailing SL Script, if defined. If the script is not defined, or the script returns zero, the lot size is calculated in accordance with the trader's risk management settings and the broker's margin requirement and lot size limits.

Scripts -> Long TP Script, Short TP Script

(setting name: InpTradeTool_ScriptLongTakeProfit) (setting name: InpTradeTool_ScriptShortTakeProfit)

These scripts are run once, immediately after the Entry Script has run and before the position has been opened, and are used to determine the take profit (TP) value for the position. Use the Long TP script to set the TP of a long position opened with the Long Entry script and use the Short TP script to set the TP of a short position opened with the Short Entry script.

This script is run once immediately after the Entry script. If the script is not defined and the Settings -> Stops -> TP setting is enabled then the position's TP value is calculated using the Settings -> Stops -> TP setting. If this setting is not enabled then no TP is used.

  • The result is used as the TP when the position is opened if:

    • For long positions: the result of the Long TP script is greater than or equal to the entry price returned by the Long Entry script.
    • For short positions: the result of the Short TP script is less than or equal to the entry price returned by the Short Entry script.
  • No action is taken if:

    • For long positions: the result of the Long TP script is less than the current bid price.
    • For short positions: the result of the Short TP script is greater than the ask price.

Scripts -> Long BE Script, Short BE Script

(setting name: InpTradeTool_ScriptLongBreakeven) (setting name: InpTradeTool_ScriptShortBreakeven)

These scripts are run, immediately after the Entry Script has run and before the position has been opened, and when price makes a new high or new low for the current bar. It is used to determine the Breakeven trigger price for the position. Use the Long BE script to set the Breakeven trigger price of a long position opened with the Long Entry script and use the Short BE script to set the Breakeven trigger price of a short position opened with the Short Entry script.

This script is run once immediately after the entry script and when price makes a new high or new low for the current bar.

If the script is not defined and the Settings -> Stops -> BE setting is enabled then the position's BE value is calculated using the Settings -> Stops -> BE setting. If this setting is not enabled then no BE is used.

Scripts -> Long Exit Script, Short Exit Script

(setting name: InpTradeTool_ScriptLongExit) (setting name: InpTradeTool_ScriptShortExit)

Use the Long Exit script to close a long position previously opened with the Long Entry script and use the Short Exit script to close a short position previously opened with the Short Entry script.

These scripts are run every tick whilst the position is open, regardless of the Settings -> Auto Trade -> Refresh Mode setting.

  • If the result of the Exit script is non-zero then the position is closed.
  • If the result of the Exit script is zero then no action is taken.

Scripts -> AI Trigger Script

(setting name: InpTradeTool_ScriptAITrigger)

This script acts as a gatekeeper for AI assessment refreshes, controlling when new requests are sent to AI and thereby managing token usage and API costs. It works in conjunction with the AIRefreshIntervalMinutes setting (InpTradeTool_AIRefreshIntervalMinutes), which sets the minimum time between AI requests. The refresh interval is checked first — if it hasn't elapsed, no refresh occurs regardless of this script. Once the interval has passed, the trigger script provides a second layer of control by applying custom conditions.

The trigger script is evaluated only after the current AI assessment has expired and there are no open positions (open positions always trigger a refresh regardless of this script). Returning a positive value (greater than zero) from this script means an AI request will be sent on the current bar. Returning zero or a negative value means the request is blocked. If this setting is left empty, the trigger check is skipped entirely and AI refreshes proceed whenever the assessment expires.

This script is run either every bar or every tick according to the Settings -> Auto Trade -> Refresh Mode setting. Every Bar is the default and recommended setting for most strategies. Every Tick consumes more compute time and could affect performance, especially when trading multiple markets.

This script uses the same expression engine as entry and exit scripts, so any variable available in EAsiScript expressions can be used here. Typical use cases include gating AI calls on volatility thresholds, indicator alignments, session times, or other conditions that indicate the market is worth analysing.

AI Trigger Script Examples

Example 1: Session Time Gate

Only allow AI requests during the London and New York trading sessions (08:00–21:00 server time), blocking requests during the quieter Asian session to save API costs.

TimeOfDay(8,0) >= 0 && TimeOfDay(21,0) < 0 ? 1 : 0

  • TimeOfDay(8,0) >= 0: Current time is at or after 08:00
  • TimeOfDay(21,0) < 0: Current time is before 21:00
  • Returns 1 (allow) during the window, 0 (block) outside it

Example 2: Volatility Gate

Only refresh the AI assessment when the market is showing above-average volatility, avoiding wasted API calls during low-activity periods.

ATR1(1) > ATR1(14) * 0.8 ? 1 : 0

  • ATR1(1): Current ATR value (last closed bar)
  • ATR1(14): ATR value from 14 bars ago (a longer-term reference)
  • Allows the request when current volatility is at least 80% of the reference level

Example 3: Trend Confirmation Gate

Only request an AI assessment when the moving average confirms a trend, avoiding requests during choppy, trendless conditions.

Trend('MA1') != 0 ? 1 : 0

  • Trend('MA1'): Returns Bullish (1), Bearish (-1), or No Trend (0) from the MA indicator
  • Blocks the AI request when there is no clear trend

Example 4: Combined Session and Volatility Gate

Combine multiple conditions — only refresh during London/NY hours AND when volatility is sufficient AND when there is directional momentum.

TimeOfDay(8,0) >= 0 && TimeOfDay(21,0) < 0 && ATR1(1) > ATR1(14) * 0.8 && Close(1) != Open(1) ? 1 : 0

Note

Ensure that any indicators referenced in the AI Trigger Script (e.g., ATR1, MA1) are enabled in the Indicator's List (prefixed with + in the preset file). This also applies more broadly: any indicator whose grounded events or raw data should be included in AI requests must be enabled, regardless of whether it is referenced in a script. The AI Trigger Script is only evaluated when all three preconditions are met: the refresh interval has elapsed, the current AI assessment has expired, and there are no open positions.

3. Script Execution Workflow

This section explains the logical steps EAsiScript follows to evaluate and execute trading logic. The process is divided into distinct phases for better understanding.

3.1 Start

Overview

The workflow begins when one of the following events is triggered.

  1. OnTick() Event:
    • Triggered for the Primary Market whenever the broker sends a price or volume update.
    • Ensures tick-by-tick precision for strategies requiring real-time data.
  2. OnTimer() Event:
    • Triggered for Secondary Markets at regular intervals (typically every second).
    • Processes updates for multiple symbols and timeframes but with less precision than OnTick().

3.2 Initialisation

At this stage, the system prepares essential variables and performs initial validations to set up the trading environment.

  1. Sets variables:
    • Assign CurrentAsk to the symbol's current Ask price.
    • Assign CurrentBid to the symbol's current Bid price.
  2. Update Open Positions:
    • Refresh details of any existing open positions.
  3. Check Auto Trading Enabled:
    • If the InpTradeTool_AutoTradeEnabled setting is false, exit the workflow.
  4. Verify Live Trades and Signal Alerts Settings:
    • If both InpTradeTool_LiveTrades and InpTradeTool_SignalAlerts settings are false for the market, exit the workflow.
  5. Ensure Entry Scripts Are Defined:
    • If both InpTradeTool_LongEntryScript and InpTradeTool_ShortEntryScript are undefined or empty, exit the workflow.
  6. Check Refresh Mode Timing:
    • If InpTradeTool_AutoTradeRefreshMode is set to EveryBar and it is not the first tick of a new bar, exit the workflow.

This initialisation ensures that the system is correctly set up and that all necessary conditions are met before proceeding to evaluate trading signals or place orders.

3.3 Perform Preliminary Checks

This step ensures all trade-specific conditions are met before evaluating entry scripts or placing orders. It validates key constraints like trading hours, open position limits, and trade frequency.

  1. Validate Trading Hours:
    • Check if the current time falls within the range defined by:
      • InpTradeTool_StartOfDayTime (start of trading).
      • InpTradeTool_EndOfDayTime (end of trading).
    • If the current time is outside this range, exit the workflow.
  2. Verify Open Position Limits:
    • Market-Specific Limit:
      • Check if the number of open positions for the current market exceeds InpTradeTool_MaxOpenPositions (default: 1).
      • If this limit is exceeded, exit the workflow.
    • Symbol-Wide Limit:
      • Check if open positions for the same symbol across all markets exceed InpTradeTool_MaxOpenPositionsSymbol (default: 0; ignored if zero).
      • If this limit is exceeded, exit the workflow.
    • Account-Wide Limit:
      • Check if total open positions across all symbols and markets exceed InpTradeTool_MaxOpenPositionsAccount (default: 0; ignored if zero).
      • If this limit is exceeded, exit the workflow.
  3. Check Trade Frequency Restrictions:
    • Maximum Trades Per Unit Time:
      • Validate that the number of trades within the last InpTradeTool_MaxTradesUnitTimeInSeconds does not exceed the allowed maximum (default: 0; ignored if zero).
      • If the limit is exceeded, exit the workflow.
    • Minimum Interval Between Trades:
      • Ensure that the time since the last trade exceeds InpTradeTool_MinTradeIntervalInSeconds (default: 0; ignored if zero).
      • If the interval has not passed, exit the workflow.

3.4 Execute Entry Scripts

This step evaluates the entry scripts to determine whether a trade should be opened and calculates the required parameters such as order type and price.

  1. Evaluate Long and Short Entry Scripts:
    • LongEntryScript: Determines the conditions for opening a buy trade.
    • ShortEntryScript: Determines the conditions for opening a sell trade.
    • If both scripts return 0, no trade is required, and the workflow exits.
  2. Determine Order Type: Based on the price returned by the entry scripts:
    • Market Orders:
      • A Buy Market Order is created if the result of LongEntryScript equals the current ask price.
      • A Sell Market Order is created if the result of ShortEntryScript equals the current bid price.
    • Stop Orders:
      • A Buy Stop Order is created if the result of LongEntryScript is greater than the current ask price.
      • A Sell Stop Order is created if the result of ShortEntryScript is less than the current bid price.
    • Limit Orders:
      • A Buy Limit Order is created if the result of LongEntryScript is less than the current ask price.
      • A Sell Limit Order is created if the result of ShortEntryScript is greater than the current bid price.
  3. Check for Order Conflicts:
    • If both LongEntryScript and ShortEntryScript return positive results on the same tick:
      • Market Orders: No action is taken.
      • Pending Orders (OCO): Orders are treated as "One Cancels the Other." The first executed order cancels the other.
  4. Verify Order Validity:
    • Ensure that all calculated parameters (e.g., price, order type) meet required conditions:
    • If any parameter is invalid, the workflow exits without placing the order.

3.5 Place Orders

This step finalizes trade placement by calculating necessary parameters such as Stop Loss (SL), Position Size (Lots) and Take Profit (TP), and executing the appropriate order type.

  1. Calculate Stop Loss (SL):
    • The SL value is determined based on the following priority:
      1. Initial SL Script: If defined, the result of the script is used.
      2. Trailing SL Script: If no initial SL script is defined, this script is used.
      3. Default SL Setting: If neither script is defined, the SL is calculated using:
        • InpTradeTool_InitialStopValue
        • InpTradeTool_InitialStopValueUnits (e.g., ATR, HH/LL Bars, Points).
  2. Determine Position Size:
    • The volume (lot size) is calculated based on the following priority:
      1. Lots Script: If defined, the result of the script is used.
      1. The risk settings:
      • InpTradeTool_MaxRiskPerTradeInPercent
      • InpTradeTool_MaxRiskPerTradeInMoney
      • The available margin and broker-defined lot size constraints.
  3. Calculate Take Profit (TP):
    • The TP value is determined based on the following priority:
      1. TP Script: If defined, the result of the script is used.
      2. Default TP Setting: If no script is defined, the TP is calculated using:
        • InpTradeTool_TakeProfitStopValue
        • InpTradeTool_TakeProfitStopValueUnits (e.g., ATR, HH/LL Bars, Points).
  4. Validate Order Parameters:
    • Ensure the following conditions are met:
      • SL and TP values are within valid ranges (e.g., SL < entry price for buy orders).
      • The calculated volume is non-zero and within the broker's limits.
    • If any parameter is invalid, the workflow exits without placing the order.
  5. Execute the Order:
    • Market Orders: Place a buy or sell order immediately if the script result matches the current ask or bid price.
    • Pending Orders: Place a stop or limit order based on the calculated price levels.
  6. Log and Notify:
    • If InpTradeTool_SignalAlerts is enabled:
      • Log the trade details (e.g., symbol, type, SL, TP, volume).
      • Send a notification to the user regarding the new trade.

4. EAsiScript -> UserVARs

(setting name: InpTradeTool_UserVAR[n]=[current value];[comma separated set of values]) // [n]=variable number, 0-99

UserVARs (VAR0..VAR99) are defined in the EAsiTrader GUI, in the Settings tab under Settings -> UserVARs. These user-defined variables provide flexibility and reusability in your scripts and indicator creation strings. They allow you to replace constant numerical values, such as script parameters, with dynamic ones that can be adjusted during optimization.

Each variable is mapped in the Presets File to a InpTradeTool_UserVAR[n] setting, where [n] is the variable's VAR number. The value of the setting is a string in two parts separated by a ";". The first part is the variable's current value and the second part is the variables set of all values.

Defining User Variables

  1. Assign a value to one of the UserVAR settings, such as VAR0 = 10.

  2. Use the variable name (e.g., VAR0) in your script or indicator creation string instead of a fixed number. Example: Create VAR0, set its value to 10 and use it in your scripts like:

    Close(1) > VAR0 * Point ? Ask() : 0
    

Using Variable Sets

Each UserVAR can be assigned a set of values, such as 10, 12, 14, 16. During optimization, the strategy will test each combination of variable values from their respective sets. Example:

  • VAR0: 10, 20
  • VAR1: 1, 2
  • Optimization Runs:
    • Pass 1: VAR0 = 10, VAR1 = 1
    • Pass 2: VAR0 = 10, VAR1 = 2
    • Pass 3: VAR0 = 20, VAR1 = 1
    • Pass 4: VAR0 = 20, VAR1 = 2

If you define 3 variables, each with 10 values, the optimiser will perform 10 * 10 *10 = 1000 passes.

Practical Use Cases

  1. Dynamic Stop Loss: Use VAR0 to set the stop loss distance in a stop Loss script, like the Long Initial SL script:

    Low(1) - VAR0 * Point.
    
  2. Indicator Creation String: Replace fixed parameters with UserVARs:

    NTL\MA(1,VAR0).ex5,0,1
    

Notes:

  • Ensure that user variable values are valid for their intended use (e.g., numeric and within the expected range for the indicator or script).
  • Define your user variables before using them in scripts or indicator strings to avoid errors.

Common Mistakes

  1. Assigning invalid values to UserVARs (e.g., a non-numeric string).
  2. Using undefined variables in scripts or indicator strings.
  3. Failing to consider how variable sets multiply during optimization, potentially leading to a high number of passes.

5. EAsiScript -> Operators

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
! Not
~ Negate
< Less Than
> Greater Than
<= Less Than Or Equal To
>= Greater Than Or Equal To
?: If Then Else
== Is Equal To
&& Logical And
|| Logical Or
& Bitwise And
| Bitwise Or
<< Bit Shift Left
>> Bit Shift Right

6. EAsiScript -> Variables

Name Value
Bearish -1
Bullish 1
M1 1
M2 2
M3 3
M4 4
M5 5
M6 6
M10 10
M12 12
M15 15
M20 20
M30 30
H1 16385
H2 16386
H3 16387
H4 16388
H6 16390
H8 16392
H12 16396
D1 16408
W1 32769
MN1 49153
No Trend 0
Pip Symbol pip value
Point Symbol point value

7. EAsiScript -> Functions

Price Functions

Function Description
Ask(double offset=0) Returns the ask price for the current symbol, adjusted by offset (price+price*offset). For live trading this is SYMBOL_ASK. For Tester trading this is the ask tick price plus 0.5 * broker spread (Tester->BrokerSpread).
Bid(double offset=0) Returns the bid price for the current symbol, adjusted by offset (price+price*offset). For live trading this is SYMBOL_BID. For Tester trading this is the bid tick price minus 0.5 * broker spread (Tester->BrokerSpread).
BodyHigh(int shift=1,string symbol=_Symbol) Returns the high body price of the bar at offset shift for symbol.
BodyLow(int shift=1,string symbol=_Symbol) Returns the low body price of the bar at offset shift for symbol.
Close(int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the close price of a bar at offset shift for symbol and timeframe.
High(int shift=0, string symbol=_Symbol, enum timeframe=_Period) Returns the high price of the bar at offset shift for symbol and timeframe.
HighD(int shift=0, string symbol=_Symbol) Returns the daily high price for the bar at offset shift and symbol.
Low(int shift=0, string symbol=_Symbol, enum timeframe=_Period) Returns the low price of the bar at offset shift for symbol and timeframe.
LowD(int shift=0, string symbol=_Symbol) Returns the daily low price for the bar at offset shift and symbol.
Mid(string symbol=_Symbol) Returns the mid price for symbol. The mid price is (bid + ask) * 0.5.
Open(int shift=0, string symbol=_Symbol, enum timeframe=_Period) Returns the open price of the bar at offset shift for symbol and timeframe.
Spread(int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the spread of the bar at offset shift for symbol and timeframe.
Volume(int shift=0, string symbol=_Symbol, enum timeframe=_Period) Returns the trade volume or tick volume (broker dependent) of the bar at offset shift for symbol and timeframe.

Bar Analysis Functions

Function Description
BarClosePos(int shift=1) Returns the position of the close within the bar's total range as a ratio between 0.0 (close at low) and 1.0 (close at high). If the high equals the low, the function returns 0.5.
BarImpulse(int shift=1) Returns a signed momentum ratio for the bar at shift. The value is (BodySize / BarSize) multiplied by 1 for bullish bars or -1 for bearish bars. If the bar has no range or no body, returns 0.
BarMatch(int shift=1, int direction=0, int barSize=0, int bodySize=0, int wickSize=0, int upperWick=0, int lowerWick=0) Returns 1 if the bar at the specified shift matches the specified bar direction and structural criteria, otherwise returns 0. All size parameters must be specified in points (e.g. 10 * Point). Use positive values to check for greater than or equal, and negative values to check for less than. Direction should be Bullish, Bearish, or 0 (any). A return value of 1 indicates a matching bar.
BarMatchAvg(string atrName,int shift=1, int direction=0, double barSize=0, double bodySize=0, double wickSize=0, double upperWick=0, double lowerWick=0) Returns 1 if the bar at the specified shift matches the given direction and structural criteria, scaled as a proportion of the average bar height. The average height is read from the indicator named in atrName (typically an ATR indicator like 'ATR1'). Use positive values to check for values greater than or equal to the specified ratio, and negative values to check for values less than the ratio. Direction can be Bullish, Bearish, or 0 (any).
BarSize(int shift=1, part=0, string symbol=_Symbol, enum timeframe=_Period) Returns the size of a part of a bar, in terms of its price, at offset shift, for symbol and timeframe. part can be: 0=whole bar, 1=body, 2=upper wick, 3=lower wick.
BarSkew(int shift=1) Returns the position of the body midpoint within the bar’s total range as a ratio between 0.0 (body midpoint at low) and 1.0 (body midpoint at high). If high equals low, returns 0.5.
BarTrend(int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the trend of a bar at offset shift for symbol and timeframe. 0=no trend (open=close), 1=bullish bar (close > open), -1=bearish bar (close < open).
BearishBars(int count=0,string symbol=_Symbol, enum timeframe=_Period) Returns the number of bearish bars (close < open) starting from the latest closed bar for symbol and timeframe. If count = 0, the function returns the number of consecutive bearish bars. If count > 0, it counts up to count bearish bars (not necessarily consecutive).
BodyX(int bars=0, double price=0, string symbol=_Symbol, enum timeframe=_Period) Returns the number of bars, in a range starting from the latest closed bar, whose body part crosses the specified price. If price is 0 the symbol's mid price is used. The mid price is (bid + ask) * 0.5.
BoxBars(double lowPrice, double highPrice, int bars, string symbol=_Symbol, enum timeframe=_Period) Returns the number of bars in a range starting from the latest closed bar whose open and close prices are both contained within the specified price box. The count stops when the first bar having either its open or close price outside the box is encountered.
BullishBars(int count=0,string symbol=_Symbol, enum timeframe=_Period) Returns the number of bullish bars (close > open) starting from the latest closed bar for symbol and timeframe. If count = 0, the function returns the number of consecutive bullish bars. If count > 0, it counts up to count bullish bars (not necessarily consecutive).
DayBars() Returns the number of bars since the start of the current day.
HighBars(int bars=0, string symbol=_Symbol, enum timeframe=_Period) Returns the number of bars, in a range starting from the latest closed bar, whose high is higher than the high of the latest closed bar, for symbol and timeframe. If bars=0 the function returns the number of bars that have a high price lower than or equal to the high price of the latest closed bar, up to a maximum of 1000 bars. The count stops when the first bar with a higher high is encountered.
HighestBody(int bars=0, int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the highest body price for a range of bars, symbol and timeframe, starting from the bar at offset shift.
HighestHigh(int bars=0, int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the highest high price for a range of bars, symbol and timeframe, starting from the bar at offset shift.
IsDoji(int shift=1, double barBodyRatio=10) Returns 1 if the bar at shift is a doji. A doji is defined as a bar where the body size (Close-Open) is very small relative to its total range (High-Low). The barBodyRatio sets how small: the bar’s total range must be at least barBodyRatio times larger than the body size. Zero-body bars (open = close) are always considered doji.
IsEngulfing(int shift=1, int direction=0) Returns 1 if the bar at shift fully engulfs the previous bar’s body. The direction parameter should be Bullish (1), Bearish (-1), or 0 (any). A bullish engulfing requires the current bar to be bullish and the body to fully cover the previous bar’s body.
IsInsideBar(int shift=1) Returns 1 if the bar at shift is fully inside the range of the previous bar. This means the current bar’s High <= previous High** and **Low >= previous Low.
IsOutsideBar(int shift=1) Returns 1 if the bar at shift is fully outside the range of the previous bar. This means the current bar’s High >= previous High and Low <= previous Low.
IsPinBar(int shift=1, double wickRatio=0.33) Returns 1 if the bar at shift has a small body and a large wick. The wickRatio defines the minimum wick-to-bar ratio required (default is 0.33). At least one wick (upper or lower) must meet the ratio requirement.
LowBars(int bars=0, string symbol=_Symbol, enum timeframe=_Period) Returns the number of bars, in a range starting from the latest closed bar, whose low is lower than the low of the latest closed bar, for the specified symbol and timeframe. If bars=0 the function returns the number of bars that have a low price higher than or equal to the low price of the latest closed bar, up to a maximum of 1000 bars. The count stops when the first bar with a lower low is encountered.
LowerWickX(int shift, double price, string symbol=_Symbol, enum timeframe=_Period) Returns true if price crosses the lower wick of the bar at offset shift, for symbol and timeframe.
LowestBody(int bars=0, int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the lowest body low price for a range of bars, symbol and timeframe, starting from the bar at offset shift.
LowestLow(int bars=0, int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the lowest low price for a range of bars, symbol and timeframe, starting from the bar at offset shift.
Range(int bars, int mode=0, string symbol=_Symbol, enum timeframe=_Period) Returns the difference in points between the highest high price and lowest low price for a range of bars, symbol and timeframe starting from the latest closed bar.
TrendStretch(int shift=1, int direction=1) Returns the number of consecutive bars, starting from shift, where each bar closes above the previous high (for Bullish) or below the previous low (for Bearish). The count stops at the first bar that does not meet the condition. The direction parameter must be Bullish (1) or Bearish (-1).
UpperWickX(int shift, double price, string symbol=_Symbol, enum timeframe=_Period) Returns true if price crosses the upper wick of the bar at offset shift, for symbol and timeframe.
WickRatio(int shift=1) Returns the ratio of the total wick length (UpperWick + LowerWick) to the body size. Returns 0 if the body size is zero.

Tick Functions

Function Description
TickAsk(int shift=0,string symbol=_Symbol) Returns the tick ask price for symbol at the tick offset from the latest tick.
TickBid(int shift=0, string symbol=_Symbol) Returns the tick bid price for symbol at the offset from the latest tick.
TickHigest(int tickRangeInMs, string symbol=_Symbol) Returns the highest ask tick price for symbol and time range in milliseconds counting back from the latest tick.
TickLowest(int tickRangeInMs, string symbol = _Symbol) Returns the lowest bid tick price for symbol and time range in milliseconds counting back from the latest tick.
TickRange(int tickRangeInMs, string symbol = _Symbol) Returns the difference in points between the highest ask and lowest bid for symbol and time span in milliseconds from the latest tick.

AI Functions

Function Description
AiBias() Returns the AI-assessed directional bias for the current market.
AiBiasConfidence() Returns the AI confidence level for the directional bias, as a value between 0.0 and 1.0.
AiBiasMultiplier(int isLong) Returns a directional position-size multiplier based on AI bias. isLong should be 1 for long trades and 0 for short trades.
AiBiasRaw() Returns the raw AI directional bias without checking validity or expiry.
AiCombinedMultiplier(int isLong) Returns the combined AI multiplier derived from both bias and risk assessment. isLong should be 1 for long trades and 0 for short trades.
AiConfidence() Returns the overall AI confidence score, as a value between 0.0 and 1.0.
AiConfidenceRaw() Returns the raw AI confidence score without checking validity or expiry.
AiDataAge() Returns the age of the current AI assessment in seconds.
AiIsBearish() Returns 1 if the AI directional bias is bearish, otherwise 0.
AiIsBullish() Returns 1 if the AI directional bias is bullish, otherwise 0.
AiIsHighRisk() Returns 1 if the AI has classified current conditions as high risk, otherwise 0.
AiIsLowRisk() Returns 1 if the AI has classified current conditions as low risk, otherwise 0.
AiIsRanging() Returns 1 if the AI market regime is ranging, otherwise 0.
AiIsStrongBias() Returns 1 if the AI bias is classified as strong (strong bullish or strong bearish), otherwise 0.
AiIsTrending() Returns 1 if the AI market regime is trending, otherwise 0.
AiIsUsable() Returns 1 if the AI assessment is suitable for use in scripts, otherwise 0.
AiIsValid() Returns 1 if the AI assessment data is valid, otherwise 0.
AiIsVolatile() Returns 1 if the AI market regime is volatile, otherwise 0.
AiRegime() Returns the AI-assessed market regime for the current market conditions.
AiRegimeConfidence() Returns the AI confidence level for the market regime, as a value between 0.0 and 1.0.
AiRegimeRaw() Returns the raw AI market regime without checking validity or expiry.
AiRiskConfidence() Returns the AI confidence level for the risk classification, as a value between 0.0 and 1.0.
AiRiskMode() Returns the AI-recommended risk mode for the current market conditions.
AiRiskModeRaw() Returns the raw AI risk mode without checking validity or expiry.
AiRiskMultiplier() Returns a position-size multiplier based on the AI risk assessment.
AiSecondsToExpiry() Returns the number of seconds remaining before the current AI assessment expires.
AiStatus() Returns the current AI context status.

AI Function Usage Examples

AI functions allow scripts to incorporate the AI's market assessment into entry, exit, lot sizing, and trade management decisions. These functions return meaningful values only when the AI is enabled (AIMode ≠ 0) and has a valid, non-expired assessment. When the AI is disabled or no valid assessment exists, functions like AiIsValid() return 0 and numeric functions return their default values (typically 0 or 1.0 for multipliers).

Important: The AI-enhanced entry script examples below are suitable for Filter Signals mode. In Gated Trading mode, entry scripts must be AI-blind — they must not reference any Ai*() functions. See Gated Trading in Detail.

Example 1: Entry Filtered by AI Bias

Only enter long trades when the AI's directional bias is bullish and the AI assessment is valid. This combines a script-based MA crossover condition with AI confirmation.

Long Entry Script: AiIsValid() == 1 && AiIsBullish() == 1 && Close(1) > MA1(1,0) && Close(2) <= MA1(2,0) ? Ask() : 0

  • AiIsValid() == 1: Confirms the AI assessment is current and valid
  • AiIsBullish() == 1: AI bias is bullish (aligns with long entry)
  • The MA crossover provides the technical entry signal; the AI provides directional confirmation
Example 2: Entry with AI Confidence Threshold

Only trade when the AI has high confidence in its assessment, filtering out uncertain conditions.

Long Entry Script: AiConfidence() > 0.7 && AiIsBullish() == 1 && Signal('RSI1') == Bullish ? Ask() : 0

  • AiConfidence() > 0.7: Requires at least 70% overall AI confidence
  • Combines AI confidence with RSI signal for high-conviction entries
Example 3: AI-Modulated Position Sizing

Use the AI's combined multiplier to adjust lot size based on the AI's bias alignment and risk assessment.

Long Lots Script: AiCombinedMultiplier(1) * 0.01

  • AiCombinedMultiplier(1): Returns a multiplier that factors in both bias alignment (is the AI bullish for this long trade?) and risk mode (normal, reduced, aggressive, etc.)
  • The 1 parameter indicates this is a long trade
  • When AI is unavailable, the multiplier defaults to 1.0
Example 4: Exit on AI Regime Change

Close a long position if the AI detects the market has shifted to a ranging regime, suggesting the trend may be over.

Long Exit Script: AiIsValid() == 1 && AiIsRanging() == 1 ? Bid() : 0

  • Exits only when a valid AI assessment confirms ranging conditions
  • When the AI is unavailable (AiIsValid() == 0), the position is held — fail-open behaviour
Example 5: Breakeven Triggered by AI Risk Assessment

Move the stop loss to breakeven when the AI classifies conditions as high risk.

Long BE Script: AiIsValid() == 1 && AiIsHighRisk() == 1 ? OrderPrice() : 0

  • AiIsHighRisk() == 1: AI has flagged elevated risk conditions
  • Returns the order's entry price as the breakeven level, protecting the position
Example 6: AI Trend-Aligned Entry with Strong Bias

Only enter when the AI detects a strong directional conviction, combined with a technical confirmation.

Long Entry Script: AiIsStrongBias() == 1 && AiIsBullish() == 1 && AiIsTrending() == 1 && Close(1) > MA1(1,0) ? Ask() : 0

  • AiIsStrongBias() == 1: AI bias is "strongbull" or "strongbear"
  • AiIsTrending() == 1: AI regime is "trending" (not ranging or volatile)
  • Requires three AI conditions to align before the technical signal is acted on
Note

AI functions require the AI to be enabled and configured with a valid provider. When backtesting with the Tester, AI functions are not available because the AI system does not operate during simulated trading — AI functions will return their default values (0 for boolean checks, 1.0 for multipliers). Test your scripts with AI functions in Monitor Only mode on a demo account before enabling Filter Signals, Gated Trading, or Autonomous modes for live trading.

Indicator Functions

Function Description
Bars(string indicator) Returns the number of bars available for indicator.
Comp(string indicator, int buf1=0, int buf2=-1, int shift1=1, int shift2=1) Compares the buffer data for indicator at buffer buf1, shift offset shift1 with the buffer data at buffer buf2, shift offset shift2. If buf2 is -1 the Closing Price at shift offset shift2 of the current symbol and timeframe is used. Returns 0 if the data is equal, -1 if less than or 1 if greater than.
Cross(string indicator, int buf1=0, int buf2=-1, int shift1=1, int shift2=2) Looks for a cross in the buffer data for indicator at shift offset shift1 in at buffer buf1 and buf2 with the buffer data at shift offset shift2 in buffer buf1 and buf2. If buf2 is -1 the Closing Price at shift offset shift1 and shift2 of the current symbol and timeframe is used. Returns 0 if the data do not cross, -1 if bearish cross or 1 if bullish cross.
FibInZone(string fibIndicator, double zoneLevel1, double zoneLevel2, double price, int shift=1) Returns true if price is inside a zone of a Fib retracement indicator. Shift is the shift offset in the Fib indicator's buffer to the Fib retracement being tested. zoneLevel1=0-1, zoneLevel2=0-1.
FibPrice(string fibIndicator, double fibLevel, int shift=1) Returns the price of the Fib Level for a Fib retracement indicator. Shift is the shift offset in the Fib indicator's buffer to the Fib retracement being tested. fibLevel=0-1.
HLineBreak(string hlineIndicator, string atrIndicator, double atrMultiplier=0.1, int mode=0, int shift=1) Returns 1 (bullish breakout), -1 (bearish breakout), or 0 (no breakout) based on whether price breaks the most recent HLine. Wick touch is not checked — only price breaking beyond the line. Tolerance is set by atrMultiplier * ATR. Mode 0 = strict (body beyond + previous close on opposite side). Mode 1 = loose (close beyond + previous close on opposite side).
HLinesBounce(string hlineIndicator, string atrIndicator, double atrMultiplier=0.1, int mode=0, int shift=1) Returns 1 (bullish bounce), -1 (bearish bounce), or 0 (no bounce) based on whether price bounces off the most recent HLine. Wick must touch the line within ATR-based tolerance. Mode 0 = strict (touch + current and previous close reject). Mode 1 = loose (touch + current close rejects).
OBOS(string indicator, int shift=1) For indicators that support SignalFlags, this function returns the Overbought/Oversold signal flag at the bar at offset shift for indicator. 0=no signal, 1=oversold, -1=overbought.
PivotHighPrice(string pivotIndicator, int minOrder=2, int shift=1) Returns the price of a pivot high from the specified PivotPoints indicator instance. Searches backwards from the bar at shift for the most recent high pivot whose order is greater than or equal to minOrder.
PivotLowPrice(string pivotIndicator, int minOrder=2, int shift=1) Returns the price of a pivot low from the specified PivotPoints indicator instance. Searches backwards from the bar at shift for the most recent low pivot whose order is greater than or equal to minOrder.
PivotTrend(string pivotIndicator,int order,int mode=0,int shift=1) Returns 1 (bullish), -1 (bearish) or 0 (neutral) based on pivot highs and lows. Mode=0 strict (HH & HL), 1=structure (HL), 2=breakout (HH).
Signal(string indicator, int shift=1) Returns the signal direction at bar offset shift for indicator. -1=bearish, 0=no signal, 1=bullish. For bars-since queries, use SignalBull() or SignalBear().
SignalBear(string indicator, int shift=1) Returns bars since last bearish signal for indicator. 0=no signal, 1=signal on this bar, N=signal N-1 bars ago.
SignalBull(string indicator, int shift=1) Returns bars since last bullish signal for indicator. 0=no signal, 1=signal on this bar, N=signal N-1 bars ago.
Stat(int metric) Returns the value of the specified statistical metric for the current market. The metric index must match a row in the Statistic Metrics Table (see EAsiTrader User Guide, Section 15). Returns NaN if the metric is not available.
StructureFlow(string indicator,int pattern,int shift=1) Returns 1 if the last 3 SwingMap swing types match pattern, 0 otherwise. Pattern is a 3-digit number (oldest to newest): 0=any (wildcard), 1=HH, 2=HL, 3=LH, 4=LL. E.g. 212 = HL->HH->HL, 102 = HH->any->HL.
StructureQuality(string indicator,int shift=1) Returns structure quality from the last 3 SwingMap swings. +2=strong bullish (HL->HH->HL or HH->HL->HH), +1=acceptable bullish (HL->HH->HH or HH->HH->HL), -1=acceptable bearish (LH->LL->LL or LL->LL->LH), -2=strong bearish (LH->LL->LH or LL->LH->LL), 0=no match.
Trend(string indicator, int shift=1) Returns the trend direction at bar offset shift for indicator. -1=bearish, 0=no trend, 1=bullish. For bars-since queries, use TrendBull() or TrendBear().
TrendBear(string indicator, int shift=1) Returns bars since bearish trend started for indicator. 0=not bearish, 1=trend started on this bar, N=trend started N-1 bars ago.
TrendBull(string indicator, int shift=1) Returns bars since bullish trend started for indicator. 0=not bullish, 1=trend started on this bar, N=trend started N-1 bars ago.

Position and Order Functions

Function Description
BarsOpen(int position) Returns the number of bars a position has been open, or the current position if position is not specified.
BE(int position) Returns the Breakeven price for a position, or the current position if position is not specified.
Duration(int position) Returns the duration in seconds a position has been open, or the current position if position is not specified.
EntryPrice(int position) Returns the entry price for a position, or the current position if position is not specified. For live trades this is the fill price. For simulated trades this is the current bid/ask price at the time the position was opened. This function returns an invalid value when called by the Initial SL Scripts, Take Profit Scripts and Breakeven Scripts. Use OrderPrice() instead.
IsBE() Returns true (1) if the current position has reached breakeven or false (0) if not.
IsOpen(int position) Returns the open state of a position, or the current position if position is not specified. Returns 1 if the state of the current position is Open.
IsPending(int position) Returns the pending state of a position, or the current position if position is not specified. Returns 1 if the state of the current position is Pending.
Lots(int position) Returns the size of a position in lots, or the current position if position is not specified. This value is available immediately after a Lots script is run, if defined.
MaxLots(int slsize=0) Returns the maximum number of lots that can be traded based on free margin (equity minus used margin). The slsize parameter represents the stop loss distance in points - when provided, the maximum risk per trade is divided by this distance to determine the maximum allowed lot size that satisfies both margin and risk management limits.
MaxPoints(int position) Returns the current maximum profit in points made by a position, or the current position if position is not specified.
MaxProfit(int position) Returns the current maximum profit in money made by a position, or the current position if position is not specified.
OrderPrice(int position) Returns the order price for a position, or the current position if position is not specified. This function can be used immediately after an Entry script has been run.
OrderType(int position) Returns the order type for a position, or the current position if position is not specified. (0=Buy, 1=Sell, etc.) This function can be used immediately after an Entry script has been run.
Pips(int position) Returns the current profit in pips for a position, or the current position if position is not specified.
Points(int position) Returns the current profit in points for a position, or the current position if position is not specified.
Positions() Returns the number of open positions.
PriceShift(double price, int shift=1) Returns the number of bars since the specified price was last within a bar's high-low range, searching back up to 1000 bars while maintaining price-relative continuity across gaps. The optional shift parameter offsets the starting point of the search.
Profit(int position) Returns the current profit in money for a position, or the current position if position is not specified.
R(int position) Returns the initial risk in points for a position, or the current position if position is not specified.
SL(int position) Returns the stop loss price for a position, or the current position if position is not specified. This value is available immediately after an Entry script is run, or after the Initial SL / Trailing SL scripts, if defined.
SLSize(int position) Returns the stop loss size in points for a position, or the current position if position is not specified. This value is available immediately after an Entry script is run, or after the Initial SL / Trailing SL scripts, if defined.
TotalPips() Returns the total profit in pips for all open positions.
TotalPoints() Returns the total profit in points for all open positions.
TotalProfit() Returns the total profit in money for all open positions.
TP(int position) Returns the TP price for a position, or the current position if position is not specified. This value is available immediately after a TP script is run, if defined.

Account Functions

Function Description
Balance() Returns the account's balance. For live trading, this is the account balance in the deposit currency at the time of the function call. For Tester trading, this is the account balance value in the Tester's context at the time of the Tester's clock.
Equity() Returns the account's equity. For live trading, this is the account equity in the deposit currency (ACCOUNT_EQUITY) at the time of the function call. For Tester trading this is the current equity value in the Tester's context at the time of the Tester's clock.
FreeMargin() Returns the account's free margin. For live trading, this is the free margin of the account in the deposit currency (ACCOUNT_MARGIN_FREE) at the time of the function call. For Tester trading, this is the free margin value in the Tester's context at the time of the Tester's clock.

Time Functions

Function Description
Day() Returns the day of the week (0-6) for the current date. 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday.
Hour(int timeZone) Returns the hour (0–23) of the opening time of the latest bar for the current symbol, adjusted to the specified time zone. TimeZone options are: 0=Frankfurt, 1=London, 2=New York, 3=Sydney, 4=Tokyo. If the timeZone parameter is omitted, the function returns the hour in chart time (broker server time).
Minute() Returns the minute (0-59) of the opening time of the latest bar for the current symbol.
Time(int shift=0, string symbol=_Symbol, enum timeframe=_Period) Returns the open time of the bar at offset shift for symbol and timeframe.
TimeOfDay(int hour1=0,int minute1=0,int hour2=0,int minute2=0) Returns the number of minutes past midnight for the current day. If hour1 and minute1 are provided, the function returns 0 if the current time matches hour1 and minute1, -1 if the current time is before hour1 and minute1, or 1 if the current time is after hour1 and minute1. If hour1, minute1, hour2 and minute2 are provided the function returns 0 if the current time is between the two times, -1 if the current time is before the hour1 and minute1, or 1 if the current time is after hour2 and minute2.
TimeShift(int hour, int minute) Returns the number of bars since the specified hour and minute of the current day.

Math and Utility Functions

Function Description
Abs(double x) Returns absolute value (modulus) of x.
Ceil(double x) Returns integer numeric value closest from above x.
Floor(double x) Returns integer numeric value closest from below x.
Max(double x, double y) Returns the maximum value of x and y.
Min(double x, double y) Returns the minimum value of x and y.
Mod(double x, double y) Returns the real remainder after the division of x and y.
Rand() Returns a pseudorandom value within the range of 0 to 32767.
Round(double x) Returns x rounded to the nearest integer.
Sqrt(double x) Returns the square root of x.

Notes:

  1. _Symbol refers to the current chart symbol and _Period refers to the current chart timeframe. Do not use _Symbol and _Period in place of the actual symbol and timeframe. For example, Close(1,'EURUSD',D1) returns the closing price for EURUSD Daily.
  2. In functions that use int position, position refers to an index in a dynamic array of open positions, in order of the time of the position's opening. 0 refers to the first open position, 1 refers to the next open position, etc.

8. EAsiScript -> Indicators

Indicators are essential for making informed trading decisions. In EAsiScript, indicators output data through buffers, which store calculated values such as signal flags or trend data. These buffers are accessed using functions like Signal() and Trend().

EAsiTrader comes supplied with custom versions of 13 widely used indicators and 12 NTL proprietary indicators. Where applicable each indicator provides signal, trend and overbought/oversold signals from its signal data buffer, as well as access to the data from its other buffers. The EA can connect with an indicator either via the indicator's .ex5 executable file, called a custom indicator, or via the chart that the indicator has been loaded onto, called a chart indicator.

Each indicator listed below shows a Creation String and a Default Setting. The Creation String is the template format showing the indicator's configurable parameters. The Default Setting is a concrete example that includes default parameter values and the comma-separated list of buffer numbers appended after .ex5 that scripts can read from. See Indicator Creation Strings for the full format specification.

Key terms used throughout this section: Bar Strength measures the significance of a bar's high or low relative to surrounding bars; Pivot Order ranks price highs and lows by significance; Shift is the bar offset from the latest bar. See Terms for full definitions.

ABH1 - Average Bar Height Indicator

File: \Indicators\NTL\ABH.ex5 Description: Calculates average bar height values over a specified period. Useful for analyzing market volatility and determining stop-loss or take-profit levels.

Creation String

NTL\ABH([parameters,]).ex5

Default Setting:

NTL\ABH(1,14,3).ex5,0,1

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The number of bars used for calculating the averages.
    • Default: 14.
  • Parameter 2: Bar Flag Bits
    • Specifies which bar components to include in the calculations.
    • Default: 15 (all components).
    • Bit definitions:
      • Bit 0: Bar
      • Bit 1: Body
      • Bit 2: Upper Wick
      • Bit 3: Lower Wick

Buffers

  • Buffer 0: Average bar height values.
  • Buffer 1: Average body height values.
  • Buffer 2: Average upper wick height values.
  • Buffer 3: Average lower wick height values.

Associated Functions:

  • ABH1(int shift, int buffer, int lsr, int mask)
  • Signal('ABH1')
  • Trend('ABH1')

ADX1 - Average Directional Index Indicator

File: \Indicators\NTL\ADX.ex5
Description: Measures trend strength and direction using the Average Directional Index (ADX) and directional movement lines (-DI and +DI). Useful for identifying trending markets and generating trend-based signals.

Creation String

Indicators\NTL\ADX([parameters,]).ex5

Default Setting:

NTL\ADX(1,14).ex5,0,1,2,3

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The number of bars used for calculating the ADX values.
    • Default: 14.
  • Parameter 2: TrendStrengthThreshold
    • Determines the ADX value above which a trend is considered strong.
    • Default: 20.
  • Parameter 3: ADXSignalLogicMethod
    • Specifies the logic used for generating signals.
    • Default: 0.
    • Options:
      • 0: ADX Crosses Threshold
      • 1: DI Lines Cross When Trending

Buffers

  • Buffer 0: ADX values.
  • Buffer 1: -DI values.
  • Buffer 2: +DI values.
  • Buffer 3: SignalFlag values (Trend, Signal).

SignalFlag Logic

Trend Determination:

  • If ADX < TrendStrengthThreshold, then Trend = None.
  • If +DI > -DI, then Trend = Bullish.
  • If -DI > +DI, then Trend = Bearish.

Signal Determination:

  • If ADXSignalLogicMethod = 0 (ADX Crosses Threshold):
    • If Trend = Bullish and PreviousTrend = None, then Signal = Bullish.
    • If Trend = Bearish and PreviousTrend = None, then Signal = Bearish.
  • If ADXSignalLogicMethod = 1 (DI Lines Cross When Trending):
    • If Trend = Bullish and previous -DI > previous +DI, then Signal = Bullish.
    • If Trend = Bearish and previous +DI > previous -DI, then Signal = Bearish.

Associated Functions:

  • ADX1(int shift, int buffer, int lsr, int mask)
  • Signal('ADX1')
  • Trend('ADX1')

ADXW1 - Average Directional Index Welles Wilder Indicator

File: \Indicators\NTL\ADXW.ex5
Description: Measures trend strength and direction using the Average Directional Index (ADX) developed by Welles Wilder, along with directional movement lines (-DI and +DI). Useful for identifying trending markets and generating trend-based signals.

Creation String

Indicators\NTL\ADXW([parameters,]).ex5

Default Setting:

NTL\ADXW(1,14).ex5,0,1,2,3

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The number of bars used for calculating the ADXW values.
    • Default: 14.
  • Parameter 2: TrendStrengthThreshold
    • Determines the ADXW value above which a trend is considered strong.
    • Default: 20.
  • Parameter 3: ADXWSignalLogicMethod
    • Specifies the logic used for generating signals.
    • Default: 0.
    • Options:
      • 0: ADXW Crosses Threshold
      • 1: DI Lines Cross When Trending

Buffers

  • Buffer 0: ADXW values.
  • Buffer 1: -DI values.
  • Buffer 2: +DI values.
  • Buffer 3: SignalFlag values (Trend, Signal).

SignalFlag Logic

Trend Determination:

  • If ADXW < TrendStrengthThreshold, then Trend = None.
  • If +DI > -DI, then Trend = Bullish.
  • If -DI > +DI, then Trend = Bearish.

Signal Determination:

  • If ADXWSignalLogicMethod = 0 (ADXW Crosses Threshold):
    • If Trend = Bullish and PreviousTrend = None, then Signal = Bullish.
    • If Trend = Bearish and PreviousTrend = None, then Signal = Bearish.
  • If ADXWSignalLogicMethod = 1 (DI Lines Cross When Trending):
    • If Trend = Bullish and previous -DI > previous +DI, then Signal = Bullish.
    • If Trend = Bearish and previous +DI > previous -DI, then Signal = Bearish.

Associated Functions:

  • ADXW1(int shift, int buffer, int lsr, int mask)
  • Signal('ADXW1')
  • Trend('ADXW1')

ATR1 - Average True Range Indicator

File: \Indicators\NTL\ATR.ex5
Description: Calculates the Average True Range (ATR), a measure of market volatility based on the average range between the high and low prices over a specified period.

Creation String

NTL\ATR([parameters,]).ex5

Default Setting:

NTL\ATR(1,14).ex5,0

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The number of bars used for calculating the average true range.
    • Default: 14.

Buffers

  • Buffer 0: ATR values.

Associated Functions:

  • ATR1(int shift, int buffer, int lsr, int mask)

AutoFib1 - Fibonacci Retracement Indicator

File: \Indicators\NTL\AutoFib.ex5
Description: Automatically identifies Fibonacci retracement and extension levels, providing key levels of support and resistance. Uses bar strength analysis to find significant swing highs and lows, then defines Fibonacci retracement zones between them. Integrates with Average Bar Height (ABH) for dynamic volatility-adjusted height filtering. Fully customizable for a wide range of trading strategies.

Fib Level Convention

This indicator uses the standard Fibonacci retracement convention:

  • 0% level = the end of the impulse move (no retracement has occurred). For a bullish Fib this is the swing HIGH; for a bearish Fib this is the swing LOW.
  • 100% level = the origin of the impulse move (full retracement). For a bullish Fib this is the swing LOW; for a bearish Fib this is the swing HIGH.
  • Zone levels (e.g. 0.35) measure how far price has retraced from the 0% level toward the 100% level.

Creation String

NTL\AutoFib([parameters,]).ex5

Default Setting:

NTL\AutoFib(1,0,'0.0,0.3,0.5,0.618,0.762,1.0',3,0,4,8,50,100,0.0,10,250,45,'0.35,1',0,0,3,14).ex5,0,1,2,3,4,5

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Timeframes
    • Specifies the timeframe(s) to analyse.
    • Default: N/A.
  • Parameter 2: FibLevelsCSV
    • Defines Fibonacci retracement levels as a CSV string.
    • Default: '0.0,0.3,0.5,0.618,0.762,1.0'.
  • Parameter 3: MinFibWidthInBars
    • Minimum width of the pattern in bars (distance between 0% and 100% level bars).
    • Default: 3.
  • Parameter 4: MaxFibWidthInBars
    • Maximum width of the pattern in bars.
    • Default: 0 (no maximum).
  • Parameter 5: MinFibHeightInABH
    • Minimum height of the pattern in Average Bar Height (ABH) multiples.
    • Default: 4.
  • Parameter 6: MaxFibHeightInABH
    • Maximum height of the pattern in ABH multiples. 0 = unlimited.
    • Default: 8.
  • Parameter 7: MaxFibRangeInBars
    • Maximum number of bars a Fib remains active after its last swing point was detected. When exceeded, the Fib is terminated.
    • Default: 50.
  • Parameter 8: MinFibStrengthDifference
    • Additive offset added to the 100% level bar strength to determine the minimum required 0% level bar strength. Used when multiplier (P9) is 0.
    • Default: 100.
  • Parameter 9: MinFibStrengthMultiplier
    • Multiplier applied to the 100% level bar strength to calculate the minimum required 0% level bar strength. When non-zero, this takes priority over the additive difference (P8). When 0, the additive difference is used instead.
    • Default: 0.0 (disabled; additive difference used).
  • Parameter 10: MinFib100Strength
    • Minimum bar strength required for the 100% level pivot bar.
    • Default: 10.
  • Parameter 11: MaxFib100Strength
    • Maximum bar strength for the 100% level pivot bar. 0 = unlimited (internally set to INT_MAX).
    • Default: 250.
  • Parameter 12: MaxLookbackInBars
    • Maximum number of bars to look back for finding pivot points during Fib detection.
    • Default: 45.
  • Parameter 13: ZoneLevelsCSV
    • Defines Fibonacci retracement zones as semicolon-separated pairs in format "min,max;min,max". Each pair defines a zone between two Fib levels. Maximum 5 zones.
    • Default: '0.35,1' (single zone from 35% to 100% retracement).
  • Parameter 14: FibPatternBits
    • Defines the Fibonacci pattern filter as a bit pattern for matching bullish/bearish sequences in history.
    • Default: 0 (disabled).
  • Parameter 15: FibPatternSize
    • Number of bits to match from FibPatternBits.
    • Default: 0 (disabled).
  • Parameter 16: AppliedPrice
    • Defines the price data used for Fib calculations. High (3) uses high/low prices. Close (1) uses close prices for both high and low.
    • Default: 3 (High).
  • Parameter 17: ABHPeriod
    • Period for Average Bar Height calculation, which controls the volatility-based height filtering.
    • Default: 14.

Buffers

  • Buffer 0: FibShift values (bit-packed metadata, written on every bar where a Fib is active, 0 otherwise).
    • Bits 0–19: 0% level shift value (bars back from current bar to the 0% level bar).
    • Bits 20–39: 100% level shift value (bars back from current bar to the 100% level bar).
    • Bits 40–41: FibType (00=undefined, 01=Bullish, 10=Bearish, 11=undefined).
    • Bit 42: Formed bit (1 = new Fib detected on the current bar or Fib swing points changed).
    • Bit 43: Broken bit (1 = Fib terminated on the current bar because price broke beyond a boundary).
    • Bit 44: 0% Level Broken bit (1 = price broke past the 0% level: above swing high for bullish, below swing low for bearish).
    • Bit 45: 100% Level Broken bit (1 = price broke past the 100% level: below swing low for bullish, above swing high for bearish).
    • Bit 46: FibMatch bit (1 = matches user-defined Fibonacci pattern).
  • Buffer 1: FibLevel0 values — price at the 0% Fibonacci level (written on every active-Fib bar, 0 otherwise).
    • Bullish: swing HIGH price. Bearish: swing LOW price.
  • Buffer 2: FibLevel1 values — price at the 100% Fibonacci level (written on every active-Fib bar, 0 otherwise).
    • Bullish: swing LOW price. Bearish: swing HIGH price.
  • Buffer 3: BarStrength values (bit-packed, written independently during strength calculation).
    • Bits 0–23: High bar strength — number of consecutive prior bars whose high is lower.
    • Bits 24–47: Low bar strength — number of consecutive prior bars whose low is higher.
  • Buffer 4: FibTypeHistory (written once per bar on new bar/reset).
    • Bits 0–49: Last 50 FibType bits. 1 = bullish, 0 = bearish. Bit 0 is most recent.
  • Buffer 5: SignalFlag values (standard INDICATORSIGNALDATA format).

SignalFlag Logic

Trend Determination:

  • If FibShift = 0 (no active Fib), then Trend = None.
  • If FibType = 1, then Trend = Bullish.
  • If FibType = 2, then Trend = Bearish.
  • Otherwise, Trend = None.

Signal Determination:

  • For each configured zone: if the bar's high/low range overlaps the zone price range, a Signal fires in the direction of the current trend.
  • Zone prices are calculated as: zonePrice = level0Price − (level0Price − level1Price) × zoneLevel, where zoneLevel is from ZoneLevelsCSV.

Associated Functions:

  • AutoFib1(int shift, int buffer, int lsr, int mask)
  • Signal('AutoFib1')
  • Trend('AutoFib1')

BB1 - Bollinger Bands Indicator

File: \Indicators\NTL\BB.ex5
Description: Calculates Bollinger Bands, a volatility indicator using a moving average and standard deviations to define upper and lower bands. Useful for identifying overbought and oversold conditions as well as trend direction.

Creation String

NTL\BB([parameters,]).ex5

Default Setting:

NTL\BB(1,20,2.0).ex5,0,1,2,3

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The number of bars used to calculate the Bollinger Bands.
    • Default: 20.
  • Parameter 2: Deviations
    • The number of standard deviations for the upper and lower bands.
    • Default: 2.0.

Buffers

  • Buffer 0: MiddleBollinger values (Moving Average).
  • Buffer 1: UpperBollinger values (Upper Band).
  • Buffer 2: LowerBollinger values (Lower Band).
  • Buffer 3: SignalFlag values (Trend, Overbought/Oversold).

SignalFlag Logic

Trend Determination:

  • If the Close Price > MiddleBollinger, then Trend = Bullish.
  • If the Close Price < MiddleBollinger, then Trend = Bearish.
    Signal Determination:
  • If the High Price >= UpperBollinger, then OBOS = OverBought.
  • If the Low Price <= LowerBollinger, then OBOS = OverSold.

Associated Functions:

  • BB1(int shift, int buffer, int lsr, int mask)
  • Signal('BB1')
  • Trend('BB1')

ChoCh1 - Change of Character Indicator

File: \Indicators\NTL\ChoCh.ex5
Description: Detects Change of Character (ChoCh) patterns which occur when price sweeps the 100% level of a prior AutoFib retracement pattern, signaling a potential market structure shift. A bullish ChoCh forms when price sweeps below a bearish fib's 100% level (swing low), indicating bearish-to-bullish reversal potential. A bearish ChoCh forms when price sweeps above a bullish fib's 100% level (swing high), indicating bullish-to-bearish reversal potential. The ChoCh type is always the inverse of the swept AutoFib type. Supports multi-timeframe analysis with configurable AutoFib and ChoCh timeframes.

Creation String

NTL\ChoCh([parameters,]).ex5

Default Setting:

NTL\ChoCh(1,0,'0.0,0.3,0.5,0.618,0.762,1.0',3,55,3,6,55,100,0.0,8,250,45,'0.35,1',0,0,3,14,500).ex5,0,1,2,3,4,5,6,7,8

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: AutoFibTimeframe
    • Timeframe used for AutoFib pattern detection.
    • Default: 0 (current timeframe).
  • Parameter 2: FibLevelsCSV
    • Defines Fibonacci retracement levels as a CSV string.
    • Default: '0.0,0.3,0.5,0.618,0.762,1.0'.
  • Parameter 3: MinFibWidthInBars
    • Minimum width of the AutoFib pattern in bars.
    • Default: 3.
  • Parameter 4: MaxFibWidthInBars
    • Maximum width of the AutoFib pattern in bars.
    • Default: 55.
  • Parameter 5: MinFibHeightInABH
    • Minimum height of the AutoFib pattern in Average Bar Height (ABH).
    • Default: 3.
  • Parameter 6: MaxFibHeightInABH
    • Maximum height of the AutoFib pattern in ABH.
    • Default: 6.
  • Parameter 7: MaxFibRangeInBars
    • Maximum range in bars for the AutoFib pattern.
    • Default: 55.
  • Parameter 8: MinFibStrengthDifference
    • Minimum strength difference between 0% and 100% levels.
    • Default: 100.
  • Parameter 9: MinFibStrengthMultiplier
    • Minimum strength multiplier for the 100% level relative to the 0% level.
    • Default: 0.0.
  • Parameter 10: MinFib100Strength
    • Minimum strength of the 100% level.
    • Default: 8.
  • Parameter 11: MaxFib100Strength
    • Maximum strength of the 100% level.
    • Default: 250.
  • Parameter 12: MaxLookbackInBars
    • Maximum number of bars to look back for AutoFib analysis.
    • Default: 45.
  • Parameter 13: ZoneLevelsCSV
    • Defines Fibonacci zones as a CSV string.
    • Default: '0.35,1'.
  • Parameter 14: FibPatternBits
    • Defines the Fibonacci pattern filter as a bit pattern.
    • Default: 0.
  • Parameter 15: FibPatternSize
    • Size of the Fibonacci pattern in bits.
    • Default: 0.
  • Parameter 16: AppliedPrice
    • Defines the price to use for Fib calculations.
    • Default: 3 (High).
    • Options:
      • 1: Close
      • 3: High (uses high/low prices)
  • Parameter 17: ABHPeriod
    • Period used to calculate Average Bar Height.
    • Default: 14.
  • Parameter 18: ChoChMaxWidthInBars
    • Maximum width in bars from the swept fib level to the ChoCh bar. Used as a lookback limit when exporting grounded events for AI consumption.
    • Default: 500.
    • Set to 0 for unlimited lookback.

Buffers

  • Buffer 0: Bullish ChoCh Data values (bit-packed metadata for bullish patterns).
  • Buffer 1: Bearish ChoCh Data values (bit-packed metadata for bearish patterns).
  • Buffer 2: BullPriceHi values (level1Price from swept bearish fib — the 100% swing low that was swept).
  • Buffer 3: BullPriceLo values (level0Price from swept bearish fib — the 0% swing high origin level).
  • Buffer 4: BearPriceHi values (level0Price from swept bullish fib — the 0% swing low origin level).
  • Buffer 5: BearPriceLo values (level1Price from swept bullish fib — the 100% swing high that was swept).
  • Buffer 6: AutoFibLevel0 values (price at the 0% Fibonacci level / pattern origin). Written on every bar from the current AutoFib data, not only on ChoCh formation bars. Zero when no AutoFib data exists at the bar.
  • Buffer 7: AutoFibLevel1 values (price at the 100% Fibonacci level / swing extreme). Written on every bar from the current AutoFib data, not only on ChoCh formation bars. Zero when no AutoFib data exists at the bar.
  • Buffer 8: SignalFlag values (Signal).

ChoCh Data Buffer Bit Layout

The Bullish ChoCh Data (Buffer 0) and Bearish ChoCh Data (Buffer 1) buffers use bit-packed 48-bit values:

  • Bits 0-11: Backlink (bars to previous pattern or relay, max 4095).
  • Bits 12-19: SweptAge (bars since sweep event, max 255).
  • Bits 20-21: Type (01=Bullish, 10=Bearish).
  • Bit 22: Formed flag (1=ChoCh formed on this bar).
  • Bit 23: Swept flag (1=Fib level swept on this bar; always 1 when Formed=1 since ChoCh formation is the sweep event).
  • Bits 24-31: (unused, always zero).
  • Bits 32-43: Size (pattern width in bars, formation bar only, internal use — also exported in grounded events).

Two Bar Types in the Data Buffer

  1. Formation bar (Formed=1): Written by AddNew. All active bits populated. This is the pattern origin and the only bar where Type, Swept, and Size are stored. Formation bars are NOT mutated in-place after creation — Size is fixed at detection time. SweptAge starts at 1 because ChoCh formation IS the sweep event. Price buffers contain the swept zone upper and lower boundaries.

  2. Relay waypoint (Formed=0): Written by UpdateExisting. Carries chain traversal and sweep propagation data only: Backlink (bits 0-11) is always written to enable chain traversal; SweptAge (bits 12-19) is incremented while active, 0 when expired; all other bits are zero. Price buffers are propagated from the previous bar while SweptAge > 0, and left as zero when SweptAge has expired.

Note: All ChoCh buffer data is real-time safe. Unlike LP and FVG, ChoCh does not mutate formation bars retroactively — size is fixed at detection time and there is no terminated flag. All fields are safe for EA/script trading decisions.

SignalFlag Logic

Signal Determination (ChoCh type is always the inverse of the swept AutoFib type):

  • If a bearish AutoFib's 100% level (swing low) is swept, then Signal = Bullish (Bullish ChoCh).
  • If a bullish AutoFib's 100% level (swing high) is swept, then Signal = Bearish (Bearish ChoCh).

Note: ChoCh does not produce Trend signals; it only produces Signal events on sweep detection.

Pattern Detection Rules

Bullish ChoCh requires:

  • A valid bearish AutoFib pattern with 100% level at swing low.
  • Price closes below the swing low, sweeping the 100% level.
  • Pattern not already processed (unique AutoFib level1 position).
  • Same-timeframe mode uses AutoFib's level1Broken flag; lower-timeframe mode checks close vs fib low directly.

Bearish ChoCh requires:

  • A valid bullish AutoFib pattern with 100% level at swing high.
  • Price closes above the swing high, sweeping the 100% level.
  • Pattern not already processed (unique AutoFib level1 position).
  • Same-timeframe mode uses AutoFib's level1Broken flag; lower-timeframe mode checks close vs fib high directly.

ChoCh Swept

A ChoCh is detected when:

  • For Bullish ChoCh: Close price falls below the bearish fib's swing low (100% level), sweeping below it.
  • For Bearish ChoCh: Close price rises above the bullish fib's swing high (100% level), sweeping above it.

Since ChoCh formation occurs at the moment the fib level is swept, the SweptAge counter starts at 1 when the pattern forms and increments each bar (up to 255). While SweptAge is non-zero, the swept price levels propagate forward in the corresponding price buffers: BullPriceHi/BullPriceLo for bullish patterns and BearPriceHi/BearPriceLo for bearish patterns. ChoCh tracks at most one sweep per side at a time; when SweptAge expires, price buffers are left as zero.

Price Buffer Propagation

Price buffers (PriceHi/PriceLo) are conditionally written per side. On each bar, UpdateExisting propagates prices from the previous bar while SweptAge remains active. When SweptAge expires (reaches 255 or was already 0), price buffers are left as zero, explicitly signalling that no active sweep exists on this side.

Price source priority (latest write wins):

  1. New ChoCh formation overwrites with swept zone boundaries.
  2. Active SweptAge propagates from previous bar.
  3. Zero (SweptAge expired, no active sweep on this side).

Associated Functions:

  • ChoCh1(int shift, int buffer, int lsr, int mask)
  • Signal('ChoCh1')

FVG1 - Fair Value Gap Indicator

File: \Indicators\NTL\FVG.ex5
Description: Detects and tracks Fair Value Gap (FVG) patterns, which are price imbalances formed when a gap exists between the high of an earlier bar and the low of a later bar (bullish) or vice versa (bearish). Uses dual-buffer architecture with separate backlink chains for bullish and bearish patterns, enabling independent tracking and termination of each type. Patterns are drawn as boxes and tracked until filled or terminated. Uses Average Bar Height (ABH) for dynamic threshold calculations.

Creation String

NTL\FVG([parameters,]).ex5

Default Setting:

NTL\FVG(1,0,400,0.1,0.0,0.4,3.0,0.1,3,14).ex5,0,1,2,3,4,5,6

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Timeframe
    • Specifies the timeframe to analyse.
    • Default: 0 (current timeframe).
  • Parameter 2: MaxBoxWidthInBars
    • Maximum width in bars before the FVG box is terminated.
    • Default: 400.
    • Set to 0 for no maximum.
  • Parameter 3: MinBarHeightInABH
    • Minimum bar height as a multiple of Average Bar Height.
    • Default: 0.1.
  • Parameter 4: MinWickHeightInABH
    • Minimum wick height as a multiple of Average Bar Height.
    • Default: 0.0.
    • Set to 0 to disable wick validation.
  • Parameter 5: MinGapHeightInABH
    • Minimum gap height as a multiple of Average Bar Height.
    • Default: 0.4.
  • Parameter 6: MaxGapHeightInABH
    • Maximum gap height as a multiple of Average Bar Height.
    • Default: 3.0.
  • Parameter 7: MaxGapFillThreshold
    • Percentage of gap fill (0-1) that terminates the box.
    • Default: 0.1 (10% fill terminates).
  • Parameter 8: WidthInBars
    • Number of bars that form the FVG pattern.
    • Default: 3.
  • Parameter 9: ABHPeriod
    • Period used to calculate Average Bar Height.
    • Default: 14.
  • Parameter 10: HideFilledFVGs
    • Hides filled FVG boxes from the chart display.
    • Default: false.
  • Parameter 11: FontSize
    • Font size for chart labels.
    • Default: 9.

Buffers

  • Buffer 0: BullFVG Data values (bit-packed bullish pattern metadata).
    • Bits 0-11: Backlink (bars to previous pattern/relay, max 4,095).
    • Bits 12-22: UnfilledAge (bars since formation while unfilled, max 2,047).
    • Bits 23-24: Type (1=Bullish). Formation and fill bars only; zero on relay waypoints.
    • Bit 25: Formed flag (1=FVG formed on this bar). Formation bars only.
    • Bit 26: Filled flag (1=FVG fill threshold reached on this bar). Formation and fill bars only; zero on relay waypoints.
    • Bits 27-34: FillValue (gap fill percentage 0-100). Running maximum on formation bars; snapshot on fill bars; zero on relay waypoints.
    • Bits 35-46: Size (box width in bars, max 4,095). Formation bars only. Future data — mutated retroactively, for drawing/internal use only, must NOT be used in EA/script trading logic.
    • Bit 47: Terminated flag (1=box terminated). Formation bars only. Future data — mutated retroactively, for drawing/internal use only, must NOT be used in EA/script trading logic.
  • Buffer 1: BearFVG Data values (bit-packed bearish pattern metadata).
    • Same layout as Buffer 0. Type field is 2=Bearish on formation and fill bars.
  • Buffer 2: BullPriceHigh values (bullish zone upper price boundary — latest bar's low).
  • Buffer 3: BullPriceLow values (bullish zone lower price boundary — earliest bar's high).
  • Buffer 4: BearPriceHigh values (bearish zone upper price boundary — earliest bar's low).
  • Buffer 5: BearPriceLow values (bearish zone lower price boundary — latest bar's high).
  • Buffer 6: SignalFlags values (standard INDICATORSIGNALDATA format: Trend, Signal, bar offsets, and indicator ID).

Bar Types in Data Buffers

Each data buffer (Buffer 0 and Buffer 1) contains three distinct bar types with different field populations:

  1. Formation bar (formed=1): All 48 bits populated. This is the pattern origin. Size and terminated are mutated in-place on every subsequent bar as the pattern ages. FillValue and filled are updated when price intrudes into the zone. Price buffers receive the zone boundaries.

  2. Relay waypoint (formed=0, filled=0): Only backlink (bits 0-11) and unfilledAge (bits 12-22) are populated; all other fields are zero. Written on every bar where an active chain exists. Price buffers are written conditionally: filled zone if a fill occurred, else latest active pattern's zone, else zero.

  3. Fill bar (overwrites relay at current bar when fill occurs): Carries backlink, unfilledAge (from the next surviving pattern, or 0 if none remain), type, filled=1, and fillValue. Size and terminated are zero (not a formation bar). Price buffers receive the filled zone's boundaries.

Price Buffer Propagation

Price buffers (Buffers 2-5) are conditionally written per side on each bar. Priority order (latest write wins):

  1. New FVG formation overwrites with zone boundaries.
  2. Fresh fill overwrites with filled zone boundaries.
  3. Latest active pattern's zone boundaries (no fill, but live patterns exist).
  4. Zero (no active patterns, no fill — explicitly signals no live FVG zone on this side).

UnfilledAge Tracking

The UnfilledAge field tracks how many bars an FVG pattern remains unfilled:

  • When an FVG is first formed, UnfilledAge is set to 1.
  • On each subsequent bar while the FVG remains active (unfilled), UnfilledAge increments by 1.
  • When the FVG becomes filled, UnfilledAge switches to the age of the next unfilled FVG in the chain (or 0 if no unfilled FVGs remain).
  • UnfilledAge is propagated through relay waypoints in the backlink chain.
  • Maximum value is 2,047 bars (clamped at overflow).

SignalFlag Logic

Trend Determination:

  • If a valid Bullish FVG is detected, then Trend = Bullish.
  • If a valid Bearish FVG is detected, then Trend = Bearish.
  • Both sides are checked independently; both can form on the same bar.

Signal Determination:

  • If a Bullish FVG is filled (price retraces into the gap beyond the fill threshold), then Signal = Bullish (support zone touched).
  • If a Bearish FVG is filled (price retraces into the gap beyond the fill threshold), then Signal = Bearish (resistance zone touched).

Pattern Detection Rules

Bullish FVG requires:

  • Gap between earliest bar high and latest bar low within configured min/max gap height thresholds.
  • All bars in the pattern are bullish (close > open).
  • All bars meet minimum bar height requirement.
  • Upper wick of earliest bar and lower wick of latest bar meet minimum wick height (if configured).

Bearish FVG requires:

  • Gap between earliest bar low and latest bar high within configured min/max gap height thresholds.
  • All bars in the pattern are bearish (close < open).
  • All bars meet minimum bar height requirement.
  • Lower wick of earliest bar and upper wick of latest bar meet minimum wick height (if configured).

Box Filled

An FVG box is filled when price intrudes into the zone beyond the MaxGapFillThreshold percentage:

  • Bullish: (boxHi - currentBarLow) / boxHeight >= threshold — the bar's low reaches into the zone from above.
  • Bearish: (currentBarHigh - boxLo) / boxHeight >= threshold — the bar's high reaches into the zone from below.

Associated Functions:

  • FVG1(int shift, int buffer, int lsr, int mask)
  • Signal('FVG1')
  • Trend('FVG1')

HLines1 - Horizontal Lines Support and Resistance Indicator

File: \Indicators\NTL\HLines.ex5
Description: Identifies and analyses horizontal support and resistance lines across multiple timeframes. Customizable settings allow traders to adapt the indicator to various strategies, highlighting high-probability price levels for entries and exits.

Creation String

NTL\HLines([parameters,]).ex5

Default Setting:

NTL\HLines(1,'',800,100,'S2;R2',35,0.0,0.5,100).ex5,0,1

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Timeframes
    • Specifies the timeframe(s) to analyse.
    • Default: N/A.
  • Parameter 2: Period
    • The number of bars used to calculate support and resistance levels.
    • Default: 800.
  • Parameter 3: MinStrength
    • Minimum strength of a line to be included in the analysis.
    • Default: 100.
  • Parameter 4: PivotString
    • Filters patterns of support and resistance pivots.
    • Default: 'S2;R2'.
  • Parameter 5: MaxBodyCrosses
    • Maximum number of candle bodies that a line can cross.
    • Default: 35.
  • Parameter 6: PivotWeightInABH
    • Tolerance for pivot points as a fraction of average bar height.
    • Default: 0.0.
  • Parameter 7: LineWobbleToleranceInABH
    • Tolerance for line wobble in average bar height.
    • Default: 0.5.
  • Parameter 8: ABHPeriod
    • Period used to calculate average bar height.
    • Default: 100.

Buffers

  • Buffer 0: HLine Price values (Horizontal Line prices).
  • Buffer 1: SignalFlag values (Signal).

SignalFlag Logic

HLine Determination:

  • The horizontal line is created on the current bar and is closest to the Close Price.
    Signal Determination:
  • If Close Price > HLine, then Signal = Bullish.
  • If Close Price < HLine, then Signal = Bearish.

Associated Functions:

  • HLines1(int shift, int buffer, int lsr, int mask)
  • Signal('HLines1')

JCP1 - Japanese Candle Patterns Indicator

File: \Indicators\NTL\JCP.ex5
Description: Detects and categorizes Japanese candlestick patterns for market analysis and trading strategies.

Creation String

NTL\JCP([parameters,]).ex5

Default Setting:

NTL\JCP(1).ex5,0,1

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.

Buffers

  • Buffer 0: Candle Pattern Data
    • Bits 0-15: Pattern Type
    • Bits 16-19: Pattern Width in Bars
  • Buffer 1: SignalFlag values (Signal)
    • Signal Logic:
      • If PatternTrendType is Bearish, TopReversal, or MajorTopReversal: Signal = Bearish
      • If PatternTrendType is Bullish, BottomReversal, or MajorBottomReversal: Signal = Bullish

Pattern Types

The following are the supported candlestick patterns with their corresponding identifiers:

  • 0: AbandonedBabyBottom
  • 1: AbandonedBabyTop
  • 2: AscendingChannel
  • 3: AscendingTriangle
  • 4: BearishBeltHold
  • 5: BearishCounterAttack
  • 6: BearishEngulfing
  • 7: BearishHarami
  • 8: BearishHLinePin
  • 9: BearishSeparating
  • 10: BullishBeltHold
  • 11: BullishCounterAttack
  • 12: BullishEngulfing
  • 13: BullishHarami
  • 14: BullishHLinePin
  • 15: BullishSeparating
  • 16: DarkCloudCover
  • 17: DescendingChannel
  • 18: DescendingTriangle
  • 19: Doji
  • 20: DojiStar
  • 21: DragonFlyDoji
  • 22: EveningStar
  • 23: FallingThreeMethod
  • 24: FallingWindow
  • 25: FlatLowerBody
  • 26: FlatUpperBody
  • 27: GravestoneDoji
  • 28: Hammer
  • 29: HangingMan
  • 30: HighWave
  • 31: InvertedHammer
  • 32: LongLeggedDoji
  • 33: LongLowerShadow
  • 34: LongUpperShadow
  • 35: Marubozu
  • 36: MorningStar
  • 37: Pennant
  • 38: PiercingPattern
  • 39: Rectangle
  • 40: ResistanceLine
  • 41: RisingThreeMethod
  • 42: RisingWindow
  • 43: ShavenBottom
  • 44: ShavenHead
  • 45: ShootingStar
  • 46: SpinningTop
  • 47: SupportLine
  • 48: ThreeBlackCrows
  • 49: ThreeWhiteSoldiers
  • 50: TowerBottom
  • 51: TowerTop
  • 52: TweezerTop
  • 53: TweezerBottom
  • 54: UpsideGapTwoCrows

By using JCP1, traders can automate the identification of these patterns, improving decision-making and aligning their strategies with market sentiment.

Associated Functions:

  • JCP1(int shift, int buffer, int lsr, int mask)
  • Signal('JCP1')

Keltner1 - Keltner Channels Indicator

File: \Indicators\NTL\Keltner.ex5
Description: Calculates Keltner Channels, a volatility-based envelope indicator that uses a moving average and an average true range (ATR) to define upper and lower bands. Useful for identifying trends and overbought/oversold conditions.

Creation String

NTL\Keltner([parameters,]).ex5

Default Setting:

NTL\Keltner(1,20,1,2.25).ex5,0,1,2,3

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The number of bars used for calculating the moving average.
    • Default: 20.
  • Parameter 2: MAMethod
    • The method used to calculate the moving average.
    • Default: 1.
    • Options:
      • 0: Simple Averaging
      • 1: Exponential Averaging
      • 2: Smoothed Averaging
      • 3: Linear Weighted Averaging
  • Parameter 3: Ratio
    • Multiplier for the average true range (ATR) to define the channel width.
    • Default: 2.25.

Buffers

  • Buffer 0: MiddleKeltner values (Moving Average).
  • Buffer 1: UpperKeltner values (Upper Band).
  • Buffer 2: LowerKeltner values (Lower Band).
  • Buffer 3: SignalFlag values (Trend, Overbought/Oversold).

SignalFlag Logic

Trend Determination:

  • If Close Price > MiddleKeltner, then Trend = Bullish.
  • If Close Price < MiddleKeltner, then Trend = Bearish.
  • Otherwise, Trend = None.

OBOS Determination:

  • If High Price > UpperKeltner, then OBOS = OverBought.
  • If Low Price < LowerKeltner, then OBOS = OverSold.

Associated Functions:

  • Keltner1(int shift, int buffer, int lsr, int mask)
  • Trend('Keltner1')
  • OBOS('Keltner1')

LP1 - Liquidity Pool Indicator

File: \Indicators\NTL\LP.ex5
Description: Identifies Buy Side Liquidity (BSL) and Sell Side Liquidity (SSL) zones based on pivot point analysis. BSL forms at swing highs where stop losses accumulate above price. SSL forms at swing lows where stop losses accumulate below price. Patterns are drawn as horizontal lines extending from the pivot point until price sweeps the level or the maximum width is reached. Uses pivot order and bar strength for pattern validation. Signals generated when liquidity pools are swept. Optional internal/external liquidity classification separates major HTF liquidity targets from micro consolidation liquidity using max price excursion normalised by ABH. The SweptExternalAge buffer independently tracks how many bars have elapsed since the most recent external liquidity sweep on each side.

Creation String

NTL\LP([parameters,]).ex5

Default Setting:

NTL\LP(1,0,800,2,6,12,400,14,7.0,0.0,2).ex5,0,1,2,3,4,5,6,7,8,9,10,11

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Timeframe
    • Specifies the timeframe to analyse.
    • Default: 0 (current timeframe).
  • Parameter 2: MaxLookbackInBars
    • Maximum number of bars to search for pivot points.
    • Default: 800.
  • Parameter 3: MinPivotOrder
    • Minimum pivot order required for LP detection.
    • Default: 2.
  • Parameter 4: MaxPivotOrder
    • Maximum pivot order used for pivot analysis.
    • Default: 6.
  • Parameter 5: MinBarStrength
    • Minimum bar strength required at the pivot.
    • Default: 12.
  • Parameter 6: MaxWidthInBars
    • Maximum width in bars before the LP line is terminated.
    • Default: 400.
    • Set to 0 for no maximum.
  • Parameter 7: ABHPeriod
    • Period for the Average Bar Height indicator used in external liquidity classification.
    • Default: 14.
  • Parameter 8: LiquidityClassificationABH
    • ABH multiplier for internal/external liquidity classification threshold.
    • Default: 7.0.
    • Set to 0 to disable classification.
    • When > 0, an LP is classified as external if the maximum price excursion from the pivot, normalised by ABH, meets or exceeds this threshold. External liquidity represents major HTF swing highs/lows; internal liquidity represents micro liquidity inside consolidation.
  • Parameter 9: MinSwingInABH
    • Minimum swing size in ABH units required for LP detection.
    • Default: 0.0 (no minimum).
    • When > 0, a pivot is only accepted as an LP if its swing distance (normalised by ABH) meets or exceeds this value. Filters out small, insignificant pivots.
  • Parameter 10: ExportType
    • Controls which grounded event types are included in export.
    • Default: 2 (Both).
    • 0 = Liquidity Only, 1 = Structure Only, 2 = Both.

Buffers

  • Buffer 0: BSL Data values (bit-packed metadata for Buy Side Liquidity).
  • Buffer 1: SSL Data values (bit-packed metadata for Sell Side Liquidity).
  • Buffer 2: BSLPrice values (Buy Side Liquidity price level).
  • Buffer 3: SSLPrice values (Sell Side Liquidity price level).
  • Buffer 4: BSLSweptPrice values (most recent swept Buy Side Liquidity price level).
  • Buffer 5: SSLSweptPrice values (most recent swept Sell Side Liquidity price level).
  • Buffer 6: SweptExternalAge values (bit-packed bars since most recent external sweep per side).
  • Buffer 7: StructureData values (bit-packed metadata for market structure points HH/LH/HL/LL).
  • Buffer 8: StructurePrice values (pivot price of classified structure points).
  • Buffer 9: BOSData values (bit-packed metadata for Break-of-Structure events).
  • Buffer 10: BOSPrice values (price of the broken structure level).
  • Buffer 11: SignalFlag values (Trend, Signal).

LP Data Buffer Bit Layout

The BSL Data (Buffer 0) and SSL Data (Buffer 1) buffers use bit-packed 49-bit values:

  • Bits 0-11: Backlink (bars to previous pattern or relay, max 4095).
  • Bits 12-19: SweptAge (bars since sweep event, max 255).
  • Bits 20-21: Type (01=Bullish/BSL, 10=Bearish/SSL).
  • Bit 22: Formed flag (1=LP formed on this bar).
  • Bit 23: Swept flag (1=LP swept on this bar).
  • Bits 24-35: Size (pattern width in bars, internal use only).
  • Bits 36-45: Pivot Shift (bars from current to pivot, max 1023, internal use only).
  • Bit 47: Terminated flag (1=pattern no longer active, internal use only).
  • Bit 48: External flag (1=external liquidity classification, internal use only on formation bars; real-time safe on relay bars).

Note: Size, PivotShift, Terminated, and External (on formation bars) are for drawing/internal use only and must not be used in EAs as they rely on future bar data. The following fields on relay bars are real-time safe for EA use: Backlink, SweptAge, Swept, and External.

Swept Price Buffers

The BSLSweptPrice (Buffer 4) and SSLSweptPrice (Buffer 5) buffers store the pivot price of the most recently swept LP on each side. When a sweep is detected, the swept pattern's pivot price is written to the current bar and propagated forward for as long as SweptAge is active (up to 255 bars). A non-zero value is only meaningful when SweptAge > 0 on the corresponding data buffer.

Use the SweptExternalAge buffer (Buffer 6) to determine whether the most recent sweep was of an external LP.

SweptExternalAge Buffer Bit Layout

The SweptExternalAge buffer (Buffer 6) uses bit-packed 16-bit values to track the number of bars since the most recent external liquidity sweep for each side:

  • Bits 0-7: BSL SweptExternalAge (bars since BSL external sweep, max 255).
  • Bits 8-15: SSL SweptExternalAge (bars since SSL external sweep, max 255).

A value of 0 indicates no recent external sweep for that side. When an external LP is swept, the counter is set to 1 on the sweep bar, increments by 1 each subsequent bar, and drops to 0 after reaching max value (255).

SweptExternalAge operates independently from SweptAge in the data buffer. Non-external sweeps do not reset SweptExternalAge — the counter continues incrementing through non-external sweeps, counting only from the most recent external sweep. This allows EAs to test conditions like "has external liquidity been swept within the last 50 bars?" without chain traversal.

Structure Data Buffer Bit Layout

The StructureData buffer (Buffer 7) uses bit-packed 56-bit values to classify market structure pivots:

  • Bits 0-11: Backlink (bars to previous structure point or relay, max 4095).
  • Bits 12-19: SweptAge (reserved, currently unused — always 0).
  • Bits 20-22: StructType (0=None, 1=HH, 2=LH, 3=HL, 4=LL).
  • Bit 23: Formed flag (1=structure point classified on this bar).
  • Bit 24: Swept flag (reserved, currently unused — always 0).
  • Bits 25-34: PivotShift (bars from current to pivot, max 1023, internal use only).
  • Bit 35: Terminated flag (1=structure point no longer active, internal use only).
  • Bits 36-43: Strength (bar strength at the pivot, 0-255).
  • Bits 44-55: ABHMultiples (swing distance in 0.1 ABH units, max 4095).

Note: PivotShift and Terminated are for drawing/internal use only and must not be used in EAs as they rely on future bar data. SweptAge and Swept are reserved for future use and currently always 0. The following fields on relay bars are real-time safe for EA use: Backlink, StructType, Formed, Strength, and ABHMultiples.

Structure classification works by comparing consecutive pivots:

  • HH (Higher High): A high pivot whose price exceeds the previous high pivot price.
  • LH (Lower High): A high pivot whose price is at or below the previous high pivot price.
  • HL (Higher Low): A low pivot whose price exceeds the previous low pivot price.
  • LL (Lower Low): A low pivot whose price is at or below the previous low pivot price.

BOS Data Buffer Bit Layout

The BOSData buffer (Buffer 9) uses bit-packed 15-bit values to record Break-of-Structure events:

  • Bits 0-1: BOSType (0=None, 1=Bullish, 2=Bearish).
  • Bits 2-13: BrokenLevel (bars back to the broken structure point, max 4095).
  • Bit 14: Formed flag (1=BOS detected on this bar).

Break-of-Structure is detected when the closing price breaks through a recent structure level. At most one BOS is detected per bar; bullish is checked first:

  • Bullish BOS: Close exceeds the last HH or LH structure price.
  • Bearish BOS: Close falls below the last HL or LL structure price (only checked if no bullish BOS on this bar).

The BOSPrice buffer (Buffer 10) stores the price of the broken structure level on the bar where BOS is detected.

Liquidity Classification

When LiquidityClassificationABH is set to a value greater than 0, the indicator classifies each LP as either internal or external liquidity based on maximum price excursion from the pivot level, normalised by ABH.

  • External liquidity (external=1): The maximum price excursion from the pivot divided by ABH meets or exceeds the LiquidityClassificationABH threshold. Represents major HTF swing highs/lows that are true higher-timeframe liquidity targets.
  • Internal liquidity (external=0): The excursion is below the threshold. Represents micro liquidity inside consolidation.

For BSL, excursion measures the deepest drop below the swing high (pivot price minus minimum low). For SSL, excursion measures the highest rise above the swing low (maximum high minus pivot price).

Classification is a one-way latch: once a pattern is classified as external, it remains external. Patterns may be promoted from internal to external on subsequent bars as price continues to move away from the pivot.

The external flag is propagated to relay bars: if any active pattern in the chain is classified as external, the relay bar's external bit is set to 1, providing O(1) lookup for external liquidity presence without chain traversal.

SignalFlag Logic

Trend Determination:

  • If a Bearish LP (SSL) forms, then Trend = Bearish (SSL is checked first).
  • Else if a Bullish LP (BSL) forms, then Trend = Bullish.
  • If both sides detect a pattern on the same bar, SSL takes priority.

Signal Determination:

  • If a Bullish LP (BSL) is swept (price high exceeds pivot high), then Signal = Bullish.
  • If a Bearish LP (SSL) is swept (price low falls below pivot low), then Signal = Bearish.
  • If both sides are swept on the same bar, SSL takes priority.

Pattern Detection Rules

Bullish LP (Buy Side Liquidity) requires:

  • A high pivot with order >= MinPivotOrder found within MaxLookbackInBars.
  • Bar strength at the pivot >= MinBarStrength.
  • The pivot is not the same as the previously detected pivot on this side.
  • No LP already formed at the current bar on this side.
  • If MinSwingInABH > 0, the swing distance from pivot (normalised by ABH) >= MinSwingInABH.

Bearish LP (Sell Side Liquidity) requires:

  • A low pivot with order >= MinPivotOrder found within MaxLookbackInBars.
  • Bar strength at the pivot >= MinBarStrength.
  • The pivot is not the same as the previously detected pivot on this side.
  • No LP already formed at the current bar on this side.
  • If MinSwingInABH > 0, the swing distance from pivot (normalised by ABH) >= MinSwingInABH.

LP Swept

An LP line is swept when:

  • For BSL: Price high exceeds the pivot high price.
  • For SSL: Price low falls below the pivot low price.

When swept, the SweptAge counter starts at 1 and increments each bar (up to 255), allowing the swept price level to propagate forward in the swept price buffers. If the swept LP was classified as external, the SweptExternalAge counter on the corresponding side of Buffer 6 is independently set to 1 and increments each bar (up to 255).

Examples

Read BSL and SSL swept prices at the current bar:

BSLSweptPrice = LP1(0, 4)
SSLSweptPrice = LP1(0, 5)

Check whether a BSL sweep is active (SweptAge > 0 means a sweep occurred within the last 255 bars):

BSLSweptAge = LP1(0, 0, 12, 255)

Check whether a SSL sweep is active:

SSLSweptAge = LP1(0, 1, 12, 255)

Read BSL SweptExternalAge (bars since last BSL external sweep, 0 if none):

BSLSweptExternalAge = LP1(0, 6, 0, 255)

Read SSL SweptExternalAge (bars since last SSL external sweep, 0 if none):

SSLSweptExternalAge = LP1(0, 6, 8, 255)

Check if external BSL liquidity was swept within the last 50 bars:

BSLSweptExternalAge = LP1(0, 6, 0, 255)
// True when BSLSweptExternalAge > 0 && BSLSweptExternalAge <= 50

Check if external SSL liquidity was swept within the last 50 bars:

SSLSweptExternalAge = LP1(0, 6, 8, 255)
// True when SSLSweptExternalAge > 0 && SSLSweptExternalAge <= 50

Combine to read the BSL swept price only when it was an external sweep:

BSLSweptExternalAge = LP1(0, 6, 0, 255)
BSLSweptPrice = LP1(0, 4)
// BSLSweptPrice represents an external sweep when BSLSweptExternalAge > 0

Combine to read the SSL swept price only when it was an external sweep:

SSLSweptExternalAge = LP1(0, 6, 8, 255)
SSLSweptPrice = LP1(0, 5)
// SSLSweptPrice represents an external sweep when SSLSweptExternalAge > 0

Read the structure type at the current bar (0=None, 1=HH, 2=LH, 3=HL, 4=LL):

StructType = LP1(0, 7, 20, 7)

Read the structure price at the current bar:

StructPrice = LP1(0, 8)

Read the bar strength of a structure point:

StructStrength = LP1(0, 7, 36, 255)

Check if a BOS formed on the current bar (BOSType: 1=Bullish, 2=Bearish):

BOSType = LP1(0, 9, 0, 3)

Read the BOS broken price level:

BOSPrice = LP1(0, 10)

Associated Functions:

  • LP1(int shift, int buffer, int lsr, int mask)
  • Signal('LP1')
  • Trend('LP1')

MA1 - Moving Average Indicator

File: \Indicators\NTL\MA.ex5
Description: Calculates one or two moving averages using customizable periods and methods. Useful for identifying trends and generating buy/sell signals based on crossovers or price relation to the moving averages.

Creation String

NTL\MA([parameters,]).ex5

Default Setting:

NTL\MA(1,50,1,200,1).ex5,0,1,2

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period1
    • The number of bars used for the first moving average.
    • Default: 50.
  • Parameter 2: Method1
    • The method used to calculate the first moving average.
    • Default: 1.
    • Options:
      • 0: Simple Averaging
      • 1: Exponential Averaging
      • 2: Smoothed Averaging
      • 3: Linear Weighted Averaging
  • Parameter 3: Period2
    • The number of bars used for the second moving average. Set to 0 to use a single moving average.
    • Default: 200.
  • Parameter 4: Method2
    • The method used to calculate the second moving average.
    • Default: 1.
    • Options:
      • 0: Simple Averaging
      • 1: Exponential Averaging
      • 2: Smoothed Averaging
      • 3: Linear Weighted Averaging

Buffers

  • Buffer 0: Line1 values (First Moving Average).
  • Buffer 1: Line2 values (Second Moving Average).
  • Buffer 2: SignalFlag values (Trend, Signal).

SignalFlag Logic

Trend Determination:

  • If Period2 = 0:
    • If Close Price > Line1, then Trend = Bullish.
    • If Close Price < Line1, then Trend = Bearish.
    • Otherwise, Trend = None.
  • If Period1 < Period2:
    • If Line1 > Line2, then Trend = Bullish.
    • If Line1 < Line2, then Trend = Bearish.
  • Otherwise:
    • If Line2 > Line1, then Trend = Bullish.
    • If Line2 < Line1, then Trend = Bearish.

Signal Determination:

  • If Trend = Bullish and PreviousTrend = Bearish, then Signal = Bullish.
  • If Trend = Bearish and PreviousTrend = Bullish, then Signal = Bearish.

Associated Functions:

  • MA1(int shift, int buffer, int lsr, int mask)
  • Signal('MA1')
  • Trend('MA1')

MACD1 - Moving Average Convergence/Divergence Indicator

File: \Indicators\NTL\MACD.ex5
Description: Calculates the MACD, an indicator based on the difference between fast and slow moving averages, with a signal line and histogram for trend and momentum analysis.

Creation String

NTL\MACD([parameters,]).ex5

Default Setting:

NTL\MACD(1,12,26,9).ex5,0,4

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: FastPeriod
    • The number of bars for the fast moving average.
    • Default: 12.
  • Parameter 2: SlowPeriod
    • The number of bars for the slow moving average.
    • Default: 26.
  • Parameter 3: SignalPeriod
    • The number of bars for calculating the signal line.
    • Default: 9.
  • Parameter 4: SignalLogicMethod
    • Specifies the logic used for generating signals.
    • Default: 1.
    • Options:
      • 0: Histogram Crosses Zero
      • 1: MACD Line Crosses Zero
      • 2: Signal Line Crosses MACD Line

Buffers

  • Buffer 0: MACD values (Difference between FastPeriod and SlowPeriod moving averages).
  • Buffer 1: Signal values (Smoothed MACD line).
  • Buffer 2: Histogram values (Difference between MACD and Signal).
  • Buffer 3: Color values (Histogram color coding).
  • Buffer 4: SignalFlag values (Trend, Signal).

SignalFlag Logic

Trend Determination:

  • If Histogram > 0, then Trend = Bullish.
  • If Histogram < 0, then Trend = Bearish.

Signal Determination:

  • If SignalLogicMethod = 0 (Histogram Crosses Zero):
    • If Trend = Bullish and PreviousHistogram < 0, then Signal = Bullish.
    • If Trend = Bearish and PreviousHistogram > 0, then Signal = Bearish.
  • If SignalLogicMethod = 1 (MACD Line Crosses Zero):
    • If MACD > 0 and PreviousMACD < 0, then Signal = Bullish.
    • If MACD < 0 and PreviousMACD > 0, then Signal = Bearish.
  • If SignalLogicMethod = 2 (Signal Line Crosses MACD Line):
    • If Trend = Bullish and SignalLine < MACD and PreviousSignalLine > PreviousMACD then Signal = Bearish.
    • If Trend = Bearish and SignalLine > MACD and PreviousSignalLine < PreviousMACD then Signal = Bullish.

Associated Functions:

  • MACD1(int shift, int buffer, int lsr, int mask)
  • Signal('MACD1')
  • Trend('MACD1')

Markets1 - Market Times Indicator

File: \Indicators\NTL\Markets.ex5
Description: Calculates the opening and closing times for all major financial centers like Frankfurt, London, New York, Sydney, Tokyo. Its buffer stores market session data to track which markets are currently open and for how long they've been open in bars.

Creation String

NTL\Markets([parameters,]).ex5

Default Setting:

NTL\Markets(1).ex5,0

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.

Buffers

  • Buffer 0: Open/Close state and bar count since market opened for 5 markets.
    • Bit 0: Frankfurt: Open/Close (1=Open).
    • Bits 1-9: Frankfurt: Bar count since market opened.
    • Bit 10: London: Open/Close (1=Open).
    • Bits 11-19: London: Bar count since market opened.
    • Bit 20: New York: Open/Close (1=Open).
    • Bits 21-29: New York: Bar count since market opened.
    • Bit 30: Sydney: Open/Close (1=Open).
    • Bits 31-39: Sydney: Bar count since market opened.
    • Bit 40: Tokyo: Open/Close (1=Open).
    • Bits 41-49: Tokyo: Bar count since market opened.

Associated Functions:

  • Markets1(int shift, int buffer, int lsr, int mask)

OsMA1 - Oscillator Of A Moving Average Indicator

File: \Indicators\NTL\OSMA.ex5
Description: Calculates the difference between the MACD line and its signal line, providing a momentum oscillator for trend and signal analysis.

Creation String

NTL\OsMA([parameters,]).ex5

Default Setting:

NTL\OsMA(1,12,26,9).ex5,0,1

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: FastPeriod
    • The number of bars for the fast moving average.
    • Default: 12.
  • Parameter 2: SlowPeriod
    • The number of bars for the slow moving average.
    • Default: 26.
  • Parameter 3: SignalPeriod
    • The number of bars for calculating the signal line.
    • Default: 9.

Buffers

  • Buffer 0: OSMA values (Difference between MACD and Signal).
  • Buffer 1: SignalFlag values (Trend, Signal).

SignalFlag Logic

Trend Determination:

  • If OSMA > 0, then Trend = Bullish.
  • If OSMA < 0, then Trend = Bearish.

Signal Determination:

  • If Trend = Bullish and PreviousOSMA < 0, then Signal = Bullish.
  • If Trend = Bearish and PreviousOSMA > 0, then Signal = Bearish.

Associated Functions:

  • OsMA1(int shift, int buffer, int lsr, int mask)
  • Signal('OsMA1')
  • Trend('OsMA1')

PL1 - Pivot Lines Indicator

File: \Indicators\NTL\PL.ex5
Description: Identifies pivot points and their corresponding support and resistance levels using various calculation methods, such as Regular, Camarilla, Woodie, and Fibonacci. Useful for determining key price levels and anticipating market movements.

Creation String

NTL\PL([parameters,]).ex5

Default Setting:

NTL\PL(1,16408,4).ex5,0

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The timeframe used for pivot point calculations.
    • Default: 0.
    • Options:
      • 0: Daily (PERIOD_D1)
      • 1: Weekly (PERIOD_W1)
      • 2: Monthly (PERIOD_MN1)
  • Parameter 2: Method
    • The calculation method for pivot points.
    • Default: 4.
    • Options:
      • 0: None
      • 1: Regular
      • 2: Camarilla
      • 3: Woodie
      • 4: Fibonacci

Buffers

  • Buffer 0: PP Line values (Pivot Point).
  • Buffer 1: R1 Line values (First Resistance).
  • Buffer 2: R2 Line values (Second Resistance).
  • Buffer 3: R3 Line values (Third Resistance).
  • Buffer 4: R4 Line values (Fourth Resistance).
  • Buffer 5: S1 Line values (First Support).
  • Buffer 6: S2 Line values (Second Support).
  • Buffer 7: S3 Line values (Third Support).
  • Buffer 8: S4 Line values (Fourth Support).

Associated Functions:

  • PL(int shift, int buffer, int lsr, int mask)

PP1 - Pivot Points Indicator

File: \Indicators\NTL\PP.ex5
Description: Analyses pivot points and their associated bar strength for multiple orders, providing insights into key price levels and market dynamics.

Creation String

NTL\Indicators\PP([parameters,]).ex5

Default Setting:

NTL\PP(1).ex5,0,1,2,3,4,5

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Highest Order
    • Specifies the highest pivot order to analyse.
    • Default: 6.

Buffers

  • Buffer 0: BarStrength values A high pivot value is a bar's high price and a low pivot value is a bar's low price. The pivot strength is the number of bars to its left that are have a lower high than the pivot bar, for a high pivot, or have a higher low than the pivot bar, for a low pivot. Buffer 0 holds the pivot strength for both high pivot bars (bits 0-23) and low pivot bars (bits 24-47).
    • Bits 0-23: High bar strength values.
    • Bits 24-47: Low bar strength values.
  • Buffer 1: Pivot Order 1 shift values Buffer 1 holds the bar shift offset from the current bar to the nearest pivot order 1 bar.
    • Bits 0-23: High pivot shift values.
    • Bits 24-47: Low pivot shift values.
  • Buffer 2: Pivot Order 2 shift offsets
    Buffer 2 holds the bar shift offset from the current bar to the nearest pivot order 2 bar.
    • Bits 0-23: High pivot shift values.
    • Bits 24-47: Low pivot shift values.
  • Buffer 3: Pivot Order 3 shift offsets
    Buffer 3 holds the bar shift offset from the current bar to the nearest pivot order 3 bar.
    • Bits 0-23: High pivot shift values.
    • Bits 24-47: Low pivot shift values.
  • Buffer 4: Pivot Order 4 shift offsets
    Buffer 4 holds the bar shift offset from the current bar to the nearest pivot order 4 bar.
    • Bits 0-23: High pivot shift values.
    • Bits 24-47: Low pivot shift values.
  • Buffer 5: Pivot Order 5 shift offsets
    Buffer 5 holds the bar shift offset from the current bar to the nearest pivot order 5 bar.
    • Bits 0-23: High pivot shift values.
    • Bits 24-47: Low pivot shift values.
  • Buffer 6: Pivot Order 6 shift offsets
    Buffer 6 holds the bar shift offset from the current bar to the nearest pivot order 6 bar.
    • Bits 0-23: High pivot shift values.
    • Bits 24-47: Low pivot shift values.

Example To read the high price of the nearest high pivot bar of order 2 use: High(PP1(1,2,0,0xFFFFFF)+1) +1 is necessary because PP1 returns the number of bars from shift offset 1, and High() is expecting an offset starting from the latest closed bar, 1. 0xFFFFFF is used to mask the lower 24 bits. To read the low price of the nearest low pivot bar of order 2 use: Low(PP1(1,2,24,0xFFFFFF)+1) 24 is used as the bit shift value to move bits 24-47 into bits 0-23. To read the high price of the nearest high pivot bar of order 3 use: High(PP1(1,3,0,0xFFFFFF)+1) To read the low price of the nearest low pivot bar of order 3 use: Low(PP1(1,3,24,0xFFFFFF)+1)

Associated Functions:

  • PP1(int shift, int buffer, int lsr, int mask)

Notes: See Terms for an explanation of Pivot Strength and Pivot Order.

PSAR1 - Parabolic Stop And Reverse Indicator

File: \Indicators\NTL\PSAR.ex5
Description: Calculates the Parabolic Stop and Reverse (PSAR) indicator, commonly used to identify trends and potential reversal points. Useful for setting stop-loss levels and identifying entry/exit signals.

Creation String

NTL\PSAR([parameters,]).ex5

Default Setting:

NTL\PSAR(1,0.02,0.2).ex5,0,1

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Step
    • The acceleration factor used in the PSAR calculation.
    • Default: 0.02.
  • Parameter 2: Maximum
    • The maximum acceleration factor to cap the PSAR adjustment.
    • Default: 0.2.

Buffers

  • Buffer 0: PSAR values (Stop and Reverse points).
  • Buffer 1: SignalFlag values (Trend, Signal).

SignalFlag Logic

Trend Determination:

  • If Low Price > PSAR, then Trend = Bullish.
  • If High Price < PSAR, then Trend = Bearish.

Signal Determination:

  • If Trend = Bullish and Previous High < Previous PSAR, then Signal = Bullish.
  • If Trend = Bearish and Previous Low > Previous PSAR, then Signal = Bearish.

Associated Functions:

  • PSAR1(int shift, int buffer, int lsr, int mask)
  • Signal('PSAR1')
  • Trend('PSAR1')

RSI1 - Relative Strength Indicator

File: \Indicators\NTL\RSI.ex5
Description: Calculates the Relative Strength Index (RSI), a momentum oscillator that measures the speed and change of price movements. Useful for identifying overbought and oversold conditions in the market.

Creation String

NTL\RSI([parameters,]).ex5

Default Setting:

NTL\RSI(1,14,1,70,30).ex5,0,1

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The number of bars used for RSI calculation.
    • Default: 14.
  • Parameter 2: AppliedPrice
    • The price used for RSI calculations.
    • Default: PRICE_CLOSE (1).
  • Parameter 3: OverboughtLevel
    • The RSI level above which the market is considered overbought.
    • Default: 70.
  • Parameter 4: OversoldLevel
    • The RSI level below which the market is considered oversold.
    • Default: 30.

Buffers

  • Buffer 0: RSI values.
  • Buffer 1: SignalFlag values (Overbought, Oversold).

SignalFlag Logic

Overbought/Oversold Determination:

  • If RSI >= OverboughtLevel, then OBOS = Overbought.
  • If RSI <= OversoldLevel, then OBOS = Oversold.
  • Otherwise, OBOS = 0.

Associated Functions:

  • RSI1(int shift, int buffer, int lsr, int mask)
  • OBOS('RSI1')

Scalper1 - Scalper Indicator

File: \Indicators\NTL\Scalper.ex5
Description: Analyses tick-level market microstructure to detect short-term trading opportunities. Uses five core components (tick density, velocity, acceleration, direction, and MA deviation) to identify potential breakouts, reversals, and momentum shifts in real time.

Creation String

NTL\Scalper([parameters,]).ex5

Default Setting:

NTL\Scalper(1,10000,0.7,10000,0.3,0.6,10000,0.5,0.3,10000,0.7,10,1,5,0.0,5000,1,1,1,26).ex5,0,1,2,3,4,5,6

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Tick Density Window in Ms
    • Time window used to count ticks, in milliseconds.
    • Default: 10000.
  • Parameter 2: Tick Density Signal Threshold
    • Normalised value (0-1) determining market activity threshold.
    • Default: 0.7.
  • Parameter 3: Tick Velocity Window in Ms
    • Time window for measuring price movement speed.
    • Default: 10000.
  • Parameter 4: Tick Velocity Smoothing
    • Exponential smoothing factor for velocity calculations.
    • Default: 0.3.
  • Parameter 5: Tick Velocity Signal Threshold
    • Minimum normalised velocity to activate the condition.
    • Default: 0.6.
  • Parameter 6: Tick Acceleration Window in Ms
    • Time window for measuring velocity changes.
    • Default: 10000.
  • Parameter 7: Tick Acceleration Smoothing
    • Smoothing factor for acceleration calculations.
    • Default: 0.5.
  • Parameter 8: Tick Acceleration Signal Threshold
    • Minimum normalised acceleration to activate the condition.
    • Default: 0.3.
  • Parameter 9: Tick Direction Window in Ms
    • Time window for measuring directional bias of ticks.
    • Default: 10000.
  • Parameter 10: Tick Direction Signal Threshold
    • Minimum directional consensus to activate the condition.
    • Default: 0.7.
  • Parameter 11: Tick MA Period
    • Number of ticks used in the moving average calculation.
    • Default: 10.
  • Parameter 12: Tick MA Method
    • Method used for the tick-based moving average.
    • Default: 1 (EMA).
    • Options:
      • 0: Simple Moving Average (SMA)
      • 1: Exponential Moving Average (EMA)
      • 2: Weighted Moving Average (WMA)
      • 3: Hull Moving Average (HMA)
  • Parameter 13: MA Deviation Threshold in Points
    • Minimum distance from MA in points to activate the condition.
    • Default: 5.
  • Parameter 14: Min ABH Value for Signals
    • Minimum Average Bar Height required for signals.
    • Default: 0.0 (no filter).
  • Parameter 15: Min Time Between Signals in Ms
    • Minimum time between consecutive signals in milliseconds.
    • Default: 5000.
  • Parameter 16: Generate Bullish Signals
    • Enables or disables buy signals.
    • Default: 1 (enabled).
  • Parameter 17: Generate Bearish Signals
    • Enables or disables sell signals.
    • Default: 1 (enabled).
  • Parameter 18: Required Conditions
    • Bitmap defining which metrics must all be active for a valid signal.
    • Default: 1 (Density only).
    • Bit definitions:
      • Bit 0 (1): Density
      • Bit 1 (2): Velocity
      • Bit 2 (4): Acceleration
      • Bit 3 (8): Direction
      • Bit 4 (16): MA
  • Parameter 19: Direction Conditions
    • Bitmap defining which active metrics vote on signal direction.
    • Default: 26 (Velocity, Direction, and MA).

Buffers

  • Buffer 0: Tick Density values (normalized 0-1).
  • Buffer 1: Tick Velocity values (normalized -1 to +1).
  • Buffer 2: Tick Acceleration values (normalized -1 to +1).
  • Buffer 3: Tick MA values.
  • Buffer 4-6: Signal Flag buffers (encoded signal data).
    • Each buffer stores two 26-bit signals:
      • Bit 0: First Signal direction (0 = Bearish, 1 = Bullish)
      • Bits 1-25: Millisecond offset from bar open time
      • Bit 26: Second Signal direction (0 = Bearish, 1 = Bullish)
      • Bits 27-51: Millisecond offset from bar open time

SignalFlag Logic

Signal Determination:

  • If all metrics specified in Required Conditions are active:
    • A "majority vote" from metrics specified in Direction Conditions determines signal direction (bullish/bearish).
    • Only signals for enabled directions (bullish/bearish) are generated.
    • Signal will only fire if the time since the last signal exceeds Min Time Between Signals in Ms.
    • Signal will only fire if the current ABH exceeds Min ABH Value for Signals.

Associated Functions:

  • Scalper1(int shift, int buffer, int lsr, int mask)
  • Signal('Scalper1')

Stochastic1 - Stochastic Oscillator Indicator

File: \Indicators\NTL\Stochastic.ex5
Description: Calculates the Stochastic Oscillator, a momentum indicator that compares a particular closing price to a range of prices over a specific period. Useful for identifying overbought and oversold conditions and potential trend reversals.

Creation String

NTL\Stoch([parameters,]).ex5

Default Setting:

NTL\Stochastic(1,5,3,3,80,20).ex5,0,1,2

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: KPeriod
    • The number of bars used for calculating the %K line.
    • Default: 5.
  • Parameter 2: DPeriod
    • The smoothing period for calculating the %D line.
    • Default: 3.
  • Parameter 3: Slowing
    • The slowing factor applied to the %K line.
    • Default: 3.
  • Parameter 4: OverboughtLevel
    • The Stochastic level above which the market is considered overbought.
    • Default: 80.
  • Parameter 5: OversoldLevel
    • The Stochastic level below which the market is considered oversold.
    • Default: 20.

Buffers

  • Buffer 0: Stochastic values (%K line).
  • Buffer 1: Signal values (%D line).
  • Buffer 2: SignalFlag values (Trend, Overbought/Oversold).

SignalFlag Logic

Overbought/Oversold Determination:

  • If Stochastic >= OverboughtLevel, then OBOS = Overbought.
  • If Stochastic <= OversoldLevel, then OBOS = Oversold.
  • Otherwise, OBOS = 0.

Associated Functions:

  • Stoch1(int shift, int buffer, int lsr, int mask)
  • OBOS('Stoch1')
  • Trend('Stoch1')

ST1 - Super Trend Indicator

File: \Indicators\NTL\ST.ex5
Description: Calculates the Super Trend, a trend-following indicator that helps identify bullish or bearish market trends. Useful for confirming entry and exit points.

Creation String

NTL\ST([parameters,]).ex5

Default Setting:

NTL\ST(1,13,1.5).ex5,0,1

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Period
    • The period used for calculating the Super Trend.
    • Default: 13.
  • Parameter 2: Multiplier
    • The multiplier applied to the Average True Range (ATR) for calculating trend lines.
    • Default: 1.5.

Buffers

  • Buffer 0: SuperTrend values.
  • Buffer 1: SignalFlag values (Trend, Signal).

SignalFlag Logic

Trend Determination:

  • Trend is directly read from the internal SuperTrend trend buffer (_trendBuffer).
    Signal Determination:
  • If Trend = Bullish and PreviousTrend = Bearish, then Signal = Bullish.
  • If Trend = Bearish and PreviousTrend = Bullish, then Signal = Bearish.
  • Otherwise, Signal = None.

Associated Functions:

  • ST1(int shift, int buffer, int lsr, int mask)
  • Signal('ST1')
  • Trend('ST1')

SwingMap1 - Swing Map Indicator

File: \Indicators\NTL\SwingMap.ex5 Description: Labels market structure swing points as Higher Highs (HH), Higher Lows (HL), Lower Highs (LH) and Lower Lows (LL) using pivot order detection with enforced high-low alternation. Measures swing significance via Average Bar Height (ABH) for dynamic height filtering. Detects when price sweeps through a structure level and tracks sweep propagation via SweptAge and SweptPrice buffers. Determines confirmed trend direction—bullish requires both a HH and HL to have formed; bearish requires both a LH and LL. Fires signals on swing formation events and exports structure events as GroundedEvents for AI consumption.

Creation String

NTL\SwingMap([parameters,]).ex5

Default Setting:

NTL\SwingMap(1,0,2,6,800,0,0,14,0.0).ex5,0,1,2,3,4,5,6,7,8

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: Timeframe
    • Chart timeframe for calculations (eSeriesTimeframe enum). 0 = current chart timeframe.
    • Default: 0.
  • Parameter 2: MinPivotOrder
    • Minimum pivot order (bars on each side) required to qualify a bar as a swing pivot. Higher values produce fewer, more significant pivots.
    • Default: 2.
  • Parameter 3: MaxPivotOrder
    • Maximum pivot order filter. Pivots with an order exceeding this value are rejected. Also passed to the underlying PivotPoints indicator as its highest order. Set to 0 for unlimited.
    • Default: 6.
  • Parameter 4: MaxLookback
    • Maximum number of bars to search backward when detecting swing pivots.
    • Default: 800.
  • Parameter 5: MinHeightInABH
    • Minimum swing height (distance between consecutive high and low pivots) as a multiple of Average Bar Height. Filters out minor pivots that do not represent meaningful moves. Set to 0 to disable.
    • Default: 0.
  • Parameter 6: MaxHeightInABH
    • Maximum swing height as a multiple of Average Bar Height. Set to 0 for unlimited.
    • Default: 0.
  • Parameter 7: ABHPeriod
    • Period used to calculate the Average Bar Height for height filtering.
    • Default: 14.
  • Parameter 8: MinStructureABH
    • Minimum distance between consecutive same-type swings (e.g. HH to HH) as a multiple of Average Bar Height. Filters micro-pivots that are too close to the previous swing of the same type. Set to 0 to disable.
    • Default: 0.0.

Buffers

  • Buffer 0: High Data (bit-packed swing high metadata for HH and LH swings).
    • Bits 0-11: Backlink (bars to previous swing high event, max 4,095).
    • Bits 12-19: SweptAge (bars since sweep, 0 = not swept, max 255).
    • Bits 20-21: SwingType (00=HH, 10=LH).
    • Bit 22: Formed (1 = swing formed on this bar).
    • Bit 23: Swept (1 = price broke above this level).
    • Bits 24-33: PivotShift (bars from formation to pivot bar, max 1,023). Formation bar only; uses future data.
    • Bit 34: Terminated (1 = swept or superseded by newer same-type swing). Formation bar only; uses future data.
    • Bits 35-42: Strength (pivot order at swing, max 255).
    • Bits 43-44: TrendType (00=undefined, 01=bullish, 10=bearish).
  • Buffer 1: Low Data (bit-packed swing low metadata for HL and LL swings).
    • Same bit layout as Buffer 0, with SwingType values 01=HL, 11=LL.
  • Buffer 2: High Price (latest active swing high pivot price, propagated forward; 0 when no active swing highs).
  • Buffer 3: Low Price (latest active swing low pivot price, propagated forward; 0 when no active swing lows).
  • Buffer 4: Swept High Price (swept swing high pivot price, propagated forward while SweptAge > 0; returns to 0 when SweptAge expires).
  • Buffer 5: Swept Low Price (swept swing low pivot price, propagated forward while SweptAge > 0; returns to 0 when SweptAge expires).
  • Buffer 6: Strength (pivot order written at actual swing bar positions, not formation bars; 0 elsewhere).
  • Buffer 7: Sequence (rolling 48-bit history of last 24 swing types as 2-bit pairs; bits 0-1 = most recent, bits 2-3 = second most recent, etc.).
  • Buffer 8: SignalFlag values (Trend, Signal).

Bar Types

Data buffers 0 and 1 contain three types of bar:

  • Formation bar (formed=1): Pattern origin. All bit fields populated including swingType, strength and trendType. PivotShift and terminated are mutated retroactively (future data—do not use in EA trading logic). Price buffer holds the pivot price.
  • Relay waypoint (formed=0): Written each bar for chain navigation. Carries backlink (bits 0-11) and, during a swept window, sweptAge (bits 12-19). All other fields are zero. Price buffer holds the newest active pivot price (or 0 if none).
  • Sweep bar (overwrites relay at current bar): Written when a fresh sweep is detected. Carries backlink + sweptAge=1 + swept=1. SweptPrice buffer receives the swept pivot price.

SignalFlag Logic

Trend Determination:

  • If both a HH and HL have formed since the last trend confirmation, then Trend = Bullish.
  • If both a LH and LL have formed since the last trend confirmation, then Trend = Bearish.
  • Otherwise, Trend retains its previous value (or None if no trend has been established).
  • Once a trend is confirmed, all four swing flags (hasHH, hasHL, hasLH, hasLL) reset—a fresh pair is required to confirm or reverse the trend.

Signal Determination:

Signals fire on the bar where a new swing is formed:

  • If a bullish swing forms (HH or HL), then Signal = Bullish.
  • If a bearish swing forms (LH or LL), then Signal = Bearish.

Note: sweep events are not exported to SignalFlags. To detect sweeps, read the Swept bit (bit 23), SweptAge (bits 12-19) or the SweptPrice buffers (4 and 5) directly.

Pattern Detection Rules

Swing High requires:

  • A bar whose high is higher than the highs of at least MinPivotOrder consecutive bars on each side.
  • Pivot order >= MinPivotOrder and <= MaxPivotOrder (if MaxPivotOrder > 0).
  • Found within MaxLookback bars of the current position.
  • Swing height from the previous swing low meets MinHeightInABH (and does not exceed MaxHeightInABH if set).
  • Distance from the previous same-type swing meets MinStructureABH (if set).
  • Strict alternation: only accepted when the previous accepted swing was a low (or no swing has been accepted yet).

Swing Low requires:

  • A bar whose low is lower than the lows of at least MinPivotOrder consecutive bars on each side.
  • Pivot order >= MinPivotOrder and <= MaxPivotOrder (if MaxPivotOrder > 0).
  • Found within MaxLookback bars of the current position.
  • Swing height from the previous swing high meets MinHeightInABH (and does not exceed MaxHeightInABH if set).
  • Distance from the previous same-type swing meets MinStructureABH (if set).
  • Strict alternation: only accepted when the previous accepted swing was a high (or no swing has been accepted yet).

Sweep Detection

A structure level is swept when price trades through the pivot price:

  • Swing High (HH/LH): Current bar high exceeds the pivot high price.
  • Swing Low (HL/LL): Current bar low falls below the pivot low price.

When swept, the formation bar's Swept and Terminated flags are set. On the current bar, SweptAge starts at 1 and increments each subsequent bar up to 255. The SweptPrice buffer propagates the swept pivot price forward for the duration of the SweptAge window.

A swing is also terminated (without being swept) when a newer same-type swing supersedes it.

Visual Representation

  • Dotted lines: Active swing levels (price has not broken through).
  • Dashed lines: Swept swing levels (price broke through the pivot).
  • Green: Bullish swings (HH, HL).
  • Red: Bearish swings (LH, LL).
  • Grey: Swept swings (regardless of type).
  • Non-terminated swings extend as a ray to the right edge of the chart. Terminated swings end near the bar where they were superseded.

Grounded Events Schema

{
  "strength": "Pivot order (bars on each side of swing)",
  "trend": "bullish, bearish, or undef"
}

Event IDs use format SM_<type>_<bars_ago> (e.g. SM_HH_014).

Examples

Read the swing type from High Data buffer at the current bar:

SwingType = SwingMap1(0, 0, 20, 3)
// 0=HH, 2=LH (high side only)

Read the swing type from Low Data buffer at the current bar:

SwingType = SwingMap1(0, 1, 20, 3)
// 1=HL, 3=LL (low side only)

Check whether a swing high formed on the current bar:

Formed = SwingMap1(0, 0, 22, 1)

Read the latest active swing high price at shift 0:

HighPrice = SwingMap1(0, 2)

Read the latest active swing low price at shift 0:

LowPrice = SwingMap1(0, 3)

Read the swept swing high price (non-zero while SweptAge > 0):

SweptHighPrice = SwingMap1(0, 4)

Read the swept swing low price (non-zero while SweptAge > 0):

SweptLowPrice = SwingMap1(0, 5)

Check whether a swing high has been swept:

Swept = SwingMap1(0, 0, 23, 1)

Read bars elapsed since sweep on high side (0 = not swept):

SweptAge = SwingMap1(0, 0, 12, 255)

Read confirmed trend at the current bar (from High Data buffer):

TrendType = SwingMap1(0, 0, 43, 3)
// 0=undefined, 1=bullish, 2=bearish

Read pivot strength at a swing bar:

Strength = SwingMap1(shift, 6)

Associated Functions:

  • SwingMap1(int shift, int buffer, int lsr, int mask)
  • Signal('SwingMap1')
  • Trend('SwingMap1')

TLines1 - Trend Lines Indicator

File: \Indicators\NTL\TLines.ex5
Description: Automatically detects and analyses trendlines based on pivot points and other customizable parameters. Useful for identifying support, resistance, and market trends across multiple timeframes.

Creation String

NTL\TLines([parameters,]).ex5

Default Setting:

NTL\TLines(1,0,'S2;R2',10,5,5,2,0.70,400,20,800,0.4,0.2,100).ex5,0,1,2,3,4,5,6

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: MinSwingInABH
    • Minimum swing size for pivot eligibility, measured as a multiple of Average Bar Height (ABH). Pivots whose swing excursion is below this threshold are rejected. Set to 0 to disable.
    • Default: 0.
  • Parameter 2: PivotString
    • Semicolon-separated pivot filter string. Each token is S or R followed by a minimum pivot order (1-8). Prefix with = for exact match. Example: S3;R3 requires both support and resistance pivots to be at least order 3.
    • Default: 'S2;R2'.
  • Parameter 3: MinBarStrength
    • Minimum bar strength (number of consecutive bars the pivot dominates as highest high or lowest low).
    • Default: 10.
  • Parameter 4: MaxBodyCrosses
    • Maximum number of candle body crosses allowed before a trendline is invalidated.
    • Default: 5.
  • Parameter 5: MinPivotGap
    • Minimum gap, in bars, between adjacent pivot points.
    • Default: 5.
  • Parameter 6: MinPivots
    • Minimum number of pivot touches required to validate a trendline. Higher values produce fewer but stronger lines.
    • Default: 2.
  • Parameter 7: MaxPivotGapRatio
    • Maximum ratio of the largest gap between consecutive pivot touches to the total trendline length. Rejects lines where pivot touches are unevenly distributed. Set to 1.0 to disable.
    • Default: 0.70.
  • Parameter 8: MaxLineLengthInBars
    • Maximum length, in bars, of a trendline.
    • Default: 400.
  • Parameter 9: MinLineLengthInBars
    • Minimum length, in bars, of a trendline.
    • Default: 20.
  • Parameter 10: MaxLineAgeInBars
    • Maximum age, in bars, of a trendline before it is removed.
    • Default: 800.
  • Parameter 11: LineToleranceInABH
    • Maximum tolerance between the trendline and pivot points, as a fraction of the Average Bar Height (ABH).
    • Default: 0.4.
  • Parameter 12: BodyToleranceInABH
    • Maximum tolerance between the trendline and the candle body, as a fraction of the ABH.
    • Default: 0.2.
  • Parameter 13: ABHPeriod
    • Period used for calculating the Average Bar Height (ABH).
    • Default: 100.

Buffers

  • Buffer 0: Resistance trendline data.
    • Bits 0-15: Shift to trendline right-side end.
    • Bits 16-31: Shift to trendline left-side end.
    • Bits 32-46: Number of bars from the right-side end before trendline termination.
    • Bit 47: Replaced flag (1 = trendline replaced by a closer, stronger line).
  • Buffer 1: Support trendline data.
    • Bits 0-15: Shift to trendline right-side end.
    • Bits 16-31: Shift to trendline left-side end.
    • Bits 32-46: Number of bars from the right-side end before trendline termination.
    • Bit 47: Replaced flag (1 = trendline replaced by a closer, stronger line).
  • Buffer 2: Trendline strength values.
    • Bits 0-15: Line strength of trendline closest to Close Price.
    • Bits 16-31: Resistance line strength.
    • Bits 32-47: Support line strength.
  • Buffer 3: Trendline price values (Price of trendline closest to Close Price).
  • Buffer 4: SignalFlag values (Trend, Signal).
  • Buffer 5: Resistance excursion data.
    • Bits 0-15: Pivot strength of the resistance trendline's start pivot.
    • Bits 16-31: Bars from pivot to maximum excursion point.
    • Bits 32-47: Maximum excursion in ABH units x 100 (divide by 100 for actual value).
  • Buffer 6: Support excursion data.
    • Bits 0-15: Pivot strength of the support trendline's start pivot.
    • Bits 16-31: Bars from pivot to maximum excursion point.
    • Bits 32-47: Maximum excursion in ABH units x 100 (divide by 100 for actual value).

SignalFlag Logic

Trend Determination:

  • Trend = Position of Close Price relative to the nearest trendline:
    • Bullish = Close Price is above the nearest trendline.
    • Bearish = Close Price is below the nearest trendline.

Signal Determination:

  • If TrendLinePrice is between Low Price and High Price:
    • If Close Price < TrendLinePrice, then Signal = Bearish.
    • If Close Price > TrendLinePrice, then Signal = Bullish.

Associated Functions:

  • TLines1(int shift, int buffer, int lsr, int mask)
  • Signal('TLines1')
  • Trend('TLines1')

TSI1 - True Strength Index Indicator

File: \Indicators\NTL\TSI.ex5
Description: Measures trend direction and momentum using the True Strength Index (TSI). Useful for identifying overbought and oversold conditions and generating trend and reversal signals.

Creation String

NTL\TSI([parameters,]).ex5

Default Setting:

NTL\TSI(1,13,21,8,25,-25,1).ex5,0,1,2

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: FastPeriod
    • The number of bars for the fast smoothing period.
    • Default: 13.
  • Parameter 2: SlowPeriod
    • The number of bars for the slow smoothing period.
    • Default: 21.
  • Parameter 3: SignalPeriod
    • The number of bars for calculating the signal line.
    • Default: 8.
  • Parameter 4: OverboughtLevel
    • The TSI level above which the market is considered overbought.
    • Default: 25.
  • Parameter 5: OversoldLevel
    • The TSI level below which the market is considered oversold.
    • Default: -25.
  • Parameter 6: SignalLogicMethod
    • Specifies the logic used for generating signals.
    • Default: 1.
    • Options:
      • 0: Zero Line Cross
      • 1: Signal Line Cross

Buffers

  • Buffer 0: TSI values.
  • Buffer 1: Signal values.
  • Buffer 2: SignalFlag values (Trend, Signal, Overbought/Oversold).

SignalFlag Logic

Trend Determination:

  • If TSI > 0, then Trend = Bullish.
  • If TSI < 0, then Trend = Bearish.
    Overbought/Oversold Determination:
  • If Trend = Bullish and TSI >= OverboughtLevel, then OBOS = Overbought.
  • If Trend = Bearish and TSI <= OversoldLevel, then OBOS = Oversold.

Signal Determination:

  • If SignalLogicMethod = 0 (Zero Line Cross):
    • If Trend = Bullish and PreviousTrend = Bearish, then Signal = Bullish.
    • If Trend = Bearish and PreviousTrend = Bullish, then Signal = Bearish.
  • If SignalLogicMethod = 1 (Signal Line Cross):
    • If TSI > Signal and PreviousTSI < PreviousSignal, then Signal = Bullish.
    • If TSI < Signal and PreviousTSI > PreviousSignal, then Signal = Bearish.

Associated Functions:

  • TSI1(int shift, int buffer, int lsr, int mask)
  • Signal('TSI1')
  • Trend('TSI1')
  • OBOS('TSI1')

9. Reading Indicator Buffer Data

Each indicator listed above has its own script function to read the data from one of its buffers at the specified shift offset from the latest bar in a price history series.

Function Syntax

Indicator(shift,buffer,lsr,mask)

Parameter Definitions

  • Indicator: The name of the indicator (e.g., ABH1, ADX1). Indicators are given numbers starting from 1, e.g. ABH1, MACD1, etc. If a second indicator of the same type is added to the indicator list, it is given the next integer number, e.g. ABH2, MACD2, etc. So, a strategy that uses 2 MA's would have names MA1 and MA2.
  • shift: The bar shift offset from the latest bar.
    • 0: Latest bar (unfinished).
    • 1: Latest closed bar (finished).
    • 2: Two bars ago, and so on.
  • buffer: The number of the buffer to read data from.
    • Refer to the indicator's buffer list for valid buffer numbers.
  • lsr: Number of bits to shift the buffer data before returning the result.
    • Default: 0 (no rotation).
  • mask: Bit mask to apply (via AND operation) after rotating the buffer data.
    • Example: 0xFFFF masks the lower 16 bits.

Example Usage

  1. ABH1(1,2)
    Returns the average upper wick height (buffer 2) of the latest closed bar (shift 1).

  2. JCP1(1,0,0,0xFFFF)
    Returns the Japanese Candle Pattern Type (lower 16 bits of buffer 0) at the latest closed bar (shift 1).

  3. JCP1(1,0,16,0xF)
    Returns the Japanese Candle Pattern Width In Bars (bits 16-19 of buffer 0) at the latest closed bar (shift 1).

Tips for Using lsr and mask

  • lsr: Use to align specific bits of interest to the least significant position.
    • Example: Shift bits 16-19 to positions 0-3 for easier access.
  • mask: Apply to isolate specific bits of interest.
    • Example: Use 0xF to capture only the lowest 4 bits.

Combining Signal Flags

For indicators that support SignalFlags, consider using built-in functions like Signal(), Trend(), and OBOS() for convenience. Example:

Signal('MA1') == Bullish ? Ask() : 0

Using Signal and Trend Functions

  1. Signal(): Automatically retrieves the SignalFlag from the appropriate buffer for the specified indicator. Example:

    Long Entry Script: Signal('MA1') == Bullish ? Ask() : 0

    Retrieves the SignalFlag value from MA1’s buffer and executes a buy trade if the flag is Bullish.

  2. Trend(): Retrieves the TrendFlag from the appropriate buffer. Example:

    Trend('MA1') == Bullish ? Ask() : 0
    

    Checks if the moving average trend is bullish before placing a trade.

Combining Signal and Trend

Leverage both SignalFlag and TrendFlag for more robust strategies:

Long Entry Script: Trend('MA1') == Bullish && Signal('RSI1') == Bullish ? Ask() : 0

This script ensures both the Moving Average and RSI indicators confirm a bullish trend before entering a trade.

Indicator List The Indicator List box lists both the custom indicators and chart indicators for the current profile, that the EA can have access to. The list is refreshed when: the EA is first loaded; when a profile is loaded; or when the symbol or timeframe of the chart is changed. The EA assigns unique names to each indicator, so that two of the same indicator, with different settings, can be used, e.g. MA1, MA2

To conserve resources the EA connects with only the indicators that have been enabled for use by ticking the check box alongside the indicator's name. Enabled indicators have a "+" as the first character of their creation string.

To use an indicator in a script, or to include its data (grounded events or raw buffer values) in AI requests, you must first enable the indicator in the Indicator List.

10. Indicator Creation Strings

Indicator Creation Strings define how an indicator is configured and instantiated in EAsiTrader. They specify the indicator file, parameters, including optional symbol and timeframe settings, and the indicator's buffer numbers that data can be read from. This allows traders to integrate custom indicators dynamically into their strategies.

Format

The standard format for an indicator creation string is as follows:

[Folder\]{Indicator}([Symbol:Timeframe,]EA_Flag[,args...]).ex5[,buffers]

The format is structured as follows:

  • [Folder]: (Optional) Specifies the folder containing the indicator file.
  • {Indicator}: The name of the indicator file without the .ex5 extension.
  • ([Symbol:Timeframe,]...): Both Symbol and Timeframe are optional.
    • Symbol:Timeframe specifies both a custom symbol and timeframe.
    • :Timeframe uses the current symbol but overrides the timeframe.
    • Symbol: uses the specified symbol but keeps the current timeframe.
    • If omitted entirely, both the current symbol and timeframe are used.
  • EA_Flag: A boolean value (1 or 0) indicating the indicator was created by an EA. Use 1 when creating an NTL indicator.
  • [,args...]: (Optional) Additional arguments specific to the indicator.
  • [,buffers] comma separated list of buffer numbers, e.g. 0,1,2 or 0,4. etc. these list the indicator's buffer numbers that scripts will need access to. If a script tries to read data from buffer 4, then 4 must be in the list. Note that the Signal and Trend functions read data from the indicator's signal buffer, so the signal buffer number must be included in the list if you intend using these functions. By default, the signal buffer number is included in the indicator's creation string.

Note: In an EAsiTrader preset file, indicator creation string settings that are prefixed with "+" indicate that the indicator is enabled and can be used in a script and/or exported to the AI. In the GUI, enabling an indicator automatically adds the "+" to its creation string. Indicators that are not enabled will not contribute grounded events or raw buffer data to AI requests, even if AI Mode is active.

Examples

These examples demonstrate how to dynamically configure indicators for different symbols, timeframes, and strategies.

  1. Moving Average (MA1) for the Primary Market: NTL\MA(1,14,0).ex5

    • EA Flag: 1 (true).
    • Period: 14 (Moving Average period).
    • Mode: 0 (Simple Moving Average).
  2. Moving Average (MA1) for GBPUSD on H1 Timeframe: NTL\MA(GBPUSD:H1,1,20,1).ex5

    • Symbol: GBPUSD.
    • Timeframe: H1.
    • EA Flag: 1 (true).
    • Period: 20 (Moving Average period).
    • Mode: 1 (Exponential Moving Average).
  3. Relative Strength Index (RSI1) for EURUSD on M5 Timeframe: NTL\RSI(EURUSD:M5,1,14).ex5

    • Symbol: EURUSD.
    • Timeframe: M5.
    • EA Flag: 1 (true).
    • Period: 14 (RSI period).
  4. Bollinger Bands (BB1) for USDJPY on D1 Timeframe: NTL\BB(USDJPY:D1,1,20,2.0).ex5

    • Symbol: USDJPY.
    • Timeframe: D1.
    • EA Flag: 1 (true).
    • Period: 20 (Bollinger Bands period).
    • Deviation: 2.0.
  5. Moving Average (MA1) for the Primary Market on H1 Timeframe: NTL\MA(:H1,1,14,0).ex5

    • Timeframe: H1.
    • EA Flag: 1 (true).
    • Period: 14 (Moving Average period).
    • Mode: 0 (Simple Moving Average).

Notes

  1. Symbol and Timeframe:
  • Both components are optional and can be combined or omitted as needed.
  • Default behavior ensures seamless integration with the primary market.
  1. Dynamic Parameters:
  • User-defined variables like VAR0 can replace fixed parameters to allow dynamic optimization during testing.
  • Example: NTL\MA(EURUSD:M5,1,VAR0,1).ex5
  1. No Quotes or Spaces:
  • Do not use quotes around symbols or timeframes.
  • Spaces after commas are not required.

11. Reading Indicator Signal Flags

Indicators that support SignalFlags provide built-in functions for accessing signal data from the indicator's SignalFlags data buffer:

Direction Functions

  • Signal(indicator, shift=1): Returns the last signal direction. -1=bearish, 0=no signal, 1=bullish. Direction persists on non-signal bars.
  • Trend(indicator, shift=1): Returns the last trend direction. -1=bearish, 0=no trend, 1=bullish. Direction persists on non-trend bars.
  • OBOS(indicator, shift=1): Returns the overbought/oversold state. -1=overbought, 0=neutral, 1=oversold.

Bars-Since Functions

  • SignalBull(indicator, shift=1): Returns bars since last bullish signal. 0=no signal, 1=signal on this bar, N=signal N-1 bars ago.
  • SignalBear(indicator, shift=1): Returns bars since last bearish signal. 0=no signal, 1=signal on this bar, N=signal N-1 bars ago.
  • TrendBull(indicator, shift=1): Returns bars since bullish trend started. 0=not bullish, 1=trend started on this bar, N=trend started N-1 bars ago.
  • TrendBear(indicator, shift=1): Returns bars since bearish trend started. 0=not bearish, 1=trend started on this bar, N=trend started N-1 bars ago.

The direction functions offer a convenient way to check the current state. The bars-since functions are useful for trigger gating, e.g., only calling AI when a structural event occurred within the last N bars. Alternatively, the same SignalFlag bits can be accessed manually by reading from the indicator's SignalFlags data buffer using the indicator's function, as described in Reading Indicator Buffer Data.

Signal Flags Data Buffer

The Signal Flags data buffer, available in indicators that support it, provides critical trading information to EAsiScript via one of the indicator's buffers, typically the last one (the highest indexed buffer). Traders can combine signals from multiple indicators to form their trading strategies.

The signal data in the buffer corresponds to the time of the opening bar for its respective shift offset. For example, signal data at shift offset 1 in the indicator's Signal Flags data buffer provides signals at the time of the opening of the latest closed bar. A shift value of 0 relates to the latest unfinished bar. Refer to Terms->Shift for additional details.

SignalFlags Bits

  • Bits 0-11 (0xFFF): Trend Bar Offset

    • Number of bars since the last Trend direction change.
    • 0: Trend change occurred on the latest bar.
    • 1: Trend change occurred 1 bar ago, and so on.
  • Bits 12-23 (0xFFF): Bullish Signal Bar Offset

    • Number of bars since the last Bullish Signal fired.
    • 0: Bullish signal occurred on the latest bar.
    • 1: Bullish signal occurred 1 bar ago, and so on.
    • 4095 (0xFFF): No bullish signal has ever fired (sentinel value).
    • Bullish and bearish signal offsets are tracked independently.
  • Bits 24-35 (0xFFF): Bearish Signal Bar Offset

    • Number of bars since the last Bearish Signal fired.
    • 0: Bearish signal occurred on the latest bar.
    • 1: Bearish signal occurred 1 bar ago, and so on.
    • 4095 (0xFFF): No bearish signal has ever fired (sentinel value).
  • Bits 36-42 (0x7F): SignalFlag Bits

    • Bit 36: 1 = Bearish Trend
    • Bit 37: 1 = Bullish Trend
    • Bit 38: 1 = Bearish Signal
    • Bit 39: 1 = Bullish Signal
    • Bit 40: 1 = Overbought
    • Bit 41: 1 = Oversold
    • Bit 42: Unused
    • Note: Trend and signal direction bits persist on non-event bars. For discrete indicators (ChoCh, FVG, LP), Signal() and Trend() return the last known direction even on bars where no event fired.
  • Bits 43-47 (0x15): Signal Data ID

    • A fixed value (0x15) identifying the Signal Data format.
  • Bits 48-49:

    • The least significant two bits of the current bar's open time in minutes.
    • Used for time synchronization between the indicator and the EA.

12. Adding A Custom Indicator

To use your own indicators in EAsiTrader scripts follow these instructions:

  1. Copy your indicator to the *MQL\Indicators* folder.
  2. Restart your Terminal and load EAsiTrader.
  3. In the EA, go to Settings->EAsiScript->Indicators.
  4. Click the Add button below the Indicator's List.
  5. Enter the indicators name and parameters, e.g. MyInd(14).ex5.
  6. Enter the numbers of the buffers you want to use in your scripts, e.g. 0,1.
  7. Click the OK button.

The indicator's name, in this case MyInd1, will now appear at the end of the indicator's List. You can now use your indicator in your scripts. For example, MyInd1(1, 0) would return the data at shift offset 1, the latest closed bar, in buffer 0.

13. Execution Context

Clock

During Live Trading the EA internal clock is set to the value of the terminal's TimeTradeServer.

Live Trading

This applies during live trading, when scripts are executed on live price data, i.e. as a result of the EA's OnTick event when new tick prices are received.

14. Simulated Trading

When running the Tester or during a scheduled optimisation the EA simulates the process of live trading as closely as possible using the bid and ask values from the price series' raw tick data. Each tick price is time stamped so the exact time of the price update, subject to the broker's infrastructure and the network latency, is known.

As the Tester runs, it processes each tick price one at a time within the specified date range. As it does so, it sets its own internal clock to the timestamp of the tick price.

This applies during tester trading, when scripts are executed on historical price data, i.e. as a result of running Tester, or during a scheduled optimisation.

15. Learn EAsiScript

See the Learn EAsiScript User Guide.

Visit the EAsiScript Presets for examples you can download and use in EAsiTrader.

16. Terms

This section defines key concepts and terms used in EAsiTrader to ensure a clear understanding of its features and functionality.

Bar Strength

The strength of a bar is determined by counting the number of preceding bars (to its immediate left) that have a higher low (for low bar strength) or a lower high (for high bar strength). The count stops when the first bar with a higher low (for low bar strength) or a lower high (for high bar strength) is encountered.

Pivot Order

Ordering pivots ranks price highs and lows based on their significance. The higher the order, the more significant the price compared to lower-ordered pivots.

  • a 0 order high pivot is a bar without a lower high bar on its immediate left (older) and right (newer).
  • a 0 order low pivot is a bar without a higher low bar on its immediate left (older) and right (newer).
  • a 1 order high pivot is a bar with a lower high bar on its immediate left and right.
  • a 1 order low pivot is a bar with a higher low bar on its immediate left and right.
  • a 2 order high pivot is a bar with a 1 order high pivot on its left and right.
  • a 2 order low pivot is a bar with a 1 order low pivot on its left and right.
  • a 3 order pivot has a 2 order pivot on its left and right.
  • a 4 order pivot has a 3 order pivot on its left and right, and so on.

Shift

The offset in bars from the latest bar. A shift value of zero means the latest bar, or latest unfinished bar. The EA always considers the latest bar to be unfinished (regardless of whether it is or not), i.e. only the open price is unchanging, unlike the high, low and close prices which can change. A shift value of one means the bar before the latest bar, i.e. the latest finished bar, where the open, high, low and close prices will not change. All functions, except Open(), Time(), Hour() and Minute() are blocked from accessing the latest bar, i.e. using a shift offset of 0. If 0 is used as a shift offset it is changed to one. The largest shift value is equal to the current total number of bars in the price series minus one.

ABH

Average Bar Height. The ABH values are read from the ABH indicator. The Period of the ABH is determined by the indicator.

Rev:17.03.2026 12:00