Advanced Examples (Complete Strategies)
EAsiScript enables you to define sophisticated trading strategies through a clear and flexible syntax. At its core, EAsiScript uses expressions combining functions, operators, and indicators to drive trade decisions - from entry and exit points to stop losses and take profits. This guide will teach you step by step how to write effective scripts, with a focus on practical examples demonstrating key concepts like the ternary operator (?:), logical AND (&&), and logical OR (||) operators.
The examples provided in this document are for educational purposes only and intended to demonstrate the functionality and application of EAsiScript. They have been generated as teaching examples and have not been tested in live market conditions. Before using any trading strategy, whether manually created or AI-generated:
Northen Trading Labs assumes no responsibility for any financial losses or other consequences arising from the use of these examples. Traders should develop their own testing procedures and risk management rules before deploying any strategy in a live trading environment.
The examples focus on demonstrating EAsiScript syntax and capabilities. A complete trading strategy requires additional considerations including:
These examples introduce fundamental EAsiScript concepts through simple, clear trading logic. Each example focuses on one key scripting technique, proper syntax, and function usage. Starting with built-in functions and basic price conditions, they provide the building blocks for more complex strategies. While intentionally simple, they follow best practices for bar referencing and decision making.
This example demonstrates how to use the BarTrend function to identify price direction.
BarTrend(1) == Bullish ? Ask() : 0
Opens a buy trade when the last completed bar closes higher than it opened, showing a simple price direction filter.
BarTrend(1)
== Bullish
Ask()
0 if condition is not met (no trade)This basic example can be enhanced by adding consecutive bar checks or volume confirmation.
This example shows how to use high and low price functions to identify trading ranges.
High(1) - Low(1) < ATR1(1) ? Ask() : 0
Opens a buy trade when the last bar’s range is smaller than the average range, identifying potential consolidation periods.
High(1) - Low(1)
< ATR1(1)
Ask()
0 if condition is not met (no trade)Ensure the ATR indicator is enabled in the Indicator’s List before running this script.
This example shows how to detect lower highs using the HighestHigh function.
HighestHigh(3) < HighestHigh(6) ? Ask() : 0
Opens a buy trade when the highest high of the last 3 bars is lower than the highest high of the previous 3 bars, identifying a potential reversal point.
HighestHigh(3)
HighestHigh(6)
<
This basic pattern recognition can be used as a building block for more complex strategies.
This example introduces basic volume analysis using the Volume function.
Volume(1) > Volume(2) * 1.5 ? Ask() : 0
Opens a buy trade when the last bar’s volume is significantly higher than the previous bar’s volume, identifying increased market interest.
Volume(1)
Volume(2) * 1.5
Ask()
0 if condition is not met (no trade)Volume comparison provides a simple way to identify increased market activity.
This example demonstrates how to detect when price crosses above a specific value.
Close(1) > MA1(1,0) && Close(2) <= MA1(2,0) ? Ask() : 0
Opens a buy trade when price crosses above a moving average, showing basic cross detection.
Close(1) > MA1(1,0)
Close(2) <= MA1(2,0)
Ask()
0 if conditions are not met (no trade)Ensure the MA indicator is enabled in the Indicator’s List before running this script.
This example shows how to detect bars with strong bullish pivot patterns.
High(PP1(1,1,0,0xFFFFF)+1) <= High(1) ? Ask() : 0
Opens a buy trade when the current bar’s high is greater than or equal to the high of the nearest pivot bar, indicating potential bullish reversal.
PP1(1,1,0,0xFFFFF)
High(PP1(1,1,0,0xFFFFF)+1) <= High(1)
Ask()
0 if condition is not met (no trade)Ensure the PP indicator is enabled in the Indicator’s List before running this script.
This example shows how to check an indicator’s value against a threshold.
RSI1(1) < 30 ? Ask() : 0
Opens a buy trade when RSI moves below 30, demonstrating simple oversold level detection.
RSI1(1)
< 30
Ask()
0 if condition is not met (no trade)Ensure the RSI indicator is enabled in the Indicator’s List before running this script.
This example demonstrates how to filter trades based on spread size.
Spread(1) <= ATR1(1) * 0.1 ? Ask() : 0
Opens a buy trade when the spread is reasonable compared to average price movement, showing basic cost control.
Spread(1)
<= ATR1(1) * 0.1
Ask()
0 if condition is not met (no trade)Ensure the ATR indicator is enabled in the Indicator’s List before running this script.
This example shows how to filter trades based on time of day.
TimeOfDay(9,30) == 0 ? Ask() : 0
Opens a buy trade at exactly 9:30, demonstrating basic time-based entry rules.
TimeOfDay(9,30) == 0
Ask()
0 if condition is not met (no trade)Times are based on your broker’s server time. Verify the correct time zone for your trading session.
This example shows how to use an indicator’s built-in signals.
Signal('ST1') == Bullish ? Ask() : 0
Opens a buy trade when the SuperTrend indicator signals a bullish move, showing basic signal detection.
Signal('ST1')
== Bullish
Ask()
0 if condition is not met (no trade)Ensure the SuperTrend (ST1) indicator is enabled in the Indicator’s List before running this script.
These examples demonstrate how to construct more sophisticated trading strategies by combining multiple components and conditions. Each example shows a complete trade management approach, using all relevant scripts (entry, stop loss, trailing stop, take profit, and breakeven). While more complex than the Basic Examples, they maintain clear logic and focus on one key trading concept at a time. By studying these examples, you’ll learn how different EAsiScript components work together to create robust trading strategies and how various scripts interact during the lifecycle of a trade. You’ll also see practical implementations of risk management concepts and how to adapt your strategy to changing market conditions.
This example demonstrates a trend-following strategy that combines moving average trend with price position and dynamic trade management.
Trend('MA1') == Bullish && Close(1) > MA1(1,0) && Low(1) > MA1(1,0) ? Ask() : 0
MA1(1,0) - ATR1(1)
MA1(1,0) - ATR1(1) * 0.5
OrderPrice() + (OrderPrice() - SL()) * 2
OrderPrice() + ATR1(1)
Creates a trend-following strategy that enters when price shows clear bullish momentum above the moving average, with comprehensive trade management based on market volatility.
Trend('MA1') == Bullish: Confirms overall trend directionClose(1) > MA1(1,0): Price closed above MALow(1) > MA1(1,0): Full bar above MAEnsure both MA and ATR indicators are enabled in the Indicator’s List. The MA period affects both trend detection and trade management.
This example shows how to trade oversold conditions with confirmation and comprehensive trade management.
RSI1(1) < 30 && RSI1(1) > RSI1(2) && Close(1) > Open(1) ? Ask() : 0
Low(1) - ATR1(1)
Low(1) - (ATR1(1) * (RSI1(1) < 50 ? 1 : 0.5))
OrderPrice() + ATR1(1) * 3
RSI1(1) > 50 ? OrderPrice() : 0
Trades bullish reversals from oversold conditions, using RSI for entry confirmation and dynamic trade management based on both RSI and volatility conditions.
RSI1(1) < 30: Oversold conditionRSI1(1) > RSI1(2): RSI turning upClose(1) > Open(1): Bullish price actionEnsure both RSI and ATR indicators are enabled in the Indicator’s List. Consider adjusting RSI levels based on the specific instrument’s characteristics.
Close(1) > BB1(1,1) && Volume(1) > Volume(2) * 1.5 ? Ask() : 0
BB1(1,0) - ATR1(1)
BB1(1,0)
BB1(1,1) + (BB1(1,1) - BB1(1,0))
OrderPrice() + ATR1(1)
Trades breakouts from Bollinger Bands with volume confirmation, using the bands for dynamic trade management and profit targeting.
Close(1) > BB1(1,1): Price closes above upper bandVolume(1) > Volume(2) * 1.5: Increased volume confirms breakoutEnsure both Bollinger Bands and ATR indicators are enabled in the Indicator’s List. The strategy’s effectiveness depends on proper band settings for your timeframe.
HLines1(1) > 0 && HLineBreak('HLines1','ATR1') == 1 && Volume(1) > Volume(2) ? Ask() : 0
Low(1) - ATR1(1)
HLines1(1,0)
OrderPrice() + (OrderPrice() - SL()) * 2
High(1) > OrderPrice() + ATR1(1) ? OrderPrice() : 0
Trades breakouts from horizontal support/resistance levels with volume confirmation and level-based management.
HLines1(1) > 0: Valid resistance level existsHLineBreak('HLines1','ATR1') == 1: Bullish breakout through levelVolume(1) > Volume(2): Volume confirms breakEnsure HLines and ATR indicators are enabled in the Indicator’s List. Level quality depends on proper HLines settings.
Signal('RSI1') == Bullish && Close(1) > Close(2) ? Ask() : 0
LowestLow(3) - ATR1(1)
RSI1(1) > 70 ? High(1) - ATR1(1) * 0.5 : Low(1) - ATR1(1)
OBOS('RSI1') == -1 ? Bid() : OrderPrice() + ATR1(1) * 3
RSI1(1) > 60 ? OrderPrice() : 0
Trades momentum signals with RSI, using overbought/oversold conditions for trade management.
Signal('RSI1') == Bullish: RSI momentum signalClose(1) > Close(2): Price confirmationEnsure RSI and ATR indicators are enabled in the Indicator’s List. Adjust RSI levels to suit your instrument’s characteristics.
Signal('AutoFib1') == Bullish && Ask() > FibPrice('AutoFib1',0.618) ? Ask() : 0
FibPrice('AutoFib1',0.382) - ATR1(1)
FibPrice('AutoFib1',0.618)
FibPrice('AutoFib1',1.0)
FibPrice('AutoFib1',0.786)
Trades bullish moves from Fibonacci retracement levels, using Fib levels for trade management.
Signal('AutoFib1') == Bullish: Fib pattern signalAsk() > FibPrice('AutoFib1',0.618): Price above 0.618 levelEnsure AutoFib indicator is enabled in the Indicator’s List. Success depends on proper Fibonacci pattern identification.
Trend('ST1') == Bearish && Low(1) < ST1(1,0) && Close(1) > Open(1) ? Ask() : 0
Low(1) - ATR1(1)
ST1(1,0)
OrderPrice() + (OrderPrice() - SL()) * 2
Trend('ST1') == Bullish ? OrderPrice() : 0
Attempts to catch reversals by entering when price shows strength (bullish close) while still in a bearish SuperTrend, with confirmation from price testing the SuperTrend level.
Trend('ST1') == Bearish: Confirms we’re in bearish trendLow(1) < ST1(1,0): Price has tested SuperTrend levelClose(1) > Open(1): Shows bullish pressureStoch1(1,0) > Stoch1(1,1) && Stoch1(2,0) <= Stoch1(2,1) && Stoch1(1,0) < 30 ? Ask() : 0
Low(1) - ATR1(1)
Low(1) - (ATR1(1) * (Stoch1(1,0) < 50 ? 1 : 0.5))
OBOS('Stoch1') == -1 ? Bid() : OrderPrice() + ATR1(1) * 3
Stoch1(1,0) > 50 ? OrderPrice() : 0
Trades Stochastic crossovers in oversold territory, with adaptive trade management based on oscillator position.
Stoch1(1,0) > Stoch1(1,1): %K crosses above %DStoch1(2,0) <= Stoch1(2,1): Confirms new crossStoch1(1,0) < 30: In oversold territoryEnsure Stochastic and ATR indicators are enabled in the Indicator’s List.
ADX1(1,0) > 25 && ADX1(1,2) > ADX1(1,1) && Close(1) > Open(1) ? Ask() : 0
Low(1) - (ATR1(1) * (ADX1(1,0) > 40 ? 2 : 1))
Low(1) - ATR1(1) * (ADX1(1,0)/50)
OrderPrice() + (ATR1(1) * (ADX1(1,0)/20))
High(1) > OrderPrice() + ATR1(1) ? OrderPrice() : 0
Trades strong trends identified by ADX, with strength-adjusted trade management.
ADX1(1,0) > 25: Strong trend existsADX1(1,2) > ADX1(1,1): +DI greater than -DI (bullish directional movement)Close(1) > Open(1): Bullish price actionEnsure ADX and ATR indicators are enabled in the Indicator’s List.
MACD1(1,0) < MACD1(3,0) && Low(1) > Low(3) && MACD1(1,0) < 0 && Close(1) > Open(1) ? Ask() : 0
LowestLow(5) - ATR1(1)
MACD1(1,0) > 0 ? Low(1) - ATR1(1) * 0.5 : Low(2) - ATR1(1)
MACD1(1,0) > MACD1(2,0) ? OrderPrice() + ATR1(1) * 3 : OrderPrice() + ATR1(1) * 2
MACD1(1,0) > 0 ? OrderPrice() : 0
Trades bullish divergence between price and MACD, with momentum-based trade management.
MACD1(1,0) < MACD1(3,0): Lower MACD lowLow(1) > Low(3): Higher price lowMACD1(1,0) < 0: Below zero lineClose(1) > Open(1): Bullish confirmationEnsure MACD and ATR indicators are enabled in the Indicator’s List. Consider adjusting the lookback period (3 bars) based on your timeframe.
These examples present fully-formed trading strategies that demonstrate how to combine multiple components into comprehensive trading systems. Each example includes complete script sets with sophisticated entry conditions, dynamic trade management, and risk controls. They show how to integrate multiple timeframes, combine various indicators, and adapt to changing market conditions. While more complex than the Intermediate Examples, they maintain clear logic and documentation to serve as templates for both manual adaptation and AI-assisted customization. These strategies also demonstrate different trading approaches including trend-following, mean reversion, breakout trading, and pattern recognition, providing a broad foundation for developing your own advanced trading systems.
VAR0=2;1,1.5,2,2.5,3 // SL ATR multiplier VAR1=4;2,3,4,5,6 // TP ATR multiplier
NTL\MA(1,50,1).ex5,0,1,2 NTL\RSI(1,14,1,70,30).ex5,0,1 NTL\RSI(:H1,1,14,1,70,30).ex5,0,1 NTL\ATR(1,14).ex5,0
TimeOfDay(8,0,17,0) == 0 && Trend('MA1') == Bullish && Close(1) > MA1(1,0) && RSI1(1) > 50 && RSI2(1) > 50 ? Ask() : 0
MA1(1,0) - (ATR1(1) * VAR0)
MA1(1,0) - (ATR1(1) * (RSI1(1) > 70 ? 0.5 : 1))
OrderPrice() + (ATR1(1) * VAR1 * (RSI2(1) > 70 ? 1 : 2))
RSI1(1) > 60 && RSI2(1) > 60 ? OrderPrice() : 0
TimeOfDay(17,0) == 1 || (RSI1(1) < 40 && RSI2(1) < 40) ? Bid() : 0
A comprehensive trend-following strategy for EURUSD that aligns M15 and H1 timeframes with momentum confirmation and time-based filters, using adaptive trade management based on market conditions.
TimeOfDay(8,0,17,0) == 0: Trading windowTrend('MA1') == Bullish: Current timeframe trendClose(1) > MA1(1,0): Price above MARSI1(1) > 50: M15 momentumRSI2(1) > 50: H1 momentumAll indicators must be enabled (’+’ prefix) in the preset file. Strategy performs best during major session overlaps.
VAR0=3;1.5,2,2.5,3,3.5,4 // TP extension multiplier
NTL\ATR(1,14).ex5,0 NTL\PP(1).ex5,0,1,2,3,4,5 NTL\BB(1,20,2.0).ex5,0,1,2,3
High(PP1(1,2,0,0xFFFFF)+1) < High(1) && OBOS('BB1') == 1 && Close(1) > Open(1) ? Ask() : 0
Low(PP1(1,2,20,0xFFFFF)+1) - ATR1(1)
Low(2) - ATR1(1) * (BB1(1,0) < BB1(2,0) ? 1.5 : 1)
BB1(1,1) + ATR1(1) * VAR0
High(1) > OrderPrice() + ATR1(1) * 2 ? OrderPrice() : 0
OBOS('BB1') == -1 || Close(1) < BB1(1,0) ? Bid() : 0
Identifies potential reversals in GBPUSD using pivot points and Bollinger Band oversold conditions, with adaptive trade management based on volatility.
High(PP1(1,2,0,0xFFFFF)+1) < High(1): New high above pivot pointOBOS('BB1') == 1: Oversold conditionClose(1) > Open(1): Bullish confirmationStrategy performs best during periods of high volatility but clear price structure. Most effective in the early London session when GBPUSD typically shows strong directional moves.
VAR0=0.5;0.3,0.4,0.5,0.6,0.7 // Range size filter (in ATR) VAR1=2;1.5,2,2.5,3 // Breakout target multiplier
NTL\ATR(1,14).ex5,0 NTL\ABH(1,14,3).ex5,0,1 NTL\PP(1).ex5,0,1,2,3,4,5
TimeOfDay(4,0) == 1 && (High(1) - Low(1)) < ATR1(1) * VAR0 && Volume(1) > Volume(2) ? Ask() : 0
Low(1) - ATR1(1)
Low(2) - ATR1(1) * (ABH1(1,0) > ABH1(2,0) ? 1.5 : 1)
OrderPrice() + (ATR1(1) * VAR1)
High(1) > OrderPrice() + ATR1(1) ? OrderPrice() : 0
TimeOfDay(8,0) == 1 || PP1(1,0) > 0 ? Bid() : 0
Capitalizes on USDJPY’s characteristic early Asian session consolidation followed by breakout moves, using time filters and volatility measures.
TimeOfDay(4,0) == 1: After 04:00 (early Asian session)(High(1) - Low(1)) < ATR1(1) * VAR0: Compressed rangeVolume(1) > Volume(2): Volume confirmationStrategy targets the characteristic USDJPY behavior during Asian hours. Most effective during Tuesday-Thursday Asian sessions when liquidity is optimal.
VAR0=2.5;1.5,2.0,2.5,3.0,3.5 // Range multiplier VAR1=1.5;1.0,1.5,2.0,2.5 // Risk-reward ratio
NTL\ATR(1,14).ex5,0 NTL\BB(1,20,2.0).ex5,0,1,2,3 NTL\MA(1,50,1).ex5,0,1,2
TimeOfDay(7,0) == 1 && High(1) > HighestHigh(Range(6,0,"",D1)/Point) && Trend('MA1') == Bullish ? Ask() : 0
Low(1) - ATR1(1) * VAR0
BB1(1,0) - ATR1(1)
OrderPrice() + ((OrderPrice() - SL()) * VAR1)
High(1) > OrderPrice() + ((OrderPrice() - SL()) * 0.5) ? OrderPrice() : 0
TimeOfDay(16,0) == 1 || (BB1(1,1) < BB1(2,1) && Close(1) < Open(1)) ? Bid() : 0
Takes advantage of the typical London session breakout in EURGBP, entering on breaks of the Asian range with trend confirmation.
TimeOfDay(7,0) == 1: After London session openHigh(1) > HighestHigh(Range(6,0,"",D1)/Point): Breaks Asian rangeTrend('MA1') == Bullish: Trend confirmationBest results during Tuesday-Thursday when both London and European markets are fully active. Avoid trading on UK and European bank holidays.
VAR0=2;1.5,2,2.5,3 // Initial stop multiplier VAR1=0.5;0.3,0.4,0.5,0.6,0.7 // Trailing factor
NTL\MACD(1,12,26,9).ex5,0,1,2,3,4 NTL\ATR(1,14).ex5,0 NTL\RSI(1,14,1,70,30).ex5,0,1
MACD1(1,0) > 0 && MACD1(2,0) <= 0 && RSI1(1) > 50 && Mid() < Round(Mid()) + 0.01 ? Ask() : 0
Low(1) - ATR1(1) * VAR0
Low(1) - ATR1(1) * (MACD1(1,0) > MACD1(2,0) ? VAR1 : VAR1 * 2)
Round(Mid()) + 0.01 + (ATR1(1) * 2)
MACD1(1,0) > MACD1(1,1) * 2 ? OrderPrice() : 0
MACD1(1,0) < 0 || RSI1(1) > 70 ? Bid() : 0
Takes advantage of USDCAD’s tendency to react around ‘double-zero’ levels (e.g., 1.3200, 1.3300), combining it with momentum confirmation.
MACD1(1,0) > 0 && MACD1(2,0) <= 0: MACD crosses zeroRSI1(1) > 50: Momentum confirmationMid() < Round(Mid()) + 0.01: Near round numberStrategy performs best during North American session when USDCAD typically shows clearest reactions to psychological levels. Avoid during Canadian economic news releases.
VAR0=15;10,15,20,25,30 // Channel lookback period VAR1=1.5;1.0,1.5,2.0,2.5 // Risk-reward ratio
NTL\ATR(1,14).ex5,0 NTL\Keltner(1,20,1,2.25).ex5,0,1,2,3
High(1) > HighestHigh(VAR0) && Volume(1) > Volume(2) * 1.5 && High(1) > Keltner1(1,1) ? Ask() : 0
Keltner1(1,0) - ATR1(1)
Keltner1(1,0) - (ATR1(1) * 0.5)
OrderPrice() + ((OrderPrice() - SL()) * VAR1)
High(1) > HighestHigh(VAR0) + ATR1(1) ? OrderPrice() : 0
Close(1) < Keltner1(1,0) || Low(1) < LowestLow(5) ? Bid() : 0
Trades breakouts from established price channels in AUDUSD, using volume confirmation and Keltner Channels for validation and management.
High(1) > HighestHigh(VAR0): Breaks channel highVolume(1) > Volume(2) * 1.5: Volume surgeHigh(1) > Keltner1(1,1): Above Keltner upper bandMost effective during Asian-London crossover when AUDUSD often forms and breaks clear channels. Avoid during RBA announcements and significant Chinese economic data releases.
VAR0=2;1.5,2,2.5,3 // ATR multiplier for targets
NTL\ATR(1,14).ex5,0 NTL\ABH(1,14,3).ex5,0,1
TimeOfDay(9,0) == 1 && High(1) > HighestHigh(4) && Volume(1) > Volume(2) ? Ask() : 0
LowestLow(4) - ATR1(1)
Low(1) - (ABH1(1,0) * (High(1) > HighestHigh(3) ? 1 : 2))
OrderPrice() + (ATR1(1) * VAR0)
High(1) > OrderPrice() + ATR1(1) ? OrderPrice() : 0
TimeOfDay(16,0) == 1 || Low(1) < LowestLow(3) ? Bid() : 0
Trades breakouts from the London session opening range in EURJPY, using adaptive targets based on volatility.
TimeOfDay(9,0) == 1: After the opening range hourHigh(1) > HighestHigh(4): Breaks opening hour’s highVolume(1) > Volume(2): Volume confirmationDesigned for London session volatility in EURJPY. Best results Tuesday-Thursday, avoid during major Japanese holidays or during BOJ/ECB announcements.
VAR0=3;2,3,4,5 // Minimum pattern strength VAR1=2;1.5,2,2.5,3 // Risk multiplier
NTL\ATR(1,14).ex5,0 NTL\JCP(1).ex5,0,1 NTL\BB(1,20,2.0).ex5,0,1,2,3
Signal('JCP1') == Bullish && OBOS('BB1') == 1 && High(1) > High(2) ? Ask() : 0
Low(1) - (ATR1(1) * VAR1)
Low(1) - (ATR1(1) * (BB1(1,0) < BB1(2,0) ? 2 : 1))
BB1(1,1) + ATR1(1) * 2
Close(1) > BB1(1,1) ? OrderPrice() : 0
Signal('JCP1') == Bearish || Close(1) < BB1(1,0) ? Bid() : 0
Combines Japanese candlestick patterns with Bollinger Band oversold conditions in USDCHF, focusing on pattern-based reversals.
Signal('JCP1') == Bullish: Bullish candlestick patternOBOS('BB1') == 1: Oversold conditionHigh(1) > High(2): Pattern confirmationMost effective during European session when USDCHF typically shows clearest pattern formations. Avoid during SNB announcements and major Swiss economic releases.
VAR0=1.5;1.0,1.5,2.0,2.5 // ATR multiplier for stops VAR1=2.5;2.0,2.5,3.0,3.5 // Target multiplier
NTL\MA(:H4,1,10,1,20,1).ex5,0,1,2 NTL\MA(:H4,1,50,1).ex5,0,1 NTL\BB(1,20,2.0).ex5,0,1,2,3 NTL\ATR(1,14).ex5,0
MA1(1,0) > MA1(1,1) && MA1(1,1) > MA2(1,0) && Close(1) > BB1(1,1) ? Ask() : 0
Low(1) - (ATR1(1) * VAR0)
MA1(1,1) - (ATR1(1) * (MA1(1,0) > MA1(2,0) ? 0.5 : 1))
OrderPrice() + (ATR1(1) * VAR1 * (BB1(1,1) > BB1(2,1) ? 1.5 : 1))
High(1) > OrderPrice() + ATR1(1) ? OrderPrice() : 0
MA1(1,0) < MA1(1,1) || Close(1) < BB1(1,0) ? Bid() : 0
Uses three moving averages in correct alignment with Bollinger Band confirmation for trend trading in GBPUSD.
MA1(1,0) > MA1(1,1): 10-period MA above 20-period MAMA1(1,1) > MA2(1,0): 20-period MA above 50-period MAClose(1) > BB1(1,1): Price above upper bandStrategy works best during trending phases of GBPUSD H4. Avoid during major UK/US news releases and during periods of low volatility.
VAR0=0.5;0.3,0.4,0.5,0.6,0.7 // Range comparison factor VAR1=1.5;1.0,1.5,2.0,2.5 // Risk multiple for target
NTL\ATR(1,14).ex5,0 NTL\BB(1,20,2.0).ex5,0,1,2,3 NTL\HLines(1,'',800,64,'S2;R2',2,0.3,0.5,100).ex5,0,1
(High(3) - Low(3)) < ATR1(1) * VAR0 && Signal('HLines1') == Bullish && OBOS('BB1') == 1 ? Ask() : 0
Low(3) - ATR1(1)
BB1(1,0) - (ATR1(1) * 0.5)
OrderPrice() + ((OrderPrice() - SL()) * VAR1)
High(1) > OrderPrice() + ATR1(1) ? OrderPrice() : 0
OBOS('BB1') == -1 || Signal('HLines1') == Bearish ? Bid() : 0
Trades contractions in price range near support levels, combining HLines support/resistance with Bollinger Band conditions.
(High(3) - Low(3)) < ATR1(1) * VAR0: Range contractionSignal('HLines1') == Bullish: Support level signalOBOS('BB1') == 1: Oversold conditionBest suited for NZDUSD H4 during Asian/early London hours when price tends to respect ranges more clearly. Avoid during major NZ/US news releases.
Follow these best practices to ensure your scripts are clear, consistent, and effective:
Replace raw values like 1 or -1 with the predefined variables Bullish and Bearish:
Bullish = 1: Indicates a buy signal or bullish trend.Bearish = -1: Indicates a sell signal or bearish trend.Example: Signal('MA1') == Bullish ? Ask() : 0
Leverage the Point Variable for Scaling:
Point to ensure they are scaled correctly according to the symbol’s price units.Example: ATR1(1) > 15 ? Low(1) - 20 * Point : Low(1) - 10 * Point
Explicitly Define Shifts for Functions:
Close, Open, High, and Low require a shift parameter. The default is 1, but specifying it explicitly improves clarity.Example: Close(1) > Open(1) ? Ask() : 0
Avoid Invalid Functions:
SL() instead of invalid ones like StopLoss().Ask(), Bid(), SL(), Signal(), Trend().StopLoss(), Price().Combine Indicators and Price Data:
Example: Trend('MA1') == Bullish && Close(1) > Open(1) ? Ask() : 0
Before diving into script writing, it’s helpful to understand some practical approaches that can make your development process smoother and more effective. While the Best Practices section covers the technical aspects of writing scripts, these tips focus on the development process itself, common pitfalls to avoid, and strategies for testing and implementing your trading logic. Whether you’re writing your first script or developing complex strategies, these guidelines will help you build more reliable and maintainable trading systems.
EAsiScript enables you to leverage artificial intelligence for creating preset files and developing trading strategies. By providing AI with your strategy requirements and the EAsiTrader documentation, you can generate compliant preset files that are ready for testing and optimization. This approach combines the efficiency of AI with your trading expertise, allowing you to rapidly develop and refine strategies while maintaining full control over their implementation and risk management.
The key to successful AI-assisted development is providing clear strategy requirements and ensuring the AI has access to all necessary documentation. This section will guide you through the process of preparing your requirements, working with AI to generate preset files, and properly testing the resulting strategies.
Before engaging with AI, clearly define the specifics of your trading strategy:
Provide AI with the foundational documentation:
These guides contain all the information AI needs to generate accurate scripts and ensure compliance with EAsiTrader’s requirements.
Provide your strategy requirements in a clear, structured format:
.set extension (e.g., TrendFollowing.set)MQL5\Files\EAsiTrader.set file in this directoryEAsiTrader’s AI system can work alongside EAsiScript in three distinct patterns, each suited to different levels of AI involvement. Understanding these patterns helps you choose the right approach for your strategy and write effective AI prompts.
Scripts control all entries and exits. The AI periodically assesses the market and provides a directional bias, risk mode, and regime classification. Script-generated signals that conflict with the AI’s assessment are filtered out (suppressed). Use this pattern when you have a well-tested script strategy and want the AI to act as a safety net — blocking trades during unfavourable conditions without changing the core logic.
Scripts handle: Entry signals, stop loss, take profit, breakeven, exit logic
AI handles: Periodic market assessment used to filter (block or allow) script signals
Permissions: AIAllow* flags are ignored — the AI cannot open, close, or modify trades
Scripts generate entry signals, but every signal must be approved by the AI before execution. Optionally, the AI can also manage open positions — trailing stops, modifying take profit, or closing positions early based on changing conditions. Use this pattern when you want script-based entries with AI quality control and optional active position management.
Scripts handle: Entry signal generation, initial stop loss, take profit, breakeven
AI handles: Approving/rejecting each entry signal, optionally managing open positions
Permissions: AIAllowOpen = false, AIAllowPlaceOrders = false (entries always come from scripts). Enable AIAllowClose, AIAllowModifySL, AIAllowModifyTP for position management.
The AI has full control over trade decisions. Entry and exit scripts are typically empty. The AI uses grounded events from indicators (CHoCH, FVG, LP, etc.), OHLC data, and news feeds to make all trading decisions. Strategy Instructions guide the AI’s decision-making. Use this pattern for strategies that rely on complex market context that is difficult to express in scripts alone.
Scripts handle: Usually empty. Can optionally define fallback stops or AI Trigger Script conditions.
AI handles: Opening, closing, and modifying positions based on Strategy Instructions
Permissions: Enable each AIAllow* flag for actions the AI should control. At minimum, AIAllowOpen or AIAllowClose must be true.
Scripts can read the AI’s current assessment using AI functions. These allow scripts to incorporate the AI’s bias, confidence, regime, and risk assessment into their logic:
AiIsBullish() == 1 && Close(1) > MA1(1,0) ? Ask() : 0 — only enter long when AI bias is bullishAiCombinedMultiplier(1) * 0.01 — modulate lot size based on AI assessmentAiIsRanging() == 1 ? Bid() : 0 — exit when AI detects a regime changeAiIsValid() == 1 — ensure AI data is current before acting on itImportant: In Gated Trading mode, entry scripts must be AI-blind — they must not reference any
Ai*()functions. AI functions may still be used in non-entry scripts (exit, lots, trailing stop, breakeven) and in entry scripts for Filter Signals mode. See Gated Trading in Detail.
See the EAsiScript User Guide → AI Functions section for the complete function reference and usage examples.
The AI Trigger Script (InpTradeTool_ScriptAITrigger) controls when AI refresh requests are sent, helping manage API costs. It is evaluated only after the refresh interval has elapsed, the current assessment has expired, and there are no open positions. Common uses include session time gates, volatility filters, and trend confirmation checks. See the EAsiScript User Guide → AI Trigger Script Examples for practical examples.
When generating AI-enabled presets, the AI Section of the .set file must be configured to match the chosen mode. The EAsiTrader User Guide → Rules for Creating Main Preset Files (Rules 11–14) specify the exact requirements for each mode, including which permissions to enable and how to encode Strategy Instructions and URLs. The EAsiTrader AI User Guide provides configuration recipes and strategy prompt templates for each mode.
These examples demonstrate effective AI prompts for generating EAsiTrader preset files and trading strategies. Each example includes the exact text you should give to the AI, formatted with specific requirements and the mandatory preset file compliance instructions.
When providing any of these example prompts to AI, you MUST include these exact instructions as part of your prompt:
“The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.”
⚠️ WARNING: Omitting these instructions from your prompt will likely result in invalid preset files that will not work correctly in EAsiTrader. Remember that the AI cannot see or access these instructions unless you explicitly include them in your prompt.
Each example below shows a complete prompt that you can copy and use directly with AI. Pay attention to how the required instructions are integrated with the strategy specifications in each prompt.
Copy this complete prompt:
"Create an EAsiScript preset file for a strategy based on RSI levels.
The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Entry: Go long when RSI crosses above 30, go short when RSI crosses below 70
- Stop Loss: 2 times ATR below/above entry price for long/short trades
- Take Profit: Fixed at 50 points for all trades
- Exit: Close trade if the opposite RSI condition occurs
- Execution: Runs on EURUSD on the M30 timeframe"
Copy this complete prompt:
"Please create an EAsiScript Preset File for a strategy using multiple
moving averages.The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Entry: Enter when fast MA crosses above slow MA with RSI confirmation
- Stop Loss: Set below recent swing low with ATR buffer
- Take Profit: Use ATR to calculate 3:1 reward:risk ratio
- Exit: Exit if MA cross reverses or RSI conditions change
- Execution: GBPUSD, H1 timeframe"
Copy this complete prompt:
"Generate an EAsiScript Preset File for a complete trading system.
The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Markets: EURUSD, Primary M15, Secondary H1
- Entry Conditions:
- H1 trend alignment (using MA)
- M15 momentum confirmation (using RSI)
- Volume confirmation
- Risk Management:
- Dynamic ATR-based stops
- Trailing stop after breakeven
- Multiple take profit targets
- Time Filters: Active during London/NY overlap
- Position Sizing: Risk 1% per trade"
Copy this complete prompt:
"Generate an EAsiScript Preset File for a Bollinger Band breakout
strategy.The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Entry: Go long if price breaks above upper band with volume surge
- Stop Loss: Use trailing stop based on 2 ATR
- Take Profit: Use 5% of account equity as target profit
- Exit: Close position if price re-enters the bands
- Execution: GBPUSD, H1 timeframe, with risk of 1% per trade"
Copy this complete prompt:
"Help me create an EAsiScript Preset File for a mean reversion
strategy.The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Entry: Enter long when RSI below 30 and returns above it
- Stop Loss: Place at low of last 5 bars
- Take Profit: Target twice the stop-loss distance
- Exit: Exit on MA cross or RSI above 70
- Execution: USDJPY, M15 timeframe"
Copy this complete prompt:
"Create a preset for trading the Asian session range breakout.
The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Symbol: USDJPY M30
- Range Definition: 00:00-03:00 Tokyo
- Entry: Break of range high/low after range formation
- Filters: Minimum range size using ATR
- Risk: Dynamic based on range size
- Exit: Before Tokyo lunch or at 1:1 reward:risk"
Copy this complete prompt:
"Create a preset for trading key support/resistance levels.
The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Symbol: EURGBP H1
- Indicator: HLines for dynamic S/R levels
- Entry: Reversal candle at S/R with RSI confirmation
- Stop Loss: Beyond the S/R level plus buffer
- Take Profit: Distance to next S/R level
- Filters: Minimum distance between levels using ATR
- Time: Active during London session only"
Copy this complete prompt:
"Generate a preset for trading psychological price levels.
The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Symbol: USDCAD H4
- Entry: Reversal at 00 levels (1.3200, 1.3300, etc.)
- Confirmation: MACD cross and minimum volume
- Stop Loss: ATR-based beyond the level
- Management: Trail stop to breakeven after 20 pips
- Risk: 1% per trade, scaled by distance to stop"
Copy this complete prompt:
"Create an EAsiScript preset file with AI Filter Signals mode enabled.
The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Symbol: EURUSD H1
- Entry: Long when RSI crosses above 40 and MA trend is bullish; short when RSI crosses below 60 and MA trend is bearish
- Stop Loss: 2x ATR below/above entry
- Take Profit: 2R (twice the risk)
- Breakeven: Move stop to entry after 1R profit
- Exit: Close on opposite MA trend signal
- Trading Hours: 08:00–21:00 server time
- Close at end of day: Yes
AI Configuration
- AI Mode: Filter Signals (mode 2) — AI filters script signals using its directional bias
- AI Trigger Script: Only allow AI requests during 08:00–21:00 (London/NY session)
- Strategy Instructions: Focus on trend continuation. Set risk_mode to ‘reduced’ during first/last hour. Set risk_mode to ‘avoid’ when regime is ‘ranging’.
- Additional Timeframes: H4 for broader context
- Confidence Threshold: 0.40
- Refresh Interval: 10 minutes
- URLs: Include DailyForex RSS and FXStreet RSS news feeds
- Permissions: Leave all AIAllow flags at defaults (they are ignored in Filter Signals mode)
Ensure the AI Section settings comply with Rule 11 for Filter Signals mode."
Copy this complete prompt:
"Create an EAsiScript preset file with AI Gated Trading mode enabled,
where the AI also manages open positions.The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Symbol: GBPUSD H1
- Entry: Long when price closes above upper Bollinger Band with volume spike (1.5x previous bar); short when price closes below lower band with volume spike. Entry scripts must be AI-blind (no
Ai*()functions) — the AI evaluates each signal via the gate mechanism.- Stop Loss: Middle Bollinger Band minus 1 ATR (longs) or plus 1 ATR (shorts)
- Take Profit: 2x the band width from entry
- Breakeven: After 1 ATR profit
- Trading Hours: 08:00–20:00 server time
- Max trades per day: 2
AI Configuration
- AI Mode: Gated Trading (mode 3) — AI must approve each entry, and also manages positions
- Strategy Instructions: Approve breakout entries only when CHoCH confirms direction. Set risk_mode to ‘avoid’ if no recent CHoCH supports signal. Trail stops to break-even after 1R. Close early if CHoCH fires in opposite direction.
- Additional Timeframes: M15 for fine-grained structure
- Confidence Threshold: 0.40
- Refresh Interval: 15 minutes
- URLs: Include DailyForex RSS and FXStreet RSS news feeds
- Permissions: AIAllowOpen=false, AIAllowPlaceOrders=false (entries from scripts only). AIAllowClose=true, AIAllowModifySL=true (AI manages positions). AIAllowModifyTP=false, AIAllowCancelOrders=false.
Ensure the AI Section settings comply with Rule 11 for Gated Trading mode — specifically that AIAllowOpen and AIAllowPlaceOrders are false."
Copy this complete prompt:
"Create an EAsiScript preset file for a fully autonomous AI strategy
with no entry or exit scripts. The AI controls all trading decisions.The preset file must strictly comply with all the ‘Rules for
Creating EAsiTrader Preset Files’. Use the Defaults.set Preset File as
a template. Verify your content by cross referencing your sections and
settings with those from the template. Any deviation or omission
will be considered a failure to complete the task.Strategy Details
- Symbol: EURUSD M15
- Entry/Exit Scripts: All empty — AI handles everything
- Risk: 1% per trade, max 5% per market, max 10% account-wide
- Trading Hours: 07:00–21:00 server time
- Close at end of day and week: Yes
- Max positions: 1 per market, 1 per hour, 3 per day
AI Configuration
- AI Mode: Autonomous (mode 4) — AI controls all trade decisions
- Strategy Instructions: Trade Smart Money Concepts using FVG entries, CHoCH confirmations, and LP targets. Open positions only after CHoCH confirms direction AND an unfilled FVG provides entry zone. Set SL behind FVG boundary. Set TP at next LP level. Return empty instructions if no clear setup exists. Trail stops to break-even after 1R. Close early on opposite CHoCH. Never use ‘aggressive’ risk_mode. Use ‘reduced’ when regime is ‘volatile’.
- Additional Timeframes: H1 for higher timeframe context
- Confidence Threshold: 0.50 (higher threshold for autonomous decisions)
- Refresh Interval: 5 minutes (frequent for M15 timeframe)
- URLs: Include DailyForex RSS and FXStreet RSS news feeds
- Permissions: AIAllowOpen=true, AIAllowClose=true, AIAllowModifySL=true. AIAllowModifyTP=false, AIAllowPlaceOrders=false, AIAllowCancelOrders=false.
- Indicators: Include ChoCh, FVG, and LP indicators to provide grounded events for the AI
Ensure the AI Section settings comply with Rule 11 for Autonomous mode — specifically that AIAllowOpen is true and AIStrategyInstructions is non-empty."
Visit the EAsiTrader Presets Page for more examples which you can download to use in EAsiTrader.
Rev: 02.03.2026 19:48