Reference guide for EAsiScript — the built-in scripting language used to define entry, exit, stop loss, take profit, and position sizing logic in EAsiTrader preset files. Covers all operators, variables, functions, and indicators available to scripts. For a hands-on tutorial with worked examples, see Learn EAsiScript. For general EA configuration, see the EAsiTrader User Guide.
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.
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:
7 scripts for short trades, with their corresponding preset file setting name: 8. Short Entry Script (InpTradeTool_ScriptShortEntry) 9. Short Initial Stop Script (InpTradeTool_ScriptShortInitialStop) 10. Short Trailing Stop Script (InpTradeTool_ScriptShortTrailingStop) 11. Short Lots Script (InpTradeTool_ScriptShortLots) 12. Short Take Profit Script (InpTradeTool_ScriptShortTakeProfit) 13. Short Breakeven Script (InpTradeTool_ScriptShortBreakeven) 14. Short Exit Script (InpTradeTool_ScriptShortExit)
1 AI script to control AI requests: 15. AITrigger Script (InpTradeTool_ScriptAITrigger)
See EAsiTrader GUI->Settings Tab in the EAsiTrader Manual for a list of all settings that work in conjunction with the scripts.
By default, all scripts use the following settings, unless overridden by the user, or overridden by a script, e.g. the Initial SL, Lots, TP and BE scripts:
(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.
(setting name: InpTradeTool_ScriptLongInitialStop)
(setting name: InpTradeTool_ScriptShortInitialStop)
These scripts are run once, immediately after the Entry Script has run and before the position has been opened, and are used to determine the initial stop loss (SL) value used for the new position. Use the Long Initial script to set the initial stop loss of a long position opened with the Long Entry script or use the Short Initial SL script to set the initial stop loss of a short position opened with the Short Entry script.
The Initial SL scripts are run once immediately after the Entry Script initiates a new trade, i.e. when the script returns a non-zero value.
If the script is not defined then the position's SL is calculated by running the Long Trailing SL script for long positions or the Short Trailing SL script for short positions. If this script is not defined then the position's SL is calculated using the Settings -> Stops ->SL setting.
The result is used as the SL for the new position if:
No action is taken if:
(setting name: InpTradeTool_ScriptLongTrailingStop)
(setting name: InpTradeTool_ScriptShortTrailingStop)
These scripts are run after a position has been opened and used to determine a new value for the stop loss (SL). These scripts can also be run immediately after an entry script if the Initial SL script is not defined. Use the Long Trailing SL script to set or update the SL of a long position opened with the Long Entry script or use the Short Trailing SL script to set or update the SL of a short position opened with the Short Entry script.
These scripts are run every tick on a new high for long positions and on a new low for short positions, whilst the position is open, regardless of the Settings -> Auto Trade -> Refresh Mode setting. These scripts are also run immediately after an entry script if the Initial SL script is not defined.
The position's SL price is updated if both of the following conditions are met:
The position's SL is not changed if any of the following conditions are met:
(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.
(setting name: InpTradeTool_ScriptLongTakeProfit)
(setting name: InpTradeTool_ScriptShortTakeProfit)
These scripts are run once, immediately after the Entry Script has run and before the position has been opened, and are used to determine the take profit (TP) value for the position. Use the Long TP script to set the TP of a long position opened with the Long Entry script and use the Short TP script to set the TP of a short position opened with the Short Entry script.
This script is run once immediately after the Entry script. If the script is not defined and the Settings -> Stops -> TP setting is enabled then the position's TP value is calculated using the Settings -> Stops -> TP setting. If this setting is not enabled then no TP is used.
The result is used as the TP when the position is opened if:
No action is taken if:
(setting name: InpTradeTool_ScriptLongBreakeven)
(setting name: InpTradeTool_ScriptShortBreakeven)
These scripts are run, immediately after the Entry Script has run and before the position has been opened, and when price makes a new high or new low for the current bar. It is used to determine the Breakeven trigger price for the position. Use the Long BE script to set the Breakeven trigger price of a long position opened with the Long Entry script and use the Short BE script to set the Breakeven trigger price of a short position opened with the Short Entry script.
This script is run once immediately after the entry script and when price makes a new high or new low for the current bar.
If the script is not defined and the Settings -> Stops -> BE setting is enabled then the position's BE value is calculated using the Settings -> Stops -> BE setting. If this setting is not enabled then no BE is used.
(setting name: InpTradeTool_ScriptLongExit)
(setting name: InpTradeTool_ScriptShortExit)
Use the Long Exit script to close a long position previously opened with the Long Entry script and use the Short Exit script to close a short position previously opened with the Short Entry script.
These scripts are run every tick whilst the position is open, regardless of the Settings -> Auto Trade -> Refresh Mode setting.
(setting name: InpTradeTool_ScriptAITrigger)
This script acts as a gatekeeper for AI assessment refreshes, controlling when new requests are sent to AI and thereby managing token usage and API costs. It works in conjunction with the AIRefreshIntervalMinutes setting (InpTradeTool_AIRefreshIntervalMinutes), which sets the minimum time between AI requests. The refresh interval is checked first — if it hasn't elapsed, no refresh occurs regardless of this script. Once the interval has passed, the trigger script provides a second layer of control by applying custom conditions.
The trigger script is evaluated only after the current AI assessment has expired and there are no open positions (open positions always trigger a refresh regardless of this script). Returning a positive value (greater than zero) from this script means an AI request will be sent on the current bar. Returning zero or a negative value means the request is blocked. If this setting is left empty, the trigger check is skipped entirely and AI refreshes proceed whenever the assessment expires.
This script is run either every bar or every tick according to the Settings -> Auto Trade -> Refresh Mode setting. Every Bar is the default and recommended setting for most strategies. Every Tick consumes more compute time and could affect performance, especially when trading multiple markets.
This script uses the same expression engine as entry and exit scripts, so any variable available in EAsiScript expressions can be used here. Typical use cases include gating AI calls on volatility thresholds, indicator alignments, session times, or other conditions that indicate the market is worth analysing.
Only allow AI requests during the London and New York trading sessions (08:00–21:00 server time), blocking requests during the quieter Asian session to save API costs.
TimeOfDay(8,0) >= 0 && TimeOfDay(21,0) < 0 ? 1 : 0
TimeOfDay(8,0) >= 0: Current time is at or after 08:00TimeOfDay(21,0) < 0: Current time is before 21:001 (allow) during the window, 0 (block) outside itOnly refresh the AI assessment when the market is showing above-average volatility, avoiding wasted API calls during low-activity periods.
ATR1(1) > ATR1(14) * 0.8 ? 1 : 0
ATR1(1): Current ATR value (last closed bar)ATR1(14): ATR value from 14 bars ago (a longer-term reference)Only request an AI assessment when the moving average confirms a trend, avoiding requests during choppy, trendless conditions.
Trend('MA1') != 0 ? 1 : 0
Trend('MA1'): Returns Bullish (1), Bearish (-1), or No Trend (0) from the MA indicatorCombine multiple conditions — only refresh during London/NY hours AND when volatility is sufficient AND when there is directional momentum.
TimeOfDay(8,0) >= 0 && TimeOfDay(21,0) < 0 && ATR1(1) > ATR1(14) * 0.8 && Close(1) != Open(1) ? 1 : 0
Ensure that any indicators referenced in the AI Trigger Script (e.g., ATR1, MA1) are enabled in the Indicator's List (prefixed with + in the preset file). This also applies more broadly: any indicator whose grounded events or raw data should be included in AI requests must be enabled, regardless of whether it is referenced in a script. The AI Trigger Script is only evaluated when all three preconditions are met: the refresh interval has elapsed, the current AI assessment has expired, and there are no open positions.
This section explains the logical steps EAsiScript follows to evaluate and execute trading logic. The process is divided into distinct phases for better understanding.
The workflow begins when one of the following events is triggered.
OnTick() Event:OnTimer() Event:OnTick().At this stage, the system prepares essential variables and performs initial validations to set up the trading environment.
CurrentAsk to the symbol's current Ask price.CurrentBid to the symbol's current Bid price.InpTradeTool_AutoTradeEnabled setting is false, exit the workflow.InpTradeTool_LiveTrades and InpTradeTool_SignalAlerts settings are false for the market, exit the workflow.InpTradeTool_LongEntryScript and InpTradeTool_ShortEntryScript are undefined or empty, exit the workflow.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.
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.
InpTradeTool_StartOfDayTime (start of trading).InpTradeTool_EndOfDayTime (end of trading).InpTradeTool_MaxOpenPositions (default: 1).InpTradeTool_MaxOpenPositionsSymbol (default: 0; ignored if zero).InpTradeTool_MaxOpenPositionsAccount (default: 0; ignored if zero).InpTradeTool_MaxTradesUnitTimeInSeconds does not exceed the allowed maximum (default: 0; ignored if zero).InpTradeTool_MinTradeIntervalInSeconds (default: 0; ignored if zero).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.
0, no trade is required, and the workflow exits.LongEntryScript equals the current ask price.ShortEntryScript equals the current bid price.LongEntryScript is greater than the current ask price.ShortEntryScript is less than the current bid price.LongEntryScript is less than the current ask price.ShortEntryScript is greater than the current bid price.LongEntryScript and ShortEntryScript return positive results on the same tick: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.
InpTradeTool_InitialStopValueInpTradeTool_InitialStopValueUnits (e.g., ATR, HH/LL Bars, Points).InpTradeTool_MaxRiskPerTradeInPercentInpTradeTool_MaxRiskPerTradeInMoneyInpTradeTool_TakeProfitStopValueInpTradeTool_TakeProfitStopValueUnits (e.g., ATR, HH/LL Bars, Points).InpTradeTool_SignalAlerts is enabled:(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.
Assign a value to one of the UserVAR settings, such as VAR0 = 10.
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
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:
10, 201, 2VAR0 = 10, VAR1 = 1VAR0 = 10, VAR1 = 2VAR0 = 20, VAR1 = 1VAR0 = 20, VAR1 = 2If you define 3 variables, each with 10 values, the optimiser will perform 10 * 10 *10 = 1000 passes.
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.
Indicator Creation String: Replace fixed parameters with UserVARs:
NTL\MA(1,VAR0).ex5,0,1
Notes:
| 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 |
| 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 |
| Function | Description |
|---|---|
| Ask(double offset=0) | Returns the ask price for the current symbol, adjusted by offset (price+price*offset). For live trading this is SYMBOL_ASK. For Tester trading this is the ask tick price plus 0.5 * broker spread (Tester->BrokerSpread). |
| Bid(double offset=0) | Returns the bid price for the current symbol, adjusted by offset (price+price*offset). For live trading this is SYMBOL_BID. For Tester trading this is the bid tick price minus 0.5 * broker spread (Tester->BrokerSpread). |
| BodyHigh(int shift=1,string symbol=_Symbol) | Returns the high body price of the bar at offset shift for symbol. |
| BodyLow(int shift=1,string symbol=_Symbol) | Returns the low body price of the bar at offset shift for symbol. |
| Close(int shift=1, string symbol=_Symbol, enum timeframe=_Period) | Returns the close price of a bar at offset shift for symbol and timeframe. |
| High(int shift=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the high price of the bar at offset shift for symbol and timeframe. |
| HighD(int shift=0, string symbol=_Symbol) | Returns the daily high price for the bar at offset shift and symbol. |
| Low(int shift=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the low price of the bar at offset shift for symbol and timeframe. |
| LowD(int shift=0, string symbol=_Symbol) | Returns the daily low price for the bar at offset shift and symbol. |
| Mid(string symbol=_Symbol) | Returns the mid price for symbol. The mid price is (bid + ask) * 0.5. |
| Open(int shift=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the open price of the bar at offset shift for symbol and timeframe. |
| Spread(int shift=1, string symbol=_Symbol, enum timeframe=_Period) | Returns the spread of the bar at offset shift for symbol and timeframe. |
| Volume(int shift=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the trade volume or tick volume (broker dependent) of the bar at offset shift for symbol and timeframe. |
| Function | Description |
|---|---|
| BarClosePos(int shift=1) | Returns the position of the close within the bar's total range as a ratio between 0.0 (close at low) and 1.0 (close at high). If the high equals the low, the function returns 0.5. |
| BarImpulse(int shift=1) | Returns a signed momentum ratio for the bar at shift. The value is (BodySize / BarSize) multiplied by 1 for bullish bars or -1 for bearish bars. If the bar has no range or no body, returns 0. |
| BarMatch(int shift=1, int direction=0, int barSize=0, int bodySize=0, int wickSize=0, int upperWick=0, int lowerWick=0) | Returns 1 if the bar at the specified shift matches the specified bar direction and structural criteria, otherwise returns 0. All size parameters must be specified in points (e.g. 10 * Point). Use positive values to check for greater than or equal, and negative values to check for less than. Direction should be Bullish, Bearish, or 0 (any). A return value of 1 indicates a matching bar. |
| BarMatchAvg(string atrName,int shift=1, int direction=0, double barSize=0, double bodySize=0, double wickSize=0, double upperWick=0, double lowerWick=0) | Returns 1 if the bar at the specified shift matches the given direction and structural criteria, scaled as a proportion of the average bar height. The average height is read from the indicator named in atrName (typically an ATR indicator like 'ATR1'). Use positive values to check for values greater than or equal to the specified ratio, and negative values to check for values less than the ratio. Direction can be Bullish, Bearish, or 0 (any). |
| BarSize(int shift=1, part=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the size of a part of a bar, in terms of its price, at offset shift, for symbol and timeframe. part can be: 0=whole bar, 1=body, 2=upper wick, 3=lower wick. |
| BarSkew(int shift=1) | Returns the position of the body midpoint within the bar’s total range as a ratio between 0.0 (body midpoint at low) and 1.0 (body midpoint at high). If high equals low, returns 0.5. |
| BarTrend(int shift=1, string symbol=_Symbol, enum timeframe=_Period) | Returns the trend of a bar at offset shift for symbol and timeframe. 0=no trend (open=close), 1=bullish bar (close > open), -1=bearish bar (close < open). |
| BearishBars(int count=0,string symbol=_Symbol, enum timeframe=_Period) | Returns the number of bearish bars (close < open) starting from the latest closed bar for symbol and timeframe. If count = 0, the function returns the number of consecutive bearish bars. If count > 0, it counts up to count bearish bars (not necessarily consecutive). |
| BodyX(int bars=0, double price=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the number of bars, in a range starting from the latest closed bar, whose body part crosses the specified price. If price is 0 the symbol's mid price is used. The mid price is (bid + ask) * 0.5. |
| BoxBars(double lowPrice, double highPrice, int bars, string symbol=_Symbol, enum timeframe=_Period) | Returns the number of bars in a range starting from the latest closed bar whose open and close prices are both contained within the specified price box. The count stops when the first bar having either its open or close price outside the box is encountered. |
| BullishBars(int count=0,string symbol=_Symbol, enum timeframe=_Period) | Returns the number of bullish bars (close > open) starting from the latest closed bar for symbol and timeframe. If count = 0, the function returns the number of consecutive bullish bars. If count > 0, it counts up to count bullish bars (not necessarily consecutive). |
| DayBars() | Returns the number of bars since the start of the current day. |
| HighBars(int bars=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the number of bars, in a range starting from the latest closed bar, whose high is higher than the high of the latest closed bar, for symbol and timeframe. If bars=0 the function returns the number of bars that have a high price lower than or equal to the high price of the latest closed bar, up to a maximum of 1000 bars. The count stops when the first bar with a higher high is encountered. |
| HighestBody(int bars=0, int shift=1, string symbol=_Symbol, enum timeframe=_Period) | Returns the highest body price for a range of bars, symbol and timeframe, starting from the bar at offset shift. |
| HighestHigh(int bars=0, int shift=1, string symbol=_Symbol, enum timeframe=_Period) | Returns the highest high price for a range of bars, symbol and timeframe, starting from the bar at offset shift. |
| IsDoji(int shift=1, double barBodyRatio=10) | Returns 1 if the bar at shift is a doji. A doji is defined as a bar where the body size (Close-Open) is very small relative to its total range (High-Low). The barBodyRatio sets how small: the bar’s total range must be at least barBodyRatio times larger than the body size. Zero-body bars (open = close) are always considered doji. |
| IsEngulfing(int shift=1, int direction=0) | Returns 1 if the bar at shift fully engulfs the previous bar’s body. The direction parameter should be Bullish (1), Bearish (-1), or 0 (any). A bullish engulfing requires the current bar to be bullish and the body to fully cover the previous bar’s body. |
| IsInsideBar(int shift=1) | Returns 1 if the bar at shift is fully inside the range of the previous bar. This means the current bar’s High <= previous High** and **Low >= previous Low. |
| IsOutsideBar(int shift=1) | Returns 1 if the bar at shift is fully outside the range of the previous bar. This means the current bar’s High >= previous High and Low <= previous Low. |
| IsPinBar(int shift=1, double wickRatio=0.33) | Returns 1 if the bar at shift has a small body and a large wick. The wickRatio defines the minimum wick-to-bar ratio required (default is 0.33). At least one wick (upper or lower) must meet the ratio requirement. |
| LowBars(int bars=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the number of bars, in a range starting from the latest closed bar, whose low is lower than the low of the latest closed bar, for the specified symbol and timeframe. If bars=0 the function returns the number of bars that have a low price higher than or equal to the low price of the latest closed bar, up to a maximum of 1000 bars. The count stops when the first bar with a lower low is encountered. |
| LowerWickX(int shift, double price, string symbol=_Symbol, enum timeframe=_Period) | Returns true if price crosses the lower wick of the bar at offset shift, for symbol and timeframe. |
| LowestBody(int bars=0, int shift=1, string symbol=_Symbol, enum timeframe=_Period) | Returns the lowest body low price for a range of bars, symbol and timeframe, starting from the bar at offset shift. |
| LowestLow(int bars=0, int shift=1, string symbol=_Symbol, enum timeframe=_Period) | Returns the lowest low price for a range of bars, symbol and timeframe, starting from the bar at offset shift. |
| Range(int bars, int mode=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the difference in points between the highest high price and lowest low price for a range of bars, symbol and timeframe starting from the latest closed bar. |
| TrendStretch(int shift=1, int direction=1) | Returns the number of consecutive bars, starting from shift, where each bar closes above the previous high (for Bullish) or below the previous low (for Bearish). The count stops at the first bar that does not meet the condition. The direction parameter must be Bullish (1) or Bearish (-1). |
| UpperWickX(int shift, double price, string symbol=_Symbol, enum timeframe=_Period) | Returns true if price crosses the upper wick of the bar at offset shift, for symbol and timeframe. |
| WickRatio(int shift=1) | Returns the ratio of the total wick length (UpperWick + LowerWick) to the body size. Returns 0 if the body size is zero. |
| Function | Description |
|---|---|
| TickAsk(int shift=0,string symbol=_Symbol) | Returns the tick ask price for symbol at the tick offset from the latest tick. |
| TickBid(int shift=0, string symbol=_Symbol) | Returns the tick bid price for symbol at the offset from the latest tick. |
| TickHigest(int tickRangeInMs, string symbol=_Symbol) | Returns the highest ask tick price for symbol and time range in milliseconds counting back from the latest tick. |
| TickLowest(int tickRangeInMs, string symbol = _Symbol) | Returns the lowest bid tick price for symbol and time range in milliseconds counting back from the latest tick. |
| TickRange(int tickRangeInMs, string symbol = _Symbol) | Returns the difference in points between the highest ask and lowest bid for symbol and time span in milliseconds from the latest tick. |
| Function | Description |
|---|---|
| AiBias() | Returns the AI-assessed directional bias for the current market. |
| AiBiasConfidence() | Returns the AI confidence level for the directional bias, as a value between 0.0 and 1.0. |
| AiBiasMultiplier(int isLong) | Returns a directional position-size multiplier based on AI bias. isLong should be 1 for long trades and 0 for short trades. |
| AiBiasRaw() | Returns the raw AI directional bias without checking validity or expiry. |
| AiCombinedMultiplier(int isLong) | Returns the combined AI multiplier derived from both bias and risk assessment. isLong should be 1 for long trades and 0 for short trades. |
| AiConfidence() | Returns the overall AI confidence score, as a value between 0.0 and 1.0. |
| AiConfidenceRaw() | Returns the raw AI confidence score without checking validity or expiry. |
| AiDataAge() | Returns the age of the current AI assessment in seconds. |
| AiIsBearish() | Returns 1 if the AI directional bias is bearish, otherwise 0. |
| AiIsBullish() | Returns 1 if the AI directional bias is bullish, otherwise 0. |
| AiIsHighRisk() | Returns 1 if the AI has classified current conditions as high risk, otherwise 0. |
| AiIsLowRisk() | Returns 1 if the AI has classified current conditions as low risk, otherwise 0. |
| AiIsRanging() | Returns 1 if the AI market regime is ranging, otherwise 0. |
| AiIsStrongBias() | Returns 1 if the AI bias is classified as strong (strong bullish or strong bearish), otherwise 0. |
| AiIsTrending() | Returns 1 if the AI market regime is trending, otherwise 0. |
| AiIsUsable() | Returns 1 if the AI assessment is suitable for use in scripts, otherwise 0. |
| AiIsValid() | Returns 1 if the AI assessment data is valid, otherwise 0. |
| AiIsVolatile() | Returns 1 if the AI market regime is volatile, otherwise 0. |
| AiRegime() | Returns the AI-assessed market regime for the current market conditions. |
| AiRegimeConfidence() | Returns the AI confidence level for the market regime, as a value between 0.0 and 1.0. |
| AiRegimeRaw() | Returns the raw AI market regime without checking validity or expiry. |
| AiRiskConfidence() | Returns the AI confidence level for the risk classification, as a value between 0.0 and 1.0. |
| AiRiskMode() | Returns the AI-recommended risk mode for the current market conditions. |
| AiRiskModeRaw() | Returns the raw AI risk mode without checking validity or expiry. |
| AiRiskMultiplier() | Returns a position-size multiplier based on the AI risk assessment. |
| AiSecondsToExpiry() | Returns the number of seconds remaining before the current AI assessment expires. |
| AiStatus() | Returns the current AI context status. |
AI functions allow scripts to incorporate the AI's market assessment into entry, exit, lot sizing, and trade management decisions. These functions return meaningful values only when the AI is enabled (AIMode ≠ 0) and has a valid, non-expired assessment. When the AI is disabled or no valid assessment exists, functions like AiIsValid() return 0 and numeric functions return their default values (typically 0 or 1.0 for multipliers).
Important: The AI-enhanced entry script examples below are suitable for Filter Signals mode. In Gated Trading mode, entry scripts must be AI-blind — they must not reference any
Ai*()functions. See Gated Trading in Detail.
Only enter long trades when the AI's directional bias is bullish and the AI assessment is valid. This combines a script-based MA crossover condition with AI confirmation.
Long Entry Script:
AiIsValid() == 1 && AiIsBullish() == 1 && Close(1) > MA1(1,0) && Close(2) <= MA1(2,0) ? Ask() : 0
AiIsValid() == 1: Confirms the AI assessment is current and validAiIsBullish() == 1: AI bias is bullish (aligns with long entry)Only trade when the AI has high confidence in its assessment, filtering out uncertain conditions.
Long Entry Script:
AiConfidence() > 0.7 && AiIsBullish() == 1 && Signal('RSI1') == Bullish ? Ask() : 0
AiConfidence() > 0.7: Requires at least 70% overall AI confidenceUse the AI's combined multiplier to adjust lot size based on the AI's bias alignment and risk assessment.
Long Lots Script:
AiCombinedMultiplier(1) * 0.01
AiCombinedMultiplier(1): Returns a multiplier that factors in both bias alignment (is the AI bullish for this long trade?) and risk mode (normal, reduced, aggressive, etc.)1 parameter indicates this is a long tradeClose a long position if the AI detects the market has shifted to a ranging regime, suggesting the trend may be over.
Long Exit Script:
AiIsValid() == 1 && AiIsRanging() == 1 ? Bid() : 0
AiIsValid() == 0), the position is held — fail-open behaviourMove the stop loss to breakeven when the AI classifies conditions as high risk.
Long BE Script:
AiIsValid() == 1 && AiIsHighRisk() == 1 ? OrderPrice() : 0
AiIsHighRisk() == 1: AI has flagged elevated risk conditionsOnly enter when the AI detects a strong directional conviction, combined with a technical confirmation.
Long Entry Script:
AiIsStrongBias() == 1 && AiIsBullish() == 1 && AiIsTrending() == 1 && Close(1) > MA1(1,0) ? Ask() : 0
AiIsStrongBias() == 1: AI bias is "strongbull" or "strongbear"AiIsTrending() == 1: AI regime is "trending" (not ranging or volatile)AI functions require the AI to be enabled and configured with a valid provider. When backtesting with the Tester, AI functions are not available because the AI system does not operate during simulated trading — AI functions will return their default values (0 for boolean checks, 1.0 for multipliers). Test your scripts with AI functions in Monitor Only mode on a demo account before enabling Filter Signals, Gated Trading, or Autonomous modes for live trading.
| Function | Description |
|---|---|
| Bars(string indicator) | Returns the number of bars available for indicator. |
| Comp(string indicator, int buf1=0, int buf2=-1, int shift1=1, int shift2=1) | Compares the buffer data for indicator at buffer buf1, shift offset shift1 with the buffer data at buffer buf2, shift offset shift2. If buf2 is -1 the Closing Price at shift offset shift2 of the current symbol and timeframe is used. Returns 0 if the data is equal, -1 if less than or 1 if greater than. |
| Cross(string indicator, int buf1=0, int buf2=-1, int shift1=1, int shift2=2) | Looks for a cross in the buffer data for indicator at shift offset shift1 in at buffer buf1 and buf2 with the buffer data at shift offset shift2 in buffer buf1 and buf2. If buf2 is -1 the Closing Price at shift offset shift1 and shift2 of the current symbol and timeframe is used. Returns 0 if the data do not cross, -1 if bearish cross or 1 if bullish cross. |
| FibInZone(string fibIndicator, double zoneLevel1, double zoneLevel2, double price, int shift=1) | Returns true if price is inside a zone of a Fib retracement indicator. Shift is the shift offset in the Fib indicator's buffer to the Fib retracement being tested. zoneLevel1=0-1, zoneLevel2=0-1. |
| FibPrice(string fibIndicator, double fibLevel, int shift=1) | Returns the price of the Fib Level for a Fib retracement indicator. Shift is the shift offset in the Fib indicator's buffer to the Fib retracement being tested. fibLevel=0-1. |
| HLineBreak(string hlineIndicator, string atrIndicator, double atrMultiplier=0.1, int mode=0, int shift=1) | Returns 1 (bullish breakout), -1 (bearish breakout), or 0 (no breakout) based on whether price breaks the most recent HLine. Wick touch is not checked — only price breaking beyond the line. Tolerance is set by atrMultiplier * ATR. Mode 0 = strict (body beyond + previous close on opposite side). Mode 1 = loose (close beyond + previous close on opposite side). |
| HLinesBounce(string hlineIndicator, string atrIndicator, double atrMultiplier=0.1, int mode=0, int shift=1) | Returns 1 (bullish bounce), -1 (bearish bounce), or 0 (no bounce) based on whether price bounces off the most recent HLine. Wick must touch the line within ATR-based tolerance. Mode 0 = strict (touch + current and previous close reject). Mode 1 = loose (touch + current close rejects). |
| OBOS(string indicator, int shift=1) | For indicators that support SignalFlags, this function returns the Overbought/Oversold signal flag at the bar at offset shift for indicator. 0=no signal, 1=oversold, -1=overbought. |
| PivotHighPrice(string pivotIndicator, int minOrder=2, int shift=1) | Returns the price of a pivot high from the specified PivotPoints indicator instance. Searches backwards from the bar at shift for the most recent high pivot whose order is greater than or equal to minOrder. |
| PivotLowPrice(string pivotIndicator, int minOrder=2, int shift=1) | Returns the price of a pivot low from the specified PivotPoints indicator instance. Searches backwards from the bar at shift for the most recent low pivot whose order is greater than or equal to minOrder. |
| PivotTrend(string pivotIndicator,int order,int mode=0,int shift=1) | Returns 1 (bullish), -1 (bearish) or 0 (neutral) based on pivot highs and lows. Mode=0 strict (HH & HL), 1=structure (HL), 2=breakout (HH). |
| Signal(string indicator, int shift=1) | Returns the signal direction at bar offset shift for indicator. -1=bearish, 0=no signal, 1=bullish. For bars-since queries, use SignalBull() or SignalBear(). |
| SignalBear(string indicator, int shift=1) | Returns bars since last bearish signal for indicator. 0=no signal, 1=signal on this bar, N=signal N-1 bars ago. |
| SignalBull(string indicator, int shift=1) | Returns bars since last bullish signal for indicator. 0=no signal, 1=signal on this bar, N=signal N-1 bars ago. |
| Stat(int metric) | Returns the value of the specified statistical metric for the current market. The metric index must match a row in the Statistic Metrics Table (see EAsiTrader User Guide, Section 15). Returns NaN if the metric is not available. |
| StructureFlow(string indicator,int pattern,int shift=1) | Returns 1 if the last 3 SwingMap swing types match pattern, 0 otherwise. Pattern is a 3-digit number (oldest to newest): 0=any (wildcard), 1=HH, 2=HL, 3=LH, 4=LL. E.g. 212 = HL->HH->HL, 102 = HH->any->HL. |
| StructureQuality(string indicator,int shift=1) | Returns structure quality from the last 3 SwingMap swings. +2=strong bullish (HL->HH->HL or HH->HL->HH), +1=acceptable bullish (HL->HH->HH or HH->HH->HL), -1=acceptable bearish (LH->LL->LL or LL->LL->LH), -2=strong bearish (LH->LL->LH or LL->LH->LL), 0=no match. |
| Trend(string indicator, int shift=1) | Returns the trend direction at bar offset shift for indicator. -1=bearish, 0=no trend, 1=bullish. For bars-since queries, use TrendBull() or TrendBear(). |
| TrendBear(string indicator, int shift=1) | Returns bars since bearish trend started for indicator. 0=not bearish, 1=trend started on this bar, N=trend started N-1 bars ago. |
| TrendBull(string indicator, int shift=1) | Returns bars since bullish trend started for indicator. 0=not bullish, 1=trend started on this bar, N=trend started N-1 bars ago. |
| Function | Description |
|---|---|
| BarsOpen(int position) | Returns the number of bars a position has been open, or the current position if position is not specified. |
| BE(int position) | Returns the Breakeven price for a position, or the current position if position is not specified. |
| Duration(int position) | Returns the duration in seconds a position has been open, or the current position if position is not specified. |
| EntryPrice(int position) | Returns the entry price for a position, or the current position if position is not specified. For live trades this is the fill price. For simulated trades this is the current bid/ask price at the time the position was opened. This function returns an invalid value when called by the Initial SL Scripts, Take Profit Scripts and Breakeven Scripts. Use OrderPrice() instead. |
| IsBE() | Returns true (1) if the current position has reached breakeven or false (0) if not. |
| IsOpen(int position) | Returns the open state of a position, or the current position if position is not specified. Returns 1 if the state of the current position is Open. |
| IsPending(int position) | Returns the pending state of a position, or the current position if position is not specified. Returns 1 if the state of the current position is Pending. |
| Lots(int position) | Returns the size of a position in lots, or the current position if position is not specified. This value is available immediately after a Lots script is run, if defined. |
| MaxLots(int slsize=0) | Returns the maximum number of lots that can be traded based on free margin (equity minus used margin). The slsize parameter represents the stop loss distance in points - when provided, the maximum risk per trade is divided by this distance to determine the maximum allowed lot size that satisfies both margin and risk management limits. |
| MaxPoints(int position) | Returns the current maximum profit in points made by a position, or the current position if position is not specified. |
| MaxProfit(int position) | Returns the current maximum profit in money made by a position, or the current position if position is not specified. |
| OrderPrice(int position) | Returns the order price for a position, or the current position if position is not specified. This function can be used immediately after an Entry script has been run. |
| OrderType(int position) | Returns the order type for a position, or the current position if position is not specified. (0=Buy, 1=Sell, etc.) This function can be used immediately after an Entry script has been run. |
| Pips(int position) | Returns the current profit in pips for a position, or the current position if position is not specified. |
| Points(int position) | Returns the current profit in points for a position, or the current position if position is not specified. |
| Positions() | Returns the number of open positions. |
| PriceShift(double price, int shift=1) | Returns the number of bars since the specified price was last within a bar's high-low range, searching back up to 1000 bars while maintaining price-relative continuity across gaps. The optional shift parameter offsets the starting point of the search. |
| Profit(int position) | Returns the current profit in money for a position, or the current position if position is not specified. |
| R(int position) | Returns the initial risk in points for a position, or the current position if position is not specified. |
| SL(int position) | Returns the stop loss price for a position, or the current position if position is not specified. This value is available immediately after an Entry script is run, or after the Initial SL / Trailing SL scripts, if defined. |
| SLSize(int position) | Returns the stop loss size in points for a position, or the current position if position is not specified. This value is available immediately after an Entry script is run, or after the Initial SL / Trailing SL scripts, if defined. |
| TotalPips() | Returns the total profit in pips for all open positions. |
| TotalPoints() | Returns the total profit in points for all open positions. |
| TotalProfit() | Returns the total profit in money for all open positions. |
| TP(int position) | Returns the TP price for a position, or the current position if position is not specified. This value is available immediately after a TP script is run, if defined. |
| Function | Description |
|---|---|
| Balance() | Returns the account's balance. For live trading, this is the account balance in the deposit currency at the time of the function call. For Tester trading, this is the account balance value in the Tester's context at the time of the Tester's clock. |
| Equity() | Returns the account's equity. For live trading, this is the account equity in the deposit currency (ACCOUNT_EQUITY) at the time of the function call. For Tester trading this is the current equity value in the Tester's context at the time of the Tester's clock. |
| FreeMargin() | Returns the account's free margin. For live trading, this is the free margin of the account in the deposit currency (ACCOUNT_MARGIN_FREE) at the time of the function call. For Tester trading, this is the free margin value in the Tester's context at the time of the Tester's clock. |
| Function | Description |
|---|---|
| Day() | Returns the day of the week (0-6) for the current date. 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday. |
| Hour(int timeZone) | Returns the hour (0–23) of the opening time of the latest bar for the current symbol, adjusted to the specified time zone. TimeZone options are: 0=Frankfurt, 1=London, 2=New York, 3=Sydney, 4=Tokyo. If the timeZone parameter is omitted, the function returns the hour in chart time (broker server time). |
| Minute() | Returns the minute (0-59) of the opening time of the latest bar for the current symbol. |
| Time(int shift=0, string symbol=_Symbol, enum timeframe=_Period) | Returns the open time of the bar at offset shift for symbol and timeframe. |
| TimeOfDay(int hour1=0,int minute1=0,int hour2=0,int minute2=0) | Returns the number of minutes past midnight for the current day. If hour1 and minute1 are provided, the function returns 0 if the current time matches hour1 and minute1, -1 if the current time is before hour1 and minute1, or 1 if the current time is after hour1 and minute1. If hour1, minute1, hour2 and minute2 are provided the function returns 0 if the current time is between the two times, -1 if the current time is before the hour1 and minute1, or 1 if the current time is after hour2 and minute2. |
| TimeShift(int hour, int minute) | Returns the number of bars since the specified hour and minute of the current day. |
| Function | Description |
|---|---|
| Abs(double x) | Returns absolute value (modulus) of x. |
| Ceil(double x) | Returns integer numeric value closest from above x. |
| Floor(double x) | Returns integer numeric value closest from below x. |
| Max(double x, double y) | Returns the maximum value of x and y. |
| Min(double x, double y) | Returns the minimum value of x and y. |
| Mod(double x, double y) | Returns the real remainder after the division of x and y. |
| Rand() | Returns a pseudorandom value within the range of 0 to 32767. |
| Round(double x) | Returns x rounded to the nearest integer. |
| Sqrt(double x) | Returns the square root of x. |
Notes:
Indicators are essential for making informed trading decisions. In EAsiScript, indicators output data through buffers, which store calculated values such as signal flags or trend data. These buffers are accessed using functions like Signal() and Trend().
EAsiTrader comes supplied with custom versions of 13 widely used indicators and 12 NTL proprietary indicators. Where applicable each indicator provides signal, trend and overbought/oversold signals from its signal data buffer, as well as access to the data from its other buffers. The EA can connect with an indicator either via the indicator's .ex5 executable file, called a custom indicator, or via the chart that the indicator has been loaded onto, called a chart indicator.
Each indicator listed below shows a Creation String and a Default Setting. The Creation String is the template format showing the indicator's configurable parameters. The Default Setting is a concrete example that includes default parameter values and the comma-separated list of buffer numbers appended after .ex5 that scripts can read from. See Indicator Creation Strings for the full format specification.
Key terms used throughout this section: Bar Strength measures the significance of a bar's high or low relative to surrounding bars; Pivot Order ranks price highs and lows by significance; Shift is the bar offset from the latest bar. See Terms for full definitions.
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.
NTL\ABH([parameters,]).ex5
NTL\ABH(1,14,3).ex5,0,1
1.14.15 (all components). 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.
Indicators\NTL\ADX([parameters,]).ex5
NTL\ADX(1,14).ex5,0,1,2,3
1.14.20.0. 0: ADX Crosses Threshold 1: DI Lines Cross When TrendingTrend Determination:
ADX < TrendStrengthThreshold, then Trend = None. +DI > -DI, then Trend = Bullish. -DI > +DI, then Trend = Bearish.Signal Determination:
ADXSignalLogicMethod = 0 (ADX Crosses Threshold): Bullish and PreviousTrend = None, then Signal = Bullish. Bearish and PreviousTrend = None, then Signal = Bearish.ADXSignalLogicMethod = 1 (DI Lines Cross When Trending): Bullish and previous -DI > previous +DI, then Signal = Bullish. Bearish and previous +DI > previous -DI, then Signal = Bearish.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.
Indicators\NTL\ADXW([parameters,]).ex5
NTL\ADXW(1,14).ex5,0,1,2,3
1.14.20.0. 0: ADXW Crosses Threshold 1: DI Lines Cross When TrendingTrend Determination:
ADXW < TrendStrengthThreshold, then Trend = None. +DI > -DI, then Trend = Bullish. -DI > +DI, then Trend = Bearish.Signal Determination:
ADXWSignalLogicMethod = 0 (ADXW Crosses Threshold): Bullish and PreviousTrend = None, then Signal = Bullish. Bearish and PreviousTrend = None, then Signal = Bearish.ADXWSignalLogicMethod = 1 (DI Lines Cross When Trending): Bullish and previous -DI > previous +DI, then Signal = Bullish. Bearish and previous +DI > previous -DI, then Signal = Bearish.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.
NTL\ATR([parameters,]).ex5
NTL\ATR(1,14).ex5,0
1.14.File: \Indicators\NTL\AutoFib.ex5
Description: Automatically identifies Fibonacci retracement and extension levels, providing key levels of support and resistance. Uses bar strength analysis to find significant swing highs and lows, then defines Fibonacci retracement zones between them. Integrates with Average Bar Height (ABH) for dynamic volatility-adjusted height filtering. Fully customizable for a wide range of trading strategies.
This indicator uses the standard Fibonacci retracement convention:
NTL\AutoFib([parameters,]).ex5
NTL\AutoFib(1,0,'0.0,0.3,0.5,0.618,0.762,1.0',3,0,4,8,50,100,0.0,10,250,45,'0.35,1',0,0,3,14).ex5,0,1,2,3,4,5
1.'0.0,0.3,0.5,0.618,0.762,1.0'.3.0 (no maximum).4.8.50.100.0.0 (disabled; additive difference used).10.250.45."min,max;min,max". Each pair defines a zone between two Fib levels. Maximum 5 zones.'0.35,1' (single zone from 35% to 100% retracement).0 (disabled).0 (disabled).3 (High).14.Trend Determination:
FibShift = 0 (no active Fib), then Trend = None.FibType = 1, then Trend = Bullish.FibType = 2, then Trend = Bearish.None.Signal Determination:
zonePrice = level0Price − (level0Price − level1Price) × zoneLevel, where zoneLevel is from ZoneLevelsCSV.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.
NTL\BB([parameters,]).ex5
NTL\BB(1,20,2.0).ex5,0,1,2,3
1.20.2.0.Trend Determination:
Bullish. Bearish.OverBought. OverSold.File: \Indicators\NTL\ChoCh.ex5
Description: Detects Change of Character (ChoCh) patterns which occur when price sweeps the 100% level of a prior AutoFib retracement pattern, signaling a potential market structure shift. A bullish ChoCh forms when price sweeps below a bearish fib's 100% level (swing low), indicating bearish-to-bullish reversal potential. A bearish ChoCh forms when price sweeps above a bullish fib's 100% level (swing high), indicating bullish-to-bearish reversal potential. The ChoCh type is always the inverse of the swept AutoFib type. Supports multi-timeframe analysis with configurable AutoFib and ChoCh timeframes.
NTL\ChoCh([parameters,]).ex5
NTL\ChoCh(1,0,'0.0,0.3,0.5,0.618,0.762,1.0',3,55,3,6,55,100,0.0,8,250,45,'0.35,1',0,0,3,14,500).ex5,0,1,2,3,4,5,6,7,8
1.0 (current timeframe).'0.0,0.3,0.5,0.618,0.762,1.0'.3.55.3.6.55.100.0.0.8.250.45.'0.35,1'.0.0.3 (High).1: Close3: High (uses high/low prices)14.500.0 for unlimited lookback.The Bullish ChoCh Data (Buffer 0) and Bearish ChoCh Data (Buffer 1) buffers use bit-packed 48-bit values:
Formation bar (Formed=1): Written by AddNew. All active bits populated. This is the pattern origin and the only bar where Type, Swept, and Size are stored. Formation bars are NOT mutated in-place after creation — Size is fixed at detection time. SweptAge starts at 1 because ChoCh formation IS the sweep event. Price buffers contain the swept zone upper and lower boundaries.
Relay waypoint (Formed=0): Written by UpdateExisting. Carries chain traversal and sweep propagation data only: Backlink (bits 0-11) is always written to enable chain traversal; SweptAge (bits 12-19) is incremented while active, 0 when expired; all other bits are zero. Price buffers are propagated from the previous bar while SweptAge > 0, and left as zero when SweptAge has expired.
Note: All ChoCh buffer data is real-time safe. Unlike LP and FVG, ChoCh does not mutate formation bars retroactively — size is fixed at detection time and there is no terminated flag. All fields are safe for EA/script trading decisions.
Signal Determination (ChoCh type is always the inverse of the swept AutoFib type):
Bullish (Bullish ChoCh).Bearish (Bearish ChoCh).Note: ChoCh does not produce Trend signals; it only produces Signal events on sweep detection.
Bullish ChoCh requires:
Bearish ChoCh requires:
A ChoCh is detected when:
Since ChoCh formation occurs at the moment the fib level is swept, the SweptAge counter starts at 1 when the pattern forms and increments each bar (up to 255). While SweptAge is non-zero, the swept price levels propagate forward in the corresponding price buffers: BullPriceHi/BullPriceLo for bullish patterns and BearPriceHi/BearPriceLo for bearish patterns. ChoCh tracks at most one sweep per side at a time; when SweptAge expires, price buffers are left as zero.
Price buffers (PriceHi/PriceLo) are conditionally written per side. On each bar, UpdateExisting propagates prices from the previous bar while SweptAge remains active. When SweptAge expires (reaches 255 or was already 0), price buffers are left as zero, explicitly signalling that no active sweep exists on this side.
Price source priority (latest write wins):
File: \Indicators\NTL\FVG.ex5
Description: Detects and tracks Fair Value Gap (FVG) patterns, which are
price imbalances formed when a gap exists between the high of an earlier bar
and the low of a later bar (bullish) or vice versa (bearish). Uses
dual-buffer architecture with separate backlink chains for bullish and bearish
patterns, enabling independent tracking and termination of each type. Patterns
are drawn as boxes and tracked until filled or terminated. Uses Average Bar
Height (ABH) for dynamic threshold calculations.
NTL\FVG([parameters,]).ex5
NTL\FVG(1,0,400,0.1,0.0,0.4,3.0,0.1,3,14).ex5,0,1,2,3,4,5,6
1.400. 0 for no maximum.0.1.0.0. 0 to disable wick validation.0.4.3.0.0.1 (10% fill terminates).3.14.false.9.Each data buffer (Buffer 0 and Buffer 1) contains three distinct bar types with different field populations:
Formation bar (formed=1): All 48 bits populated. This is the pattern origin. Size and terminated are mutated in-place on every subsequent bar as the pattern ages. FillValue and filled are updated when price intrudes into the zone. Price buffers receive the zone boundaries.
Relay waypoint (formed=0, filled=0): Only backlink (bits 0-11) and unfilledAge (bits 12-22) are populated; all other fields are zero. Written on every bar where an active chain exists. Price buffers are written conditionally: filled zone if a fill occurred, else latest active pattern's zone, else zero.
Fill bar (overwrites relay at current bar when fill occurs): Carries backlink, unfilledAge (from the next surviving pattern, or 0 if none remain), type, filled=1, and fillValue. Size and terminated are zero (not a formation bar). Price buffers receive the filled zone's boundaries.
Price buffers (Buffers 2-5) are conditionally written per side on each bar. Priority order (latest write wins):
The UnfilledAge field tracks how many bars an FVG pattern remains unfilled:
1. 1. 0 if no unfilled FVGs remain). 2,047 bars (clamped at overflow).Trend Determination:
Bullish. Bearish. Signal Determination:
Bullish (support zone touched). Bearish (resistance zone touched).Bullish FVG requires:
Bearish FVG requires:
An FVG box is filled when price intrudes into the zone beyond the MaxGapFillThreshold percentage:
(boxHi - currentBarLow) / boxHeight >= threshold — the
bar's low reaches into the zone from above. (currentBarHigh - boxLo) / boxHeight >= threshold — the
bar's high reaches into the zone from below.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.
NTL\HLines([parameters,]).ex5
NTL\HLines(1,'',800,100,'S2;R2',35,0.0,0.5,100).ex5,0,1
1.800.100.'S2;R2'.35.0.0.0.5.100.HLine Determination:
Bullish. Bearish.File: \Indicators\NTL\JCP.ex5
Description: Detects and categorizes Japanese candlestick patterns for market analysis and trading strategies.
NTL\JCP([parameters,]).ex5
NTL\JCP(1).ex5,0,1
1.The following are the supported candlestick patterns with their corresponding identifiers:
By using JCP1, traders can automate the identification of these patterns, improving decision-making and aligning their strategies with market sentiment.
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.
NTL\Keltner([parameters,]).ex5
NTL\Keltner(1,20,1,2.25).ex5,0,1,2,3
1.20.1. 0: Simple Averaging 1: Exponential Averaging 2: Smoothed Averaging 3: Linear Weighted Averaging2.25.Trend Determination:
Bullish. Bearish. None.OBOS Determination:
OverBought. OverSold.File: \Indicators\NTL\LP.ex5
Description: Identifies Buy Side Liquidity (BSL) and Sell Side Liquidity (SSL) zones based on pivot point analysis. BSL forms at swing highs where stop losses accumulate above price. SSL forms at swing lows where stop losses accumulate below price. Patterns are drawn as horizontal lines extending from the pivot point until price sweeps the level or the maximum width is reached. Uses pivot order and bar strength for pattern validation. Signals generated when liquidity pools are swept. Optional internal/external liquidity classification separates major HTF liquidity targets from micro consolidation liquidity using max price excursion normalised by ABH. The SweptExternalAge buffer independently tracks how many bars have elapsed since the most recent external liquidity sweep on each side.
NTL\LP([parameters,]).ex5
NTL\LP(1,0,800,2,6,12,400,14,7.0,0.0,2).ex5,0,1,2,3,4,5,6,7,8,9,10,11
1.0 (current timeframe).800.2.6.12.400.0 for no maximum.14.7.0.0 to disable classification.0.0 (no minimum).2 (Both).0 = Liquidity Only, 1 = Structure Only, 2 = Both.The BSL Data (Buffer 0) and SSL Data (Buffer 1) buffers use bit-packed 49-bit values:
Note: Size, PivotShift, Terminated, and External (on formation bars) are for drawing/internal use only and must not be used in EAs as they rely on future bar data. The following fields on relay bars are real-time safe for EA use: Backlink, SweptAge, Swept, and External.
The BSLSweptPrice (Buffer 4) and SSLSweptPrice (Buffer 5) buffers store the pivot price of the most recently swept LP on each side. When a sweep is detected, the swept pattern's pivot price is written to the current bar and propagated forward for as long as SweptAge is active (up to 255 bars). A non-zero value is only meaningful when SweptAge > 0 on the corresponding data buffer.
Use the SweptExternalAge buffer (Buffer 6) to determine whether the most recent sweep was of an external LP.
The SweptExternalAge buffer (Buffer 6) uses bit-packed 16-bit values to track the number of bars since the most recent external liquidity sweep for each side:
A value of 0 indicates no recent external sweep for that side. When an external LP is swept, the counter is set to 1 on the sweep bar, increments by 1 each subsequent bar, and drops to 0 after reaching max value (255).
SweptExternalAge operates independently from SweptAge in the data buffer. Non-external sweeps do not reset SweptExternalAge — the counter continues incrementing through non-external sweeps, counting only from the most recent external sweep. This allows EAs to test conditions like "has external liquidity been swept within the last 50 bars?" without chain traversal.
The StructureData buffer (Buffer 7) uses bit-packed 56-bit values to classify market structure pivots:
Note: PivotShift and Terminated are for drawing/internal use only and must not be used in EAs as they rely on future bar data. SweptAge and Swept are reserved for future use and currently always 0. The following fields on relay bars are real-time safe for EA use: Backlink, StructType, Formed, Strength, and ABHMultiples.
Structure classification works by comparing consecutive pivots:
The BOSData buffer (Buffer 9) uses bit-packed 15-bit values to record Break-of-Structure events:
Break-of-Structure is detected when the closing price breaks through a recent structure level. At most one BOS is detected per bar; bullish is checked first:
The BOSPrice buffer (Buffer 10) stores the price of the broken structure level on the bar where BOS is detected.
When LiquidityClassificationABH is set to a value greater than 0, the indicator classifies each LP as either internal or external liquidity based on maximum price excursion from the pivot level, normalised by ABH.
For BSL, excursion measures the deepest drop below the swing high (pivot price minus minimum low). For SSL, excursion measures the highest rise above the swing low (maximum high minus pivot price).
Classification is a one-way latch: once a pattern is classified as external, it remains external. Patterns may be promoted from internal to external on subsequent bars as price continues to move away from the pivot.
The external flag is propagated to relay bars: if any active pattern in the chain is classified as external, the relay bar's external bit is set to 1, providing O(1) lookup for external liquidity presence without chain traversal.
Trend Determination:
Bearish (SSL is checked first).Bullish.Signal Determination:
Bullish.Bearish.Bullish LP (Buy Side Liquidity) requires:
Bearish LP (Sell Side Liquidity) requires:
An LP line is swept when:
When swept, the SweptAge counter starts at 1 and increments each bar (up to 255), allowing the swept price level to propagate forward in the swept price buffers. If the swept LP was classified as external, the SweptExternalAge counter on the corresponding side of Buffer 6 is independently set to 1 and increments each bar (up to 255).
Read BSL and SSL swept prices at the current bar:
BSLSweptPrice = LP1(0, 4)
SSLSweptPrice = LP1(0, 5)
Check whether a BSL sweep is active (SweptAge > 0 means a sweep occurred within the last 255 bars):
BSLSweptAge = LP1(0, 0, 12, 255)
Check whether a SSL sweep is active:
SSLSweptAge = LP1(0, 1, 12, 255)
Read BSL SweptExternalAge (bars since last BSL external sweep, 0 if none):
BSLSweptExternalAge = LP1(0, 6, 0, 255)
Read SSL SweptExternalAge (bars since last SSL external sweep, 0 if none):
SSLSweptExternalAge = LP1(0, 6, 8, 255)
Check if external BSL liquidity was swept within the last 50 bars:
BSLSweptExternalAge = LP1(0, 6, 0, 255)
// True when BSLSweptExternalAge > 0 && BSLSweptExternalAge <= 50
Check if external SSL liquidity was swept within the last 50 bars:
SSLSweptExternalAge = LP1(0, 6, 8, 255)
// True when SSLSweptExternalAge > 0 && SSLSweptExternalAge <= 50
Combine to read the BSL swept price only when it was an external sweep:
BSLSweptExternalAge = LP1(0, 6, 0, 255)
BSLSweptPrice = LP1(0, 4)
// BSLSweptPrice represents an external sweep when BSLSweptExternalAge > 0
Combine to read the SSL swept price only when it was an external sweep:
SSLSweptExternalAge = LP1(0, 6, 8, 255)
SSLSweptPrice = LP1(0, 5)
// SSLSweptPrice represents an external sweep when SSLSweptExternalAge > 0
Read the structure type at the current bar (0=None, 1=HH, 2=LH, 3=HL, 4=LL):
StructType = LP1(0, 7, 20, 7)
Read the structure price at the current bar:
StructPrice = LP1(0, 8)
Read the bar strength of a structure point:
StructStrength = LP1(0, 7, 36, 255)
Check if a BOS formed on the current bar (BOSType: 1=Bullish, 2=Bearish):
BOSType = LP1(0, 9, 0, 3)
Read the BOS broken price level:
BOSPrice = LP1(0, 10)
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.
NTL\MA([parameters,]).ex5
NTL\MA(1,50,1,200,1).ex5,0,1,2
1.50.1. 0: Simple Averaging 1: Exponential Averaging 2: Smoothed Averaging 3: Linear Weighted Averaging0 to use a single moving average. 200.1. 0: Simple Averaging 1: Exponential Averaging 2: Smoothed Averaging 3: Linear Weighted AveragingTrend Determination:
Bullish. Bearish. None.Bullish. Bearish.Bullish. Bearish.Signal Determination:
Bullish and PreviousTrend = Bearish, then Signal = Bullish. Bearish and PreviousTrend = Bullish, then Signal = Bearish.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.
NTL\MACD([parameters,]).ex5
NTL\MACD(1,12,26,9).ex5,0,4
1.12.26.9.1. 0: Histogram Crosses Zero 1: MACD Line Crosses Zero 2: Signal Line Crosses MACD LineTrend Determination:
Bullish. Bearish.Signal Determination:
0 (Histogram Crosses Zero): Bullish and PreviousHistogram < 0, then Signal = Bullish. Bearish and PreviousHistogram > 0, then Signal = Bearish.1 (MACD Line Crosses Zero): Bullish. Bearish.2 (Signal Line Crosses MACD Line): Bullish and SignalLine < MACD and PreviousSignalLine > PreviousMACD then Signal = Bearish. Bearish and SignalLine > MACD and PreviousSignalLine < PreviousMACD then Signal = Bullish.File: \Indicators\NTL\Markets.ex5
Description: Calculates the opening and closing times for all major financial centers like Frankfurt, London, New York, Sydney, Tokyo. Its buffer stores market session data to track which markets are currently open and for how long they've been open in bars.
NTL\Markets([parameters,]).ex5
NTL\Markets(1).ex5,0
1.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.
NTL\OsMA([parameters,]).ex5
NTL\OsMA(1,12,26,9).ex5,0,1
1.12.26.9.Trend Determination:
Bullish. Bearish.Signal Determination:
Bullish and PreviousOSMA < 0, then Signal = Bullish. Bearish and PreviousOSMA > 0, then Signal = Bearish.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.
NTL\PL([parameters,]).ex5
NTL\PL(1,16408,4).ex5,0
1.0. 0: Daily (PERIOD_D1) 1: Weekly (PERIOD_W1) 2: Monthly (PERIOD_MN1)4. 0: None 1: Regular 2: Camarilla 3: Woodie 4: FibonacciFile: \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.
NTL\Indicators\PP([parameters,]).ex5
NTL\PP(1).ex5,0,1,2,3,4,5
1.6.Example
To read the high price of the nearest high pivot bar of order 2 use:
High(PP1(1,2,0,0xFFFFFF)+1)
+1 is necessary because PP1 returns the number of bars from shift offset 1, and High() is expecting an offset starting from the latest closed bar, 1. 0xFFFFFF is used to mask the lower 24 bits.
To read the low price of the nearest low pivot bar of order 2 use:
Low(PP1(1,2,24,0xFFFFFF)+1)
24 is used as the bit shift value to move bits 24-47 into bits 0-23.
To read the high price of the nearest high pivot bar of order 3 use:
High(PP1(1,3,0,0xFFFFFF)+1)
To read the low price of the nearest low pivot bar of order 3 use:
Low(PP1(1,3,24,0xFFFFFF)+1)
Notes: See Terms for an explanation of Pivot Strength and Pivot Order.
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.
NTL\PSAR([parameters,]).ex5
NTL\PSAR(1,0.02,0.2).ex5,0,1
1.0.02.0.2.Trend Determination:
Bullish. Bearish.Signal Determination:
Bullish and Previous High < Previous PSAR, then Signal = Bullish. Bearish and Previous Low > Previous PSAR, then Signal = Bearish.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.
NTL\RSI([parameters,]).ex5
NTL\RSI(1,14,1,70,30).ex5,0,1
1.14.PRICE_CLOSE (1).70.30.Overbought/Oversold Determination:
Overbought. Oversold. 0.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.
NTL\Scalper([parameters,]).ex5
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
1.10000.0.7.10000.0.3.0.6.10000.0.5.0.3.10000.0.7.10.1 (EMA). 0: Simple Moving Average (SMA) 1: Exponential Moving Average (EMA) 2: Weighted Moving Average (WMA) 3: Hull Moving Average (HMA)5.0.0 (no filter).5000.1 (enabled).1 (enabled).1 (Density only). 26 (Velocity, Direction, and MA).Signal Determination:
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.
NTL\Stoch([parameters,]).ex5
NTL\Stochastic(1,5,3,3,80,20).ex5,0,1,2
1.5.3.3.80.20.Overbought/Oversold Determination:
Overbought. Oversold. 0.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.
NTL\ST([parameters,]).ex5
NTL\ST(1,13,1.5).ex5,0,1
1.13.1.5.Trend Determination:
_trendBuffer).Bullish and PreviousTrend = Bearish, then Signal = Bullish. Bearish and PreviousTrend = Bullish, then Signal = Bearish. None.File: \Indicators\NTL\SwingMap.ex5 Description: Labels market structure swing points as Higher Highs (HH), Higher Lows (HL), Lower Highs (LH) and Lower Lows (LL) using pivot order detection with enforced high-low alternation. Measures swing significance via Average Bar Height (ABH) for dynamic height filtering. Detects when price sweeps through a structure level and tracks sweep propagation via SweptAge and SweptPrice buffers. Determines confirmed trend direction—bullish requires both a HH and HL to have formed; bearish requires both a LH and LL. Fires signals on swing formation events and exports structure events as GroundedEvents for AI consumption.
NTL\SwingMap([parameters,]).ex5
NTL\SwingMap(1,0,2,6,800,0,0,14,0.0).ex5,0,1,2,3,4,5,6,7,8
1.eSeriesTimeframe enum). 0 = current chart timeframe.0.2.0 for unlimited.6.800.0 to disable.0.0 for unlimited.0.14.0 to disable.0.0.Data buffers 0 and 1 contain three types of bar:
formed=1): Pattern origin. All bit fields populated including swingType, strength and trendType. PivotShift and terminated are mutated retroactively (future data—do not use in EA trading logic). Price buffer holds the pivot price.formed=0): Written each bar for chain navigation. Carries backlink (bits 0-11) and, during a swept window, sweptAge (bits 12-19). All other fields are zero. Price buffer holds the newest active pivot price (or 0 if none).Trend Determination:
Bullish.Bearish.None if no trend has been established).Signal Determination:
Signals fire on the bar where a new swing is formed:
Bullish.Bearish.Note: sweep events are not exported to SignalFlags. To detect sweeps, read the Swept bit (bit 23), SweptAge (bits 12-19) or the SweptPrice buffers (4 and 5) directly.
Swing High requires:
Swing Low requires:
A structure level is swept when price trades through the pivot price:
When swept, the formation bar's Swept and Terminated flags are set. On the current bar, SweptAge starts at 1 and increments each subsequent bar up to 255. The SweptPrice buffer propagates the swept pivot price forward for the duration of the SweptAge window.
A swing is also terminated (without being swept) when a newer same-type swing supersedes it.
{
"strength": "Pivot order (bars on each side of swing)",
"trend": "bullish, bearish, or undef"
}
Event IDs use format SM_<type>_<bars_ago> (e.g. SM_HH_014).
Read the swing type from High Data buffer at the current bar:
SwingType = SwingMap1(0, 0, 20, 3)
// 0=HH, 2=LH (high side only)
Read the swing type from Low Data buffer at the current bar:
SwingType = SwingMap1(0, 1, 20, 3)
// 1=HL, 3=LL (low side only)
Check whether a swing high formed on the current bar:
Formed = SwingMap1(0, 0, 22, 1)
Read the latest active swing high price at shift 0:
HighPrice = SwingMap1(0, 2)
Read the latest active swing low price at shift 0:
LowPrice = SwingMap1(0, 3)
Read the swept swing high price (non-zero while SweptAge > 0):
SweptHighPrice = SwingMap1(0, 4)
Read the swept swing low price (non-zero while SweptAge > 0):
SweptLowPrice = SwingMap1(0, 5)
Check whether a swing high has been swept:
Swept = SwingMap1(0, 0, 23, 1)
Read bars elapsed since sweep on high side (0 = not swept):
SweptAge = SwingMap1(0, 0, 12, 255)
Read confirmed trend at the current bar (from High Data buffer):
TrendType = SwingMap1(0, 0, 43, 3)
// 0=undefined, 1=bullish, 2=bearish
Read pivot strength at a swing bar:
Strength = SwingMap1(shift, 6)
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.
NTL\TLines([parameters,]).ex5
NTL\TLines(1,0,'S2;R2',10,5,5,2,0.70,400,20,800,0.4,0.2,100).ex5,0,1,2,3,4,5,6
1.0 to disable. 0.S or R followed by a minimum pivot order (1-8). Prefix with = for exact match. Example: S3;R3 requires both support and resistance pivots to be at least order 3. 'S2;R2'.10.5.5.2.1.0 to disable. 0.70.400.20.800.0.4.0.2.100.1 = trendline replaced by a closer, stronger line).1 = trendline replaced by a closer, stronger line).Trend Determination:
Bullish = Close Price is above the nearest trendline. Bearish = Close Price is below the nearest trendline.Signal Determination:
Bearish. Bullish.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.
NTL\TSI([parameters,]).ex5
NTL\TSI(1,13,21,8,25,-25,1).ex5,0,1,2
1.13.21.8.25.-25.1. 0: Zero Line Cross 1: Signal Line CrossTrend Determination:
Bullish. Bearish.Bullish and TSI >= OverboughtLevel, then OBOS = Overbought. Bearish and TSI <= OversoldLevel, then OBOS = Oversold.Signal Determination:
0 (Zero Line Cross): Bullish and PreviousTrend = Bearish, then Signal = Bullish. Bearish and PreviousTrend = Bullish, then Signal = Bearish.1 (Signal Line Cross): Bullish. Bearish.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.
Indicator(shift,buffer,lsr,mask)
0: Latest bar (unfinished). 1: Latest closed bar (finished). 2: Two bars ago, and so on.0 (no rotation).0xFFFF masks the lower 16 bits.ABH1(1,2)
Returns the average upper wick height (buffer 2) of the latest closed bar (shift 1).
JCP1(1,0,0,0xFFFF)
Returns the Japanese Candle Pattern Type (lower 16 bits of buffer 0) at the latest closed bar (shift 1).
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).
16-19 to positions 0-3 for easier access.0xF to capture only the lowest 4 bits.For indicators that support SignalFlags, consider using built-in functions like Signal(), Trend(), and OBOS() for convenience.
Example:
Signal('MA1') == Bullish ? Ask() : 0
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.
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.
Leverage both SignalFlag and TrendFlag for more robust strategies:
Long Entry Script: Trend('MA1') == Bullish && Signal('RSI1') == Bullish ? Ask() : 0
This script ensures both the Moving Average and RSI indicators confirm a bullish trend before entering a trade.
Indicator List The Indicator List box lists both the custom indicators and chart indicators for the current profile, that the EA can have access to. The list is refreshed when: the EA is first loaded; when a profile is loaded; or when the symbol or timeframe of the chart is changed. The EA assigns unique names to each indicator, so that two of the same indicator, with different settings, can be used, e.g. MA1, MA2
To conserve resources the EA connects with only the indicators that have been enabled for use by ticking the check box alongside the indicator's name. Enabled indicators have a "+" as the first character of their creation string.
To use an indicator in a script, or to include its data (grounded events or raw buffer values) in AI requests, you must first enable the indicator in the Indicator List.
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.
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:
.ex5 extension.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.1 or 0) indicating the indicator was created by an EA. Use 1 when creating an NTL indicator.Note: In an EAsiTrader preset file, indicator creation string settings that are prefixed with "+" indicate that the indicator is enabled and can be used in a script and/or exported to the AI. In the GUI, enabling an indicator automatically adds the "+" to its creation string. Indicators that are not enabled will not contribute grounded events or raw buffer data to AI requests, even if AI Mode is active.
These examples demonstrate how to dynamically configure indicators for different symbols, timeframes, and strategies.
Moving Average (MA1) for the Primary Market: NTL\MA(1,14,0).ex5
1 (true).14 (Moving Average period).0 (Simple Moving Average).Moving Average (MA1) for GBPUSD on H1 Timeframe: NTL\MA(GBPUSD:H1,1,20,1).ex5
GBPUSD.H1.1 (true).20 (Moving Average period).1 (Exponential Moving Average).Relative Strength Index (RSI1) for EURUSD on M5 Timeframe: NTL\RSI(EURUSD:M5,1,14).ex5
EURUSD.M5.1 (true).14 (RSI period).Bollinger Bands (BB1) for USDJPY on D1 Timeframe: NTL\BB(USDJPY:D1,1,20,2.0).ex5
USDJPY.D1.1 (true).20 (Bollinger Bands period).2.0.Moving Average (MA1) for the Primary Market on H1 Timeframe: NTL\MA(:H1,1,14,0).ex5
H1.1 (true).14 (Moving Average period).0 (Simple Moving Average).VAR0 can replace fixed parameters to allow dynamic optimization during testing.Indicators that support SignalFlags provide built-in functions for accessing signal data from the indicator's SignalFlags data buffer:
The direction functions offer a convenient way to check the current state. The bars-since functions are useful for trigger gating, e.g., only calling AI when a structural event occurred within the last N bars. Alternatively, the same SignalFlag bits can be accessed manually by reading from the indicator's SignalFlags data buffer using the indicator's function, as described in Reading Indicator Buffer Data.
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.
Bits 0-11 (0xFFF): Trend Bar Offset
0: Trend change occurred on the latest bar. 1: Trend change occurred 1 bar ago, and so on.Bits 12-23 (0xFFF): Bullish Signal Bar Offset
0: Bullish signal occurred on the latest bar. 1: Bullish signal occurred 1 bar ago, and so on. 4095 (0xFFF): No bullish signal has ever fired (sentinel value). Bits 24-35 (0xFFF): Bearish Signal Bar Offset
0: Bearish signal occurred on the latest bar. 1: Bearish signal occurred 1 bar ago, and so on. 4095 (0xFFF): No bearish signal has ever fired (sentinel value).Bits 36-42 (0x7F): SignalFlag Bits
1 = Bearish Trend 1 = Bullish Trend 1 = Bearish Signal 1 = Bullish Signal 1 = Overbought 1 = Oversold Bits 43-47 (0x15): Signal Data ID
0x15) identifying the Signal Data format.Bits 48-49:
To use your own indicators in EAsiTrader scripts follow these instructions:
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.
During Live Trading the EA internal clock is set to the value of the terminal's TimeTradeServer.
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.
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.
See the Learn EAsiScript User Guide.
Visit the EAsiScript Presets for examples you can download and use in EAsiTrader.
This section defines key concepts and terms used in EAsiTrader to ensure a clear understanding of its features and functionality.
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.
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.
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.
Average Bar Height. The ABH values are read from the ABH indicator. The Period of the ABH is determined by the indicator.
Rev:17.03.2026 12:00