EAsiScript 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. 14 Essential Scripts:
    • EAsiScript supports 14 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 50 built-in functions to handle data retrieval, calculations, and trade execution seamlessly.
  3. Indicator Support:
    • Utilize 22 built-in indicators, including 8 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:

  1. Short Entry Script (InpTradeTool_ScriptShortEntry)
  2. Short Initial Stop Script (InpTradeTool_ScriptShortInitialStop)
  3. Short Trailing Stop Script (InpTradeTool_ScriptShortTrailingStop)
  4. Short Lots Script (InpTradeTool_ScriptShortLots)
  5. Short Take Profit Script (InpTradeTool_ScriptShortTakeProfit)
  6. Short Breakeven Script (InpTradeTool_ScriptShortBreakeven)
  7. Short Exit Script (InpTradeTool_ScriptShortExit)

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.

  • If the result of the Long Initial SL script is less than the entry price returned by the Long Entry script or the result of the Short Initial SL script is greater than the entry price returned by the Short Entry script then the result is used as the SL for the new position.

  • If 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 or the result of the Short Initial SL script is less than or equal to the entry price returned by the Short Entry script then no action is taken.

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 **

  • If the result of the Long Trailing SL script is less than the current bid price for long positions or the result of the Short Trailing SL is greater than the current ask price for short positions AND the difference between the old and new SL is greater than or equal to the Settings -> Stops -> Min Stop Move setting, then the position’s SL price is updated.

  • If the result of the Long Trailing SL script is zero or greater than or equal to the current bid price for long positions or the result of the Short Trailing SL script is zero or less than or equal to the current ask price for the short positions OR the difference between the current SL and new SL is less than the Settings -> Stops -> Min Stop Move setting, then the position’s SL is not changed.

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.

  • If the result of the Long TP script is greater than or equal to the entry price returned by the Long Entry script for long positions or if the result of the Short TP script is less than or equal to the entry price returned by the Short Entry script for short positions then the result is used as the TP when the position is opened.

  • If the result of the Long TP script is less than the current bid price for long positions opened with the Long Entry script or if the result of the Short TP script is greater than the ask price for short positions opened with the Short Entry script then no action is taken.

Scripts -> Long BE Script, Short BE Script

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

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 Breakeven value for the position. Use the Long BE script to set the Breakeven value of a long position opened with the Long Entry script and use the Short BE script to set the Breakeven value 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 -> 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 Entry 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.

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.

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().

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. 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.

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.

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

Function Description
Abs(double x) Returns absolute value (modulus) of x.
Ask(double offset=0,string symbol = _Symbol) Returns the ask price for 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).
BE(int position) Returns the Breakeven price for a position, or the current position if position is not specified.
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.
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.
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).
Bars(string indicator) Returns the number of bars available for indicator.
Bars(string symbol, enum timeframe) Returns the number bars in the price series for symbol and timeframe.
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).
Bid(double offset=0,string symbol=_Symbol) Returns the bid price for 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).
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).
Ceil(double x) Returns integer numeric value closest from above x.
Close(int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the close price of a bar at offset shift for symbol and timeframe.
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.
DayBars() Returns the number of bars since the start of the current day.
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.
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.
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.
Floor(double x) Returns integer numeric value closest from below x.
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.
HH(int bars=0, int shift=1, int mode=0,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.
High(int shift=0, string symbol=_Symbol, enum timeframe=_Period) Returns the high price of the bar at offset shift for symbol and timeframe.
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.
HighD(int shift=0, string symbol=_Symbol) Returns the daily high price for the bar at offset shift and symbol.
Hour() Returns the hour (0-23) of the opening time of the latest bar for the current symbol.
Low(int bar = 0, string symbol = _Symbol, ENUM_TIMEFRAMES timeframe = _Period) Returns the low price for symbol and timeframe at offset bar.
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.
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 bar. The count stops when the first bar with a lower low is encountered.
LL(int bars=0, int shift=1, int mode=0, 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.
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.
Low(int shift=0, string symbol=_Symbol, enum timeframe=_Period) Returns the low price of the bar at offset shift for symbol and timeframe.
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.
LowD(int shift=0, string symbol=_Symbol) Returns the daily low price for the bar at offset shift and symbol.
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.
Max(double x, double y) Returns the maximum value of x and y.
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.
Min(double x, double y) Returns the minimum value of x and y.
Mid(string symbol=_Symbol) Returns the mid price for symbol. The mid price is (bid + ask) * 0.5.
Minute() Returns the minute (0-59) of the opening time of the latest bar for the current symbol.
Mod(double x, double y) Returns the real remainder after the division of x and y.
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.
Open(int shift=0, string symbol=_Symbol, enum timeframe=_Period) Returns the open price of the bar at offset shift for symbol and timeframe.
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.
Rand() Returns a pseudorandom value within the range of 0 to 32767.
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.
Round(double x) Returns x rounded to the nearest integer.
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.
Signal(string indicator, int shift=1) For indicators that support SignalFlags, this function returns the buy/sell signal flag of the bar at offset shift for indicator. 0=no signal, 1=bullish signal, -1=bearish signal.
Spread(int shift=1, string symbol=_Symbol, enum timeframe=_Period) Returns the spread of the bar at offset shift for symbol and timeframe.
Sqrt(double x) Returns the square root of x.
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.
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.
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.
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.
Trend(string indicator, int shift=1) For indicators that support SignalFlags, this function returns the trend signal flag for indicator at bar offset shift. 0=no trend, 1=bullish trend, -1=bearish trend.
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.
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.

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 16 widely used indicators and 5 NTL custom 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.

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 ror, 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 ror, 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 ror, 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 ror, 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. Fully customizable for a wide range of trading strategies.

Creation String

NTL\AutoFib([parameters,]).ex5

Default Setting:

NTL\AutoFib(1,'','0.0,0.236,0.382,0.5,0.618,0.762,1.0',10,0,4,50,0,0,1.2,20,250,150,'0.618,0.762',0,0).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.236,0.382,0.5,0.618,0.762,1.0'.
  • Parameter 3: MinFibWidthInBars
    • Minimum width of the pattern in bars.
    • Default: 10.
  • 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).
    • Default: 4.
  • Parameter 6: MaxFibHeightInABH
    • Maximum height of the pattern in ABH.
    • Default: 50.
  • Parameter 7: MaxFibRangeInBars
    • Maximum range in bars for the pattern.
    • Default: 0 (no maximum).
  • Parameter 8: MinFibStrengthDifference
    • Minimum strength difference between 0% and 100% levels.
    • Default: 0.
  • Parameter 9: MinFibStrengthMultiplier
    • Minimum strength multiplier for the 100% level relative to the 0% level.
    • Default: 1.2.
  • Parameter 10: MinFib100Strength
    • Minimum strength of the 100% level.
    • Default: 20.
  • Parameter 11: MaxFib100Strength
    • Maximum strength of the 100% level.
    • Default: 250.
  • Parameter 12: MaxLookbackInBars
    • Maximum number of bars to look back for analysis.
    • Default: 150.
  • Parameter 13: ZoneLevelsCSV
    • Defines Fibonacci zones as a CSV string.
    • Default: '0.618,0.762'.
  • 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:: Applied Price
    • Defines the price of the bar to use for Fib price calculations. Can be either High (3) or Close (1). High means high and low prices will be used. Close (1) means only the closing price of the bar is used.
    • Default: 3 (High)

Buffers

  • Buffer 0: FibLevel0 values (0% level).
  • Buffer 1: FibLevel1 values (100% level).
  • Buffer 2: BarStrength values.
    • Bits 0–23: High bar strength values.
    • Bits 24–47: Low bar strength values.
  • Buffer 3: FibShift values.
    • Bits 0–19: 0% level shift value.
    • Bits 20–39: 100% level shift value.
    • Bit 40: FibType bit (0 = Bearish, 1 = Bullish).
    • Bit 41: FibMatch bit (1 = Matches user-defined Fibonacci pattern).
  • Buffer 4: FibTypeHistory
    • Bits 0–49: Last 50 FibType bits.
  • Buffer 5: SignalFlag values (Trend, Signal).

SignalFlag Logic

Trend Determination:

  • If FibShift = 0, then Trend = None.
  • If FibType = 1, then Trend = Bullish.
  • Otherwise, Trend = Bearish.
    Signal Determination:
  • For each zone in Fibonacci zones:
    • If price touches the zone, return Trend.
    • Otherwise, return None.

Associated Functions:

  • AutoFib1(int shift, int buffer, int ror, 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 ror, int mask)
  • Signal(‘BB1’)
  • Trend(‘BB1’)

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 ror, 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 ror, 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 ror, int mask)
  • Trend(‘Keltner1’)
  • OBOS(‘Keltner1’)

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 ror, 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 ror, 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 Sydney, Tokyo, Frankfurt, London, and New York. 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 4 markets.
    • Bit 0: Sydney: Open/Close (1=Open).
    • Bits 1-12: Sydney: Bar count since market opened.
    • Bit 13: Tokyo: Open/Close (1=Open).
    • Bits 14-25: Tokyo: Bar count since market opened.
    • Bit 26: London: Open/Close (1=Open).
    • Bits 27-38: London: Bar count since market opened.
    • Bit 39: New York: Open/Close (1=Open).
    • Bits 40-51: New York: Bar count since market opened.

Associated Functions

  • Markets1(int shift, int buffer, int ror, 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 ror, 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 ror, 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-19: High pivot shift values.
    • Bits 20-39: 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-19: High pivot shift values.
    • Bits 20-39: 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-19: High pivot shift values.
    • Bits 20-39: 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-19: High pivot shift values.
    • Bits 20-39: 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-19: High pivot shift values.
    • Bits 20-39: 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-19: High pivot shift values.
    • Bits 20-39: 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,0xFFFFF)+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. 0xFFFFF is used to mask the lower 20 bits.
To read the low price of the nearest low pivot bar of order 2 use:
High(PP1(1,2,20,0xFFFFF)+1)
20 is used as the bit rotate value to move bits 20-39 into bits 0-19.
To read the high price of the nearest high pivot bar of order 3 use:
High(PP1(1,3,0,0xFFFFF)+1)
To read the low price of the nearest low pivot bar of order 3 use:
High(PP1(1,3,20,0xFFFFF)+1)
Associated Functions

  • PP1(int shift, int buffer, int ror, 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 ror, 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 ror, 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 ror, int mask)
  • Signal(‘Scalper1’)

Stoch1 - 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 ror, 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 ror, int mask)
  • Signal(‘ST1’)
  • Trend(‘ST1’)

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,10,2,5,400,20,800,0.4,0.2,100,0).ex5,0,1,2,3,4

Parameters

  • Parameter 0: EA Flag
    • Indicates the indicator was created by an EA.
    • Default: 1.
  • Parameter 1: MinLineStrength
    • Minimum strength of a trendline to be displayed.
    • Default: 10.
  • Parameter 2: MinPivots
    • Minimum number of pivot points required to define a trendline.
    • Default: 2.
  • Parameter 3: MinPivotGap
    • Minimum gap, in bars, between adjacent pivot points.
    • Default: 5.
  • Parameter 4: MaxLineLengthInBars
    • Maximum length, in bars, of a trendline.
    • Default: 400.
  • Parameter 5: MinLineLengthInBars
    • Minimum length, in bars, of a trendline.
    • Default: 20.
  • Parameter 6: MaxLineAgeInBars
    • Maximum age, in bars, of a trendline before it is removed.
    • Default: 800.
  • Parameter 7: LineToleranceInABH
    • Maximum tolerance between the trendline and pivot points, as a fraction of the Average Bar Height (ABH).
    • Default: 0.4.
  • Parameter 8: BodyToleranceInABH
    • Maximum tolerance between the trendline and the candle body, as a fraction of the ABH.
    • Default: 0.2.
  • Parameter 9: ABHPeriod
    • Period used for calculating the Average Bar Height (ABH).
    • Default: 100.
  • Parameter 10: StrengthType
    • Method used to calculate trendline strength.
    • Default: 0.
    • Options:
      • 0: Bar
      • 1: Pivot

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).

SignalFlag Logic

Trend Determination:

  • Trend = Slope of the trendline closest to Close Price:
    • Bullish = Ascending trendline.
    • Bearish = Descending 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 ror, 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 buffer, int ror, 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,ror,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.
  • ror: Number of bits to rotate 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 ror and mask

  • ror: Use to align specific bits of interest to the least significant position.
    • Example: Rotate 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 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. In the GUI, enabling an indicator automatically adds the “+” to its creation string.

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.

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 three built-in functions for accessing specific SignalFlag bits from the indicator’s SignalFlags data buffer:

  • Signal(): Reads the Buy/Sell Signal Flags.
  • Trend(): Reads the Bullish/Bearish Trend Flags.
  • OBOS(): Reads the Overbought/Oversold Flags.

These functions offer a convenient and straightforward way to retrieve flag values directly. 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 change.
    • 0: Trend change occurred on the latest bar.
    • 1: Trend change occurred on bar 1, and so on.
  • Bits 12–23 (0xFFF000): Signal Bar Offset

    • Number of bars since the last Buy/Sell Signal.
    • 0: Signal occurred on the latest bar.
    • 1: Signal occurred on bar 1, and so on.
  • Bits 24–35 (0xFFF000000): Overbought/Oversold Bar Offset

    • Number of bars since the last Overbought/Oversold change.
    • 0: Overbought/Oversold change occurred on the latest bar.
    • 1: Overbought/Oversold change occurred on bar 1, and so on.
  • Bits 36–42 (0x7F000000000): 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 Signal
    • Bit 41: 1 = Oversold Signal
    • Bit 42: Unused
  • 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:15.4.2025 15:25