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 HH function.
HH(3) < HH(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.
HH(3)
HH(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) ? Ask() : 0
Opens a buy trade at exactly 9:30, demonstrating basic time-based entry rules.
TimeOfDay(9,30)
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 && Close(1) > Signal('HLines1') && 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 existsClose(1) > Signal('HLines1')
: Price breaks above 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
Low(LL(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)
: Rising trend strengthClose(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
Low(LL(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) && (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) || 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)
: 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) && High(1) > HH(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) || (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)
: London session openHigh(1) > HH(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) > HH(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) > HH(VAR0) + ATR1(1) ? OrderPrice() : 0
Close(1) < Keltner1(1,0) || Low(1) < LL(5) ? Bid() : 0
Trades breakouts from established price channels in AUDUSD, using volume confirmation and Keltner Channels for validation and management.
High(1) > HH(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) > HH(4) && Volume(1) > Volume(2) ? Ask() : 0
LL(4) - ATR1(1)
Low(1) - (ABH1(1,0) * (High(1) > HH(3) ? 1 : 2))
OrderPrice() + (ATR1(1) * VAR0)
High(1) > OrderPrice() + ATR1(1) ? OrderPrice() : 0
TimeOfDay(16,0) == 1 || Low(1) < LL(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) > HH(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.
When writing scripts in EAsiScript, following established coding practices will help you create more reliable and maintainable trading strategies. These best practices focus on proper syntax, correct use of variables and functions, and clear logical structure. By following these guidelines, you’ll avoid common coding errors and create scripts that are easier to test and modify.
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 directoryThese 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"
Visit the EAsiTrader Presets Page for more examples which you can download to use in EAsiTrader.
Rev:07.02.2025 10:35