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) ? 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(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)
: 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(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) && (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) > 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) || (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) > 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.
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.
TimeOfDay(8,0) && Trend('MA1') == Bullish && Close(1) > MA1(1,0) && RSI1(1) > 50 && RSI1(1,_Symbol,H1) > 50 ? Ask() : 0
MA1(1,0) - (ATR1(1) * VAR0)
MA1(1,0) - (ATR1(1) * (RSI1(1) > 70 ? 0.5 : 1))
OrderPrice() + (ATR1(1) * VAR1 * (RSI1(1,_Symbol,H1) > 70 ? 1 : 2))
RSI1(1) > 60 && RSI1(1,_Symbol,H1) > 60 ? OrderPrice() : 0
TimeOfDay(17,0) || (RSI1(1) < 40 && RSI1(1,_Symbol,H1) < 40) ? Bid() : 0
A comprehensive trend-following strategy that aligns multiple timeframes with momentum confirmation and time-based filters, using adaptive trade management based on market conditions.
TimeOfDay(8,0)
: Trades after market openTrend('MA1') == Bullish
: Current timeframe trendClose(1) > MA1(1,0)
: Price above MARSI1(1) > 50
: Current timeframe momentumRSI1(1,_Symbol,H1) > 50
: H1 timeframe momentumEnsure MA and RSI indicators are enabled. Optimize VAR0 (stop distance) and VAR1 (profit target) for your instrument.
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) && 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) || (RSI1(1) < 40 && RSI2(1) < 40) ? Bid() : 0
A comprehensive trend-following strategy that aligns multiple timeframes with momentum confirmation and time-based filters, using adaptive trade management based on market conditions.
TimeOfDay(8,0)
: Trades after market openTrend('MA1') == Bullish
: Current timeframe trendClose(1) > MA1(1,0)
: Price above MARSI1(1) > 50
: Current timeframe momentumRSI2(1) > 50
: H1 timeframe momentumAll indicators must be enabled (’+’ prefix) in the preset file. UserVars VAR0 (stop distance) and VAR1 (profit target) should be optimized for your specific instrument.
This example shows how to combine trend with momentum for a more reliable entry strategy.
Trend('MA1') == Bullish && RSI1(1) > 50 && RSI1(2) < 50 ? Ask() : 0
Opens a buy trade when price shows bullish trend structure and RSI crosses above the centerline (50), indicating aligned trend and momentum conditions.
Trend('MA1') == Bullish
RSI1(1) > 50 && RSI1(2) < 50
RSI1(1) > 50
: Current RSI above centerlineRSI1(2) < 50
: Previous RSI below centerlineAsk()
0
if conditions are not met (no trade)Ensure both the MA and RSI indicators are enabled in the Indicator’s List before running this script. Consider adding volume or volatility filters for additional confirmation.
This example demonstrates how to adjust stop loss placement based on both market volatility and price structure.
ATR1(1) > 20 ? Low(1) - ATR1(1) * 2 : Low(1) - ATR1(1)
Sets a stop loss distance that adapts to market conditions, placing a wider stop when volatility is high and a tighter stop when volatility is lower, while using the previous bar’s low as a reference point.
ATR1(1) > 20
Low(1) - ATR1(1) * 2
Low(1) - ATR1(1)
Ensure the ATR indicator is enabled in the Indicator’s List before running this script. Consider using dynamic ATR thresholds based on historical volatility patterns.
This example demonstrates a complete trading strategy that adjusts all its parameters based on market volatility.
ATR1(1) > 20 && Close(1) > Open(1) ? Ask() : 0
ATR1(1) > 20 ? Low(1) - ATR1(1) * 2 : Low(1) - ATR1(1)
ATR1(1) > 20 ? Low(1) - ATR1(1) * 1.5 : Low(1) - ATR1(1) * 0.75
ATR1(1) > 20 ? OrderPrice() + ATR1(1) * 4 : OrderPrice() + ATR1(1) * 2
ATR1(1) > 20 ? OrderPrice() + ATR1(1) : OrderPrice() + ATR1(1) * 0.5
Creates a comprehensive trading strategy that adapts all its parameters to current market volatility conditions, providing wider settings in volatile markets and tighter settings in calmer conditions.
ATR1(1) > 20
: Identifies high volatility environmentClose(1) > Open(1)
: Confirms bullish price actionEnsure the ATR indicator is enabled in the Indicator’s List before running this script. The ATR threshold of 20 should be adjusted based on your specific instrument’s characteristics.
MACD1(1) < 0 && BarTrend(1) == Bearish ? Bid() : 0
This script enters a sell trade when the MACD indicates bearish momentum and the last bar is bearish.
MACD1(1) < 0
confirms bearish momentum.BarTrend(1) == Bearish
ensures the last bar is bearish.MA1(1) + 10 * Point
This script sets a take profit level dynamically based on the moving average (MA).
MA1(1)
) to define the take profit level.Trend('MA1') == Bullish ? Ask() : 0
This script enters a buy trade when a moving average confirms an upward trend.
Trend('MA1') == Bullish
ensures the trend is upward.RSI1(1) < 30 && BarTrend(1) == Bullish ? Ask() : 0
Low(1) - ATR1(1) * 2
OrderPrice() + ATR1(1) * 3
RSI1(1) > 70 || BarTrend(1) == Bearish ? Bid() : 0
Ensure the RSI and ATR indicators are enabled in the Indicator’s List before running the script.
This strategy enters a long trade when the RSI indicates oversold conditions and the bar trend is bullish. It uses dynamic ATR-based stop loss and take profit levels, exiting the trade when RSI is overbought or the bar trend turns bearish.
RSI1(1) < 30
to detect oversold conditions with BarTrend(1) == Bullish
to ensure a bullish bar trend. Places the trade at the current Ask price.Low(1)
minus twice the ATR value (ATR1(1)
) to define a dynamic stop loss that adapts to market volatility.OrderPrice() + ATR1(1) * 3
, giving a reward target three times the market volatility.RSI1(1) > 70
indicates overbought conditions or BarTrend(1) == Bearish
signals a reversal.Trend('MA1') == Bullish && BarTrend(1) == Bullish ? Ask() : 0
Low(1) - 15 * Point
High(1) + 20 * Point
Trend('MA1') == Bearish ? Bid() : 0
Ensure the Moving Averages (MA1) indicator is enabled in the Indicator’s List before running the script.
This strategy enters a long trade when the moving average trend and bar trend are both bullish. It uses fixed stop loss and take profit levels and exits the trade when the moving average indicates a bearish trend.
Trend('MA1') == Bullish
for confirming a bullish moving average trend with BarTrend(1) == Bullish
for verifying a bullish bar. Executes the trade at the Ask price.Low(1) - 15 * Point
, providing a safety buffer below the last bar’s low.High(1) + 20 * Point
, giving a predefined profit target above the last bar’s high.Trend('MA1') == Bearish
, indicating a shift to a bearish moving average trend.High(1) > BB1(1, 1) ? Ask() : 0
Low(1) - ATR1(1)
OrderPrice() + ATR1(1) * 2
BarTrend(1) == Bearish || High(1) < BB1(1, 1) ? Bid() : 0
Ensure the Bollinger Bands (BB1) and ATR indicators are enabled in the Indicator’s List before running the script.
This strategy enters a long trade when the price breaks above the Bollinger Band upper line, indicating a bullish breakout. It sets a dynamic stop loss and take profit based on ATR, exiting when the bar trend turns bearish or the price returns below the upper Bollinger Band.
High(1) > BB1(1, 1)
to detect a price breakout above the Bollinger Band upper line and enters a buy trade at the Ask price.Low(1) - ATR1(1)
, using the last bar’s low and ATR for volatility adjustment.OrderPrice() + ATR1(1) * 2
, targeting a reward twice the market volatility.BarTrend(1) == Bearish
) or if the price falls below the upper Bollinger Band (High(1) < BB1(1, 1)
).RSI1(1) > 70 && BarTrend(1) == Bearish ? Bid() : 0
High(1) + ATR1(1)
OrderPrice() - ATR1(1) * 2
RSI1(1) < 30 || BarTrend(1) == Bullish ? Ask() : 0
Ensure the RSI and ATR indicators are enabled in the Indicator’s List before running the script.
This strategy enters a short trade when the RSI indicates overbought conditions and the bar trend is bearish. It uses ATR-based stop loss and take profit levels and exits when the RSI indicates oversold conditions or the bar trend turns bullish.
RSI1(1) > 70
to detect overbought conditions with BarTrend(1) == Bearish
to confirm a bearish trend. Executes a sell trade at the current Bid price.High(1) + ATR1(1)
, adjusting for volatility above the last bar’s high.OrderPrice() - ATR1(1) * 2
, targeting a reward twice the market volatility.RSI1(1) < 30
signals oversold conditions or BarTrend(1) == Bullish
indicates a bullish trend reversal.MA1(1) > MA2(1) && MA1(2) <= MA2(2) ? Ask() : 0
Low(1) - ATR1(1)
OrderPrice() + ATR1(1) * 2
MA1(1) < MA2(1) ? Bid() : 0
Ensure the Moving Averages (MA1 and MA2) and ATR indicators are enabled in the Indicator’s List before running the script.
This strategy enters a long trade when a short moving average crosses above a long moving average. It uses ATR-based stop loss and take profit levels and exits the trade when the short moving average crosses back below the long moving average.
MA1(1) > MA2(1)
to confirm the short moving average is above the long moving average and MA1(2) <= MA2(2)
to verify the crossover occurred. Executes a buy trade at the Ask price.Low(1) - ATR1(1)
, adjusting for market volatility.OrderPrice() + ATR1(1) * 2
, targeting a reward twice the ATR value.MA1(1) < MA2(1)
, indicating a bearish crossover of the moving averages.TimeOfDay(4,30) && ((HighestHigh(3) - LowestLow(3)) >= Ask() * 0.002) && ((HighestHigh(3) - LowestLow(3)) <= Ask() * 0.004) ? HighestHigh(3) : 0
HighestHigh(3) - (HighestHigh(3) - LowestLow(3)) * 0.5
OrderPrice() + (HighestHigh(3) - LowestLow(3)) * 1.5
TimeOfDay(18,0) && (IsOpen() || IsPending()) ? Bid() : 0
TimeOfDay(4,30) && ((HighestHigh(3) - LowestLow(3)) >= Ask() * 0.002) && ((HighestHigh(3) - LowestLow(3)) <= Ask() * 0.004) ? LowestLow(3) : 0
LowestLow(3) + (HighestHigh(3) - LowestLow(3)) * 0.5
OrderPrice() - (HighestHigh(3) - LowestLow(3)) * 1.5
TimeOfDay(18,0) && (IsOpen() || IsPending()) ? Ask() : 0
This strategy identifies breakout opportunities during a predefined time window and dynamically adjusts its stop loss and take profit levels based on the range of the past three bars. Trades are closed at the end of the trading window or if the trade status is open or pending beyond the allowable timeframe.
TimeOfDay(4,30)
and checks if the range (HighestHigh(3) - LowestLow(3)
) of the past three bars is within a valid range proportional to the Ask price. Places a buy trade at HighestHigh(3)
if conditions are met.HighestHigh(3)
.TimeOfDay(18,0)
if the trade is still active, either open or pending.LowestLow(3)
if conditions are met.LowestLow(3)
.TimeOfDay(18,0)
if the trade is still active, either open or pending.TimeOfDay(9,0) && Close(1) > FibRetrace(LowestLow(10), HighestHigh(10), 0.618) ? Ask() : 0
FibRetrace(LowestLow(10), HighestHigh(10), 0.5)
FibRetrace(LowestLow(10), HighestHigh(10), 1.0)
TimeOfDay(17,0) || Close(1) < FibRetrace(LowestLow(10), HighestHigh(10), 0.618) ? Bid() : 0
TimeOfDay(9,0) && Close(1) < FibRetrace(LowestLow(10), HighestHigh(10), 0.618) ? Bid() : 0
FibRetrace(LowestLow(10), HighestHigh(10), 0.5)
FibRetrace(LowestLow(10), HighestHigh(10), 0.0)
TimeOfDay(17,0) || Close(1) > FibRetrace(LowestLow(10), HighestHigh(10), 0.618) ? Ask() : 0
Ensure the Fibonacci Retracement tool is configured to calculate retracement levels based on the high and low of the last 10 bars.
This strategy utilizes Fibonacci retracement levels to identify potential reversal points in the market. Trades are initiated near the 61.8% retracement level, with stop loss and take profit targets set at other key Fibonacci levels. Trades are exited at the end of the trading day or when the retracement level fails.
Close(1)
) exceeds the 61.8% Fibonacci retracement level (FibRetrace(LowestLow(10), HighestHigh(10), 0.618)
) of the last 10 bars, ensuring the trade occurs within the specified timeframe (TimeOfDay(9,0)
).TimeOfDay(17,0)
or if the price falls back below the 61.8% retracement level.TimeOfDay(9,0)
).TimeOfDay(17,0)
or if the price rises back above the 61.8% retracement level.MA1(1, 1) > MA1(1, 2) && Volume(1) > 1000 ? Ask() : 0
Low(1) - ATR1(1)
OrderPrice() + ATR1(1) * 2
MA1(1, 1) < MA1(1, 2) || Volume(1) < 800 ? Bid() : 0
MA1(1, 1) < MA1(1, 2) && Volume(1) > 1000 ? Bid() : 0
High(1) + ATR1(1)
OrderPrice() - ATR1(1) * 2
MA1(1, 1) > MA1(1, 2) || Volume(1) < 800 ? Ask() : 0
NTL\MA(:M30,1,10,2,50,0).ex5
The MA
indicator is configured with the following parameters:
M30
2
)0
)This strategy uses a single MA1 indicator to handle two moving averages (short and long) along with volume checks to confirm trend direction and market activity. It enters trades when the conditions align and exits when the trend reverses or volume drops below a threshold.
MA1(1, 1)
) is above the long moving average (MA1(1, 2)
) and ensures strong market activity with Volume(1) > 1000
. Places a buy trade at the Ask price.Low(1) - ATR1(1)
, providing a volatility-based safety net.OrderPrice() + ATR1(1) * 2
, targeting a reward twice the market volatility.MA1(1, 1) < MA1(1, 2)
) or if market activity weakens (Volume(1) < 800
).MA1(1, 1)
) is below the long moving average (MA1(1, 2)
) and ensures strong market activity with Volume(1) > 1000
. Places a sell trade at the Bid price.High(1) + ATR1(1)
, based on the recent high and volatility.OrderPrice() - ATR1(1) * 2
, aiming for a reward twice the market volatility.MA1(1, 1) > MA1(1, 2)
) or if market activity weakens (Volume(1) < 800
).TimeOfDay(9,0) && Ask() > High(1, "", D1) ? Ask() : 0
High(1, "", D1) - 20 * Point
High(1, "", D1) + (High(1, "", D1) - Low(1, "", D1)) * 1.5
TimeOfDay(16,0) || Ask() < High(1, "", D1) ? Bid() : 0
TimeOfDay(9,0) && Bid() < Low(1, "", D1) ? Bid() : 0
Low(1, "", D1) + 20 * Point
Low(1, "", D1) - (High(1, "", D1) - Low(1, "", D1)) * 1.5
TimeOfDay(16,0) || Bid() > Low(1, "", D1) ? Ask() : 0
This strategy uses the High()
and Low()
functions with the D1
timeframe to calculate the daily high and low prices dynamically. No additional indicators are required.
This strategy identifies breakout opportunities based on the daily high and low prices. It dynamically calculates stop loss and take profit levels relative to the day’s range and exits trades if the breakout fails or the trading session ends.
High(1, "", D1)
) and the time is after 09:00
. Places the trade at the current Ask price.High(1, "", D1) - Low(1, "", D1)
) above the daily high.16:00
or if the Ask price drops below the daily high (High(1, "", D1)
).Low(1, "", D1)
) and the time is after 09:00
. Places the trade at the current Bid price.16:00
or if the Bid price rises above the daily low (Low(1, "", D1)
).TimeOfDay(10,0) && Volume(1) > Volume(2) * 2 ? Ask() : 0
Low(1) - 15 * Point
OrderPrice() + 30 * Point
Volume(1) < Volume(2) ? Bid() : 0
TimeOfDay(10,0) && Volume(1) > Volume(2) * 2 ? Bid() : 0
High(1) + 15 * Point
OrderPrice() - 30 * Point
Volume(1) < Volume(2) ? Ask() : 0
This strategy relies on the Volume()
function to identify sudden spikes in market activity compared to the previous bar. No additional indicators are required.
This strategy identifies potential trading opportunities based on significant volume spikes, indicating heightened market activity. It uses fixed stop loss and take profit levels and exits trades when volume normalizes.
10:00
if the volume of the current bar (Volume(1)
) is more than double the volume of the previous bar (Volume(2)
). Places the trade at the current Ask price.Volume(1)
) falls below the volume of the previous bar (Volume(2)
).10:00
if the volume of the current bar (Volume(1)
) is more than double the volume of the previous bar (Volume(2)
). Places the trade at the current Bid price.Volume(1)
) falls below the volume of the previous bar (Volume(2)
).Signal('ST1') == Bullish && RSI1(1) > 50 ? Ask() : 0
Low(1) - ATR1(1)
OrderPrice() + ATR1(1) * 3
Signal('ST1') == Bearish || RSI1(1) < 50 ? Bid() : 0
Signal('ST1') == Bearish && RSI1(1) < 50 ? Bid() : 0
High(1) + ATR1(1)
OrderPrice() - ATR1(1) * 3
Signal('ST1') == Bullish || RSI1(1) > 50 ? Ask() : 0
Ensure the SuperTrend (ST1), ATR, and RSI indicators are enabled in the Indicator’s List before running the script.
This strategy combines the SuperTrend (ST1) indicator to determine trend direction with the RSI indicator to confirm the strength of the trend. Trades are entered when both indicators align, and trades are exited on a reversal or weakening RSI signal.
Signal('ST1')
) indicates a bullish trend and the RSI indicator (RSI1(1)
) shows a value greater than 50, confirming upward momentum. Places the trade at the Ask price.Low(1) - ATR1(1)
, adjusted for market volatility.OrderPrice() + ATR1(1) * 3
, aiming for a reward three times the ATR value.Signal('ST1')
) turns bearish or if RSI weakens (RSI1(1) < 50
).Signal('ST1')
) indicates a bearish trend and the RSI indicator (RSI1(1)
) shows a value less than 50, confirming downward momentum. Places the trade at the Bid price.High(1) + ATR1(1)
, adjusted for market volatility.OrderPrice() - ATR1(1) * 3
, aiming for a reward three times the ATR value.Signal('ST1')
) turns bullish or if RSI strengthens (RSI1(1) > 50
).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 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:35Trend(‘MA1’) == Bullish && Close(1) > Open(1) ? Ask() : 0
Creating EAsiScript preset files using AI can greatly simplify the process of defining and managing trading strategies. AI can assist by generating preset files based on a user-provided strategy description. However, to ensure the preset files are valid and compatible with EAsiTrader, it is essential to follow the “Rules for Creating EAsiTrader Preset Files.”
Provide a detailed description of your trading strategy in your prompt. For example:
"Create an EAsiScript preset file for a trend-following strategy:"
Instructions you must follow:
“The preset file must strictly comply with all the ‘Rules for Creating Main Preset Files’ as outlined in the EAsiTrader User Guide. Use the Defaults.set Preset File as a template. Verify your content by cross referencing your sections and settings with those from the template. If different then regenerate the content. Any deviation or omission will be considered a failure to complete the task. Repeatedly check the rules, compare with the template and regenerate the content until every rule is complied with.”
.set
file in a plain text editor like Notepad++.TrendFollowingRSI.set
.MQ5\Files\EAsiTrader
.set
file in this directory.By uploading the user guides, you eliminate the need to manually provide additional context or formatting details in your AI prompt. The AI will reference the guides to:
This streamlined process ensures you can focus on your strategy while leveraging AI and the comprehensive user guides to produce accurate and effective EAsiScript Preset Files.
**I want to 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’ as outlined in the EAsiTrader User Guide. Use the Defaults.set Preset File as a template. Verify your content by cross referencing your sections and settings with those from the template. If different then regenerate the content. Any deviation or omission will be considered a failure to complete the task.
"Please create an EAsiScript Preset File for a trend-following strategy using moving averages:"
"Generate an EAsiScript Preset File for a breakout strategy based on Bollinger Bands:"
"Help me create an EAsiScript Preset File for a mean reversion strategy:"
Visit the EAsiScript Presets for more examples which you can download to use in EAsiTrader.
Rev:13.12.2024 14:27# Learn EAsiScript
Fundamentals of Writing Scripts EAsiScript enables you to define trading logic using simple yet powerful expressions. These expressions, composed of functions and operators, form the backbone of your scripts, driving decisions such as entering trades, setting stop losses, or adjusting take profit levels. In this tutorial, you’ll learn the fundamentals of writing expressions for specific scripts, with a focus on the ?:
(ternary), &&
(AND), and ||
(OR) operators, which are integral to building dynamic and efficient trading logic.
Each EAsiScript performs a specific trading function, such as Long Entry, Short Entry, Stop Loss, or Take Profit. Let’s explore how expressions fit into these scripts.
This script places a buy trade when the closing price of the last completed bar is higher than its opening price. It’s useful for simple trend-following strategies that focus on bullish price movement.
Close(1) > Open(1) ? Ask() : 0
Close
or Open
without specifying the shift, such as Close()
instead of Close(1)
.0
for “do nothing” when the condition is false.This script dynamically adjusts the stop loss level based on the average true range (ATR) of the last completed bar. It’s suitable for strategies that adapt to market volatility.
ATR1(1) > 20 ? Low(1) - 10 * Point : Low(1) - 5 * Point
shift
argument is 1.ATR1
function to work.10
or 5
) without multiplying by Point
to ensure correct scaling.shift
argument for Low
, which defaults to 1 but should be explicitly included for clarity.This script places a buy trade when two conditions are met: the closing price of the last completed bar is higher than its opening price, and the relative strength index (RSI) indicates bullish momentum. It’s ideal for strategies that require confirmation from both price action and momentum indicators.
Close(1) > Open(1) && RSI1(1) > 50 ? Ask() : 0
RSI1
function to work.&&
incorrectly, such as failing to enclose conditions in parentheses when combining multiple logical expressions.shift
argument for Close
or Open
, which defaults to 1 but should be explicitly included for clarity.||
) OperatorThis script places a sell trade when either of two conditions is met: the closing price of the last completed bar is lower than its opening price, or the MACD indicator signals bearish momentum. It’s useful for strategies that look for multiple potential triggers for entry.
Close(1) < Open(1) || MACD1(1) < 0 ? Bid() : 0
MACD1
function to work.||
incorrectly, such as not properly separating conditions when combining multiple logical expressions.shift
argument for Close
or Open
, which defaults to 1 but should be explicitly included for clarity.This script adjusts the stop loss level dynamically for a long trade when the profit exceeds a specified threshold. It’s ideal for locking in gains while allowing the trade to run further if the price continues to move favourably.
Profit() > 100 ? Bid() - 15 * Point : 0
Profit
without parentheses, which is invalid (e.g., Profit > 100
instead of Profit() > 100
).Point
for proper scaling, especially if the symbol’s price has many decimal places.0
return value, which means “do nothing” if the condition is not met.This script sets the take profit level when two conditions are met: the closing price of the last completed bar is higher than its opening price, and the relative strength index (RSI) indicates overbought conditions. It’s designed for strategies that aim to exit trades at optimal points during strong bullish trends.
Close(1) > Open(1) && RSI1(1) > 70 ? High(1) + 10 * Point : 0
RSI1
function to work.10
) without multiplying by Point
, which may result in incorrect scaling.shift
argument for Close
, Open
, or High
, which defaults to 1 but should be explicitly included for clarity.This script dynamically adjusts the stop loss level for a short trade when the profit exceeds a specified threshold. It helps secure gains while allowing the trade to remain open if the price continues moving favorably.
Profit() > 50 ? Ask() + 10 * Point : 0
Profit
without parentheses, which is invalid (e.g., Profit > 50
instead of Profit() > 50
).Point
for proper scaling, especially for symbols with small price increments.0
return value, which means “do nothing” if the condition is not met.This script places a buy trade when two conditions are met: the relative strength index (RSI) indicates bullish momentum, and the closing price is above the moving average. It’s ideal for trend-following strategies that confirm momentum with a moving average filter.
RSI1(1) > 50 && Close(1) > MA1(1) ? Ask() : 0
RSI1
and MA1
functions to work.shift
argument for Close
, which defaults to 1 but should be explicitly included for clarity.50
) without understanding their significance in indicator thresholds (e.g., RSI values range from 0 to 100).This script places a sell trade when two conditions are met: the MACD indicator signals bearish momentum, and the relative strength index (RSI) indicates oversold conditions. It’s suitable for strategies that rely on confirmation from both momentum and trend indicators.
MACD1(1) < 0 && RSI1(1) < 30 ? Bid() : 0
MACD1
and RSI1
functions to work.&&
incorrectly, such as not properly grouping conditions when combining multiple logical expressions.shift
argument for MACD1
or RSI1
, which defaults to 1 but should be explicitly included for clarity.This script sets a take profit level when two conditions are met: the closing price is above the moving average, and the relative strength index (RSI) indicates overbought conditions. It’s useful for trend-following strategies that aim to exit trades during strong upward trends.
MA1(1) > Close(1) && RSI1(1) > 70 ? High(1) + 15 * Point : 0
MA1
and RSI1
functions to work.15
) without multiplying by Point
, which may result in incorrect scaling.shift
argument for MA1
, Close
, or High
, which defaults to 1 but should be explicitly included for clarity.This script places a buy trade when the MA1
indicator generates a bullish signal using its SignalFlag
. It’s ideal for strategies that rely on moving averages to identify upward trends.
Signal('MA1') == Bullish ? Ask() : 0
Signal('MA1') == Bullish
SignalFlag
value from the MA1
indicator’s buffer 2 at the last completed bar (shift=1
by default).Bullish = 1
).MA1
indicator to retrieve the SignalFlag
value. Ensure the MA1
indicator is enabled in the Indicator List.
Bullish (1)
: Buy signal.Bearish (-1)
: Sell signal.0
: No signal.MA1
indicator in the Indicator List.0
means no signal, Bullish (1)
indicates a buy, and Bearish (-1)
indicates a sell.0
return value, which ensures the script does nothing if the condition is false.This example combines a Long Entry Script and a Stop Loss Script to create a basic strategy:
Signal('MA1') == Bullish ? Ask() : 0
Explanation:
MA1
indicator generates a bullish signal [Signal(‘MA1’) == Bullish].MA1
indicator is enabled in the Indicator List.Signal()
function automatically retrieves the SignalFlag
from buffer 2 of MA1
.ATR1(1) > 15 ? Low(1) - 20 * Point : Low(1) - 10 * Point
Explanation:
MA1
indicator.MA1
and ATR indicators in the Indicator List.Point
).SignalFlag
or ATR
values, leading to unintended results.This example demonstrates a strategy using the Moving Average (MA) and Super Trend (ST) indicators. The strategy includes entry conditions, an initial stop loss, and exit conditions.
Trend('MA1') == Bullish && Signal('ST1') == Bullish ? Ask() : 0
Explanation:
MA1
) is bullish [Trend(‘MA1’) == Bullish].ST1
) indicator generates a bullish signal [Signal(‘ST1’) == Bullish].Trend('MA1') == Bearish && Signal('ST1') == Bearish ? Bid() : 0
Explanation:
MA1
) is bearish [Trend(‘MA1’) == Bearish].ST1
) indicator generates a bearish signal [Signal(‘ST1’) == Bearish].Low(1) - 20 * Point : 0
Explanation:
High(1) + 20 * Point : 0
Explanation:
Trend('MA1') != Bullish ? Bid() : 0
Explanation:
Bid()
function.Trend('MA1') != Bearish ? Ask() : 0
Explanation:
Ask()
function.Profit() > 50 ? Bid() - 15 * Point : 0
Explanation:
Profit() > 50 ? Ask() + 15 * Point : 0
Explanation:
Entry:
Trend('MA1') == Bullish
and Signal('ST1') == Bullish
must be true.Initial Stop Loss:
Exit:
Indicator Requirements:
MA1
and ST1
indicators are enabled in the Indicator List.Scaling with Point
:
Point
to match the symbol’s price units.Optimization:
Use VAR0
and VAR1
for dynamic stop loss distances during optimization.
Example:
VAR0 = 10, 20
VAR1 = 5, 15
Signal('ST1') == Bullish ? Low(1) - VAR0 * Point : 0
This example demonstrates a complete trading strategy leveraging two complementary indicators, showing how to combine entry, initial stop loss, and exit logic into a robust script setup.
The RangeBreakout-USDJPY strategy identifies trading opportunities based on the price range of the last three bars and executes trades at predefined times. This example demonstrates how to use EAsiScript to configure entry, exit, and initial stop-loss conditions.
The strategy aims to capitalize on breakouts during a specific time window by analyzing the price range of the last three bars. Trades are entered only if the range falls within defined thresholds relative to the current price.
Long Entry:
TimeOfDay(4,30) && ((HighestHigh(3) - LowestLow(3)) >= Ask() * 0.002) && ((HighestHigh(3) - LowestLow(3)) <= Ask() * 0.004) ? HighestHigh(3) : 0
At 4:30, check the high (HighestHigh(3)
) and low (LowestLow(3)
) of the last three bars.
If the range is between 0.2% and 0.4% of the current Ask price, enter a long trade at the high of the range (HighestHigh(3)
).
Otherwise, no trade is entered (0
).
Short Entry:
TimeOfDay(4,30) && ((HighestHigh(3) - LowestLow(3)) >= Ask() * 0.002) && ((HighestHigh(3) - LowestLow(3)) <= Ask() * 0.004) ? LowestLow(3) : 0
At 4:30, check the high (HighestHigh(3)
) and low (LowestLow(3)
) of the last three bars.
If the range is between 0.2% and 0.4% of the current Ask price, enter a short trade at the low of the range (LowestLow(3)
).
Otherwise, no trade is entered (0
).
Long Initial Stop:
Ask(-0.005)
Sets the stop loss 0.5% below the current Ask price.
Short Initial Stop:
Bid(0.005)
Sets the stop loss 0.5% above the current Bid price.
Long Exit:
TimeOfDay(18,0) && (IsOpen() || IsPending())
At 18:00, exit any open or pending long trades.
Short Exit:
TimeOfDay(18,0) && (IsOpen() || IsPending())
At 18:00, exit any open or pending short trades.
TimeOfDay
function ensures trades are evaluated only at the specified time (4:30 in this case).HighestHigh(3)
and LowestLow(3)
ensures the breakout conditions are met.M30
). Adjust the InpTradeTool_Market
setting to align with your desired symbol and timeframe.This example demonstrates how EAsiScript can be used to implement a time-sensitive breakout strategy efficiently. Modify the parameters and conditions as needed to suit your trading objectives.
This strategy uses AutoFib1 to identify bullish and bearish market structures and trade based on higher highs (HighestHigh), higher lows (HL), lower highs (LH), and lower lows (LL). It is designed for semi-automated trading to send alerts and execute trades when conditions align with the strategy.
Long Entry Script:
Signal('AutoFib1') == Bullish && Low() <= LowestLow(15) && Close() < (MA1() + (ATR1() * 5)) && Close() > MA1() ? Ask() : 0
Logic:
Enter a long trade when:
Short Entry Script:
Signal('AutoFib1') == Bearish && High() >= HighestHigh(15) && Close() < MA1() && Close() > (MA1() - (ATR1() * 5)) ? Bid() : 0
Logic:
Enter a short trade when:
Preset Configuration:
AutoFibTest.set
for clarity.Load Indicators:
Customize Scripts:
Activate Auto Trade:
AutoTradeEnabled
to true
.SeriesRefreshMode_EveryBar
for processing on each new bar.Backtest and Optimize:
This strategy enables traders to identify and act on key bullish or bearish structures, ensuring alignment with market conditions. Semi-automation provides flexibility while leveraging the power of AutoFib1 and supporting indicators for informed decision-making.
This strategy focuses on buy-only trades on the USTECH 30-minute chart. It takes advantage of Bollinger Band squeezes to identify low volatility periods, coupled with price position relative to a 200 EMA to confirm bullish conditions. The stop loss is adjustable using an optimised value of VAR0.
Long Entry Script:
Close() > MA1(0,1) && BB1(0,1) - BB1(0,2) <= ATR1() * 2 ? Ask() : 0
Logic:
Enter a long trade when:
Long Initial Stop Script:
Ask() - ATR1() * VAR0
Logic:
BollingerBands.set
.AllowedTradeTypes
to Buys Only
.VAR0
as 4
(optimised for this strategy based on historical performance).1%
by setting MaxRiskPerTradeInPercent
.MaxOpenPositionsMarket
to 1
.This strategy identifies low volatility opportunities on the USTECH 30-minute chart, confirming bullish conditions with EMA and Bollinger Bands. The combination of technical indicators and an optimised stop loss enhances trade accuracy and risk management, ensuring it aligns with semi-automated trading principles.
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
Visit the EAsiScript Page for more examples which you can download to use in EAsiTrader.