Tarea técnica
Introduction
This EA has 2 strategies, namely STRATEGY 1 AND STRATEGY 2, and allows the user to choose ONLY 1 strategy to trade. These strategies are different because they have different calculation methods to determine the price levels for EA to open the pending BUY and SELL LIMIT orders at the OPEN of a daily candle. The EA trading and operation logics ARE THE SAME for these 2 strategies.
This EA is a counter-trend grid EA where a basket of trades will be opened against the trend at different grid levels. This grid EA only trades 1 TIME PER DAY for each currency pair. At the OPEN of a daily candle, this EA will check if there are existing open positions for this currency pair. If there are no open positions for this currency pair, this EA will simultaneously open 2 pending BUY and SELL LIMIT orders at 2 specified prices. These specified prices are calculated using a formula which is related to a strategy shown later. Different strategies have different formulas. These price levels are called TOP and BOTTOM 1st grid. As the price triggers one of the pending LIMIT orders, a position will be opened at 1st grid. The other pending LIMIT order will be canceled and removed automatically. The EA will also place the MAX SL and TP automatically when the 1st position is opened at the 1st grid. MAX SL and TP are the inputs by the user.
As the trend goes against the 1st position, this EA will open more grids at a distance specified by the Grid Distance which is an EA parameter. As the EA opens more grids, the TP WILL BE ADJUSTED EVERY TIME BASED ON TRAILING TP STEP IN POINTS. The EA will adjust the TP as the market price moves equal or more than X points away from the 1st grid. The X POINTS is determined by the Trailing TP Step in the EA parameter setting.. The EA will close a basket of trades based on TP and MAX SL. Other risk management parameters are the DD% Control and MAX DD%. DD% Control is used to manage the risk in an account by stopping the EA from opening new grids and trades in all currency pairs whereas as MAX DD% is hit, all ongoing trades and pending orders in the account will be closed immediately.
EA Operations
The EA always places the pending SELL LIMIT order at the TOP 1st grid and pending BUY LIMIT order at the BOTTOM 1st grid. The pending SELL LIMIT order is always above the current price and the pending BUY LIMIT order is always below the current price. If price is in a ranging zone and does not hit either pending BUY or SELL LIMIT orders within the SAME DAY, these pending orders will be canceled at the daily candle CLOSE time. The process repeats itself at the OPEN of the next daily candle.
Daily Price Level Calculations
This EA will check if there are existing open positions for a currency pair at the Open of a daily candle. If there are no existing open positions, this EA will perform calculations to determine 2 price levels, the TOP and BOTTOM 1st grid, to open 2 pending BUY and SELL LIMIT orders. These 2 price level calculations depend on the selection of the strategies, either Strategy 1 or Strategy 2, by the EA user.
WHEN THERE ARE ALREADY OPEN POSITIONS IN A CURRENCY PAIR, THIS EA WILL NOT PERFORM THE CALCULATIONS AT THE OPEN OF THE DAILY CANDLE.
STRATEGY 1:
1st Grid Price Level Calculations:
TOP 1st Grid = Today Pivot +Factor X Range
BOTTOM 1st Grid = Today Pivot - Factor X Range
Today Pivot = [ Previous DAY HIGH + Previous DAY LOW + Previous DAY CLOSE ]/ 3
Range = Previous DAY HIGH - Previous DAY LOW
Factor is a number (data type double) in the EA parameter setting set by a user.
STRATEGY 2:
1st Grid Price Level Calculation:
TOP 1st Grid = OPEN Price of today Daily Candle+Factor ADR (N)
BOTTOM 1st Grid = OPEN Price of today Daily Candle -Factor ADR (N)
Range = { HIGH - LOW } of a Daily Candle
Average Daily Range, ADR (N) = [ 1N Previous Nth Day Range ] N
Factor is a number (data type double) in the EA parameter setting set by a user.
N is a number (data type integer) in the EA parameter setting set by a user.
Example 1: N=3, ADR (3)
Example 2: N=5, ADR (5)
BUY/SELL Signal
The BUY/SELL signal will happen when price crosses either one of the TOP or BOTTOM 1st grid price levels and activates the pending BUY/SELL LIMIT orders. When either one of these pending orders activate, the other order will be canceled and removed (OCO). If the trade(s) work out, single position or a basket of positions, will be closed with a profit by hitting TP When the EA closes a single or a basket of positions with a profit in the SAME DAY, no additional new trade will be opened again within the SAME DAY using the same 1st Grid level (TOP or BOTTOM).
Price against Trade
If the price goes against 1st trade, a new grid will be opened at a distance controlled by Grid Distance which is a parameter. Each grid level lot size, EXCEPT the 1st grid lot size, is determined by the Grid Lot Size parameter. 1st grid lot size is determined by the Initial Lot Size parameter. The Grid Distance determines the distance between 2 grid levels. Grid Distance is in POINTS. The maximum number of grids is controlled by the MAX Grid level parameter. If price continues to go against trades and does not retrace, eventually price will hit the MAX SL and all open trades in all grids will be closed at a loss for a currency pair.
Stop Loss (SL)
Since this is a grid EA, therefore every trade does not have stop loss SL except the MAX SL which is the stop loss to close all baskets of grids to save the account. MAX SL is set above the last SELL grid when there is an UP trend or is set below the last BUY grid when there is a DOWN trend as shown below.
Take Profit (TP) with Trailing TP Step
This EA must be able to modify the TP and trail TP at a distance from price as more grids are opened when the market trend is against the trades. The Trailing TP Step parameter controls when to move/trail the TP as the market moves against the trades.
Example 1: Trail TP in the UP TREND
Parameter settings are as below:
TP = 800 POINTS
Trailing TP Step = 300 POINTS
When the 1st grid opens, the TP is set below the 1st grid level. TP will not move and is fixed when the market price moves is less than 300 POINTS. As and when the market price moves 300 POINTS in the trend direction and against the 1st position, the TP will be adjusted by 300 POINTS in the trend direction as shown below.
Example 2: Trail TP in the DOWN TREND
Parameter settings are as below:
TP = 600 POINTS
Trailing TP Step = 200 POINTS
When the 1st grid opens, the TP is set above the 1st grid level. TP will not move and is fixed when the market price moves is less than 300 POINTS. As and when the market price moves 300 POINTS in the trend direction and against the 1st position, the TP will be adjusted by 300 POINTS in the trend direction as shown below.
One Chart Function
This EA needs to have a One Chart function so that it can manage many currency pairs with 1 chart instead of opening many charts. When One Chart function is de-activated, the user needs to attach this EA to the chart he wants to trade.
EA Requirements
One-Cancel-Other (OCO)
This EA must be able to execute the OCO for the pending BUY and SELL LIMITS orders placed at the OPEN of the Daily candle
Currency Pair Digits
This EA must be able to handle 4 and 5 digits brokers.
Currency Pairs Prefix and Suffix
This EA must be able to handle currency pairs with either PREFIX OR SUFFIX depending on the brokers.
Trade Expiry
When price does not hit the TOP 1st Grid or BOTTOM 1st grid within 24 hours, the pending BUY and SELL LIMIT orders will be removed.
One Trade at a Time for Each Currency Pair
This EA only opens ONE trade per day per currency pair.
This EA WILL NOT open a new trade when:
-
1st grid position opens and TP in the SAME DAY. A new trade will only be opened the next day using the new 1st TOP and BOTTOM grid level.
-
Multiple grids of positions are open and ongoing therefore Daily TOP and BOTTOM 1ST GRID CALCULATIONS WILL NOT START at OPEN of a daily candle. When these grids of positions are closed, the new TOP and BOTTOM 1st grid pending orders will only be opened the next day at the OPEN of a daily candle.
DST and Winter Time Auto Switching
After the user has decided the GMT Offset for their chosen brokers, this EA will auto switch between Daylight Saving Time (DST) and Winter time
EA Parameter Settings Requirements
Strategy
This parameter sets the trading strategy will be used by the EA. Default value is 1 which is Strategy 1
Currency Pairs
This paramet let the user input the currency pairs he wants the EA to trade without opening all the charts, therefore reducing the CPU loads.
Leave BLANK to DE-ACTIVATE this function.
Example 1: User has to attach EA to the chart he wants to trade
Example 2: Trade 28 currency pairs
Example 3: Trade some pairs
Example 4: Trade some pairs with prefix
Example 5: Trade some pairs with suffix
Factor and N
These are parameters entered by the user for the EA to calculate the Daily TOP and BOTTOM 1st grids for the EA to place the BUY and SELL LIMIT order at the OPEN of the Daily candle
Initial Lot Size
This parameter sets the lot size for the 1st grid. There are 2 ways to set this parameter: Manual or Risk % of account balance. When using the manual way, a user inputs a number, for example, 0.01 or 0.2 as the lot size for the 1st grid. Using the risk % of account balance, when a user inputs a number for example 0.6, it means EA will calculate the 1st grid lot size based on 0.6% risk of account balance. The minimum lot size using both ways is always 0.01 lot. A user only can choose 1 way to set the initial lot size. Use Zero (0) to DE-ACTIVATE 1 way over the other as shown below:
Example 1: when using the manual way to set the initial lot size:
Initial Lot Size | |
Manual | 0.01 or 0.2 or 1 |
Risk % of Account Balance | 0 (must set this to ZERO when using Manual way) |
Example 2: when using the risk % of account balance way to set the initial lot size:
Initial Lot Size | |
Manual | 0 (must set this to ZERO when using Risk % of account balance way) |
Risk % of Account Balance | 0.6 or 1 or 0.05 |
Grid Distance
This parameter sets the distance between the grids in POINTS.
MAX Grid Level
This parameter sets the maximum number of grids allowed to open by this EA for a currency pair.
Grid Level Lot Size
This parameter sets the lot size for the 2nd grid onwards. There are 3 methods to set the grid level lot size: :
-
Constant
All grids lot sizes will be the same as the Initial Lot Size.
Example1:
Initial Lot Size = 0.3
Constant = Select
1st grid lot size = 0.3
2nd grid lot size = 0.3
3rd grid lot size = 0.3
-
Fixed
When Fixed is selected, the lot size for each grid has been fixed in such a way that the 1st grid lot size which is the initial lot size is the same as the 2nd grid lot size. After the 2nd grid, the subsequent lot size is doubled from the previous lot size.
Example 1: Example 2:
Initial Lot Size = 0.3 Initial Lot Size = 0.02
Fixed = Select Fixed = Select
1st grid lot size = 0.3 1st grid lot size = 0.02
2nd grid lot size = 0.3 2nd grid lot size = 0.02
3rd grid lot size = 0.6 3rd grid lot size = 0.04
4rd grid lot size = 1.2 4rd grid lot size = 0.08
5rd grid lot size = 2.4 5rd grid lot size = 0.16
-
Multiplier:
The user inputs a number. This number will be used to multiply the 1st grid initial lot size to get the 2nd grid lot size. The 2nd grid lot size will multiply by this number to get the 3rd grid lot size so on and so forth.
Example 1:
Initial Lot Size = 1
Multiplier = 2
1st grid lot size = 1 (this is the Initial Lot Size input)
2nd grid lot size = 1 x 2 = 2
3rd grid lot size = 2 x 2 = 4
Example 2:
Initial Lot Size = 0.06
Multiplier = 1.5
1st grid lot size = 0.06 (this is the Initial Lot Size input)
2nd grid lot size = 0.06 x 1.5 = 0.09
3rd grid lot size = 0.09 x 1.5 = 0.14 (round up)
4th grid lot size = 0.14 x 1.5 = 0.20 (round down)
MAX SL
This parameter sets the stop loss to close a basket of grids of trades for a currency pair. Other currency pairs will not be affected. This stop loss is in POINTS measured from the 1ST GRID.
TP
This parameter sets the take profit in POINTS. For a single BUY trade, TP is the distance in POINTS ABOVE the 1st grid. For a single SELL trade, TP is the distance in POINTS BELOW the 1st grid. For a basket of grids of trades, the TP must be adjusted as discussed in the EA REQUIREMENTS section
Trailing TP Step
This parameter is in POINTS and controls when the EA will adjust the TP. As the market trend is against the positions, the EA will start to adjust the TP when the market price moves equal or more than the Trailing TP Step distance. Zero (0) is to DE-ACTIVATE this function. Default is Zero (0).
MAX DD %
This parameter is used to protect the account. The user inputs a number which reflects the risk he wants to take. MAX DD% is calculated based on account equity. The EA will close all ongoing trades and remove all pending orders of this account when the account DD hits this MAX DD %. Zero (0) is to DE-ACTIVATE this function. Default is Zero (0).
DD % Control
This parameter is used to manage the DD % level of an account so that risk is not out of control. DD % Control is calculated based on account equity. DD % Control calculation is the same as MAX DD % but the action taken by the EA is different. When DD % Control is hit, this EA will not open any new trades for all currency pairs. Take note that DD % Control is typically less than MAX DD %. Zero (0) is to DE-ACTIVATE this function. Default is Zero (0).
GMT Offset
This parameter let the user select the GMT offset time for different brokers. Majority brokers’ server time is GMT+3. Some brokers' server time is GMT+2. Default value is 3.
EA Parameter Settings Summary Table