Forex Factory (https://www.forexfactory.com/forum.php)
-   Commercial Content (https://www.forexfactory.com/forumdisplay.php?f=158)
-   -   Expanding Grid (https://www.forexfactory.com/showthread.php?t=548671)

bauta Jul 9, 2015 10:02am | Post# 1

3 Attachment(s)
Expanding Grid EG104:

EG104 EA, originally ExpandGrid, is a collection of grid styles/modes that have been optimized by intense tests, results from demos and real accounts and results from studies and parameter variations. It is delivered with the default parameters selected for the best EA results, so the trader does not need to change them to use the EA, just drop it to the chart, and let it play.

It has been found, during demoing EG and by users of forexfactory.com forum that a management of modes during news releases may increase profitability, decrease risk and salvage small accounts.

The idea behind EG is to create a grid above and below the price at an optimal pips increments, open a cycle and target it at one grid level. That it is. If the start lot quantity is 0.10 on EURUSD and grid level is 10 pips, then grid target is $10.00. If the trade goes south, EG will use different styles/modes to accumulate positions and average down or reverse the breakeven point and then target its original goal of $10.00. If at a preset level, the target is not reached, EG will set the cycle to a closure mode targeting the breakeven point. After a cycle is closed, EG will start a new cycle.

This EA works with its default values out of the box, but flexibility has always been a priority in developing it. It means the trader may change default values and use different grid modes simultaneously. By using start/end times the EA may run one grid mode during active sessions and a different grid mode during sleeping sessions, it may run modes in parallel or interlaced and with its own set of parameters. The trader is able, by combining these modes, to create a well complex algorithm no one created before. Its flexibility creates its unlimited potential by itself or by the trader’s imagination.

As a summary, there are two types of grid modes, stop order mode and limit order mode. It has been found that when the market is trading normally or in a range environment, limit orders style works better in a grid (buy below price, sell above price) and when the market is trending or moving fast and far up and down away of regular movements, stop orders work better. (Buy above price, sell below price).

Stop order mode reverse the breakeven point multiplying the opposite quantity by a factor (multiplier), limit order mode accumulates at the original trade direction averaging down the breakeven point by multiplying the last order quantity by a factor (multiplier). There are modes that use a static grid and others use a floating grid where the center moves as new orders are executed. Combining a stop order style with a limit order style, with a moving grid, creates a very interesting scenario. I challenge you to test it.



Grid modes:

  1. symmetry-hedge- limit order mode. it buys and sells simultaneously, closing winning positions at grid levels and averaging breakeven points of losing positions by an order quantity multiplier. The center of the grid moves as new orders execute.
  2. Channel-static - is a stop order mode. it buys and sells simultaneously, the EA multiply quantity by a multiplier and open positions on the opposite direction. the center of the grid does not move creating a static channel.
  3. Channel-floating - same as Channel-static where the difference is the center of the grid that moves as new orders execute.

Parameters:

  1. s_MagicNumber/c_MagicNumber: Set magic number to a value greater than zero to enable the style/mode. MagicNumber is used to identify modes. It must be a different value for each mode. s for symmetry, c for channel.
  2. s_StartLotQty/c_StartLotQty: Is the initial order lot quantity, additional orders will use a multiple of this value. The default is 0.01.
  3. s_WeightQtyMulti=1: In symmetry mode, when this parameter is greater than 1, the EA will use its proprietary formulas to weight direction. If EA calculates long direction, it will multiply long s_StartLotQty by s_WeighQtyMulti for all buy orders, if it calculates short direction, it will multiply the sell orders. if the direction is unknown, none direction will be multiplied. Example, if s_WeightQtyMulti = 2 and the EA defines long and s_StartLotQty=0.01, the EA will enter 0.02 for buys and 0.01 for sells.
  4. s_GridSizePips/c_GridSizePips: the size/distance of the grid levels in pips. If Grid_Increments and Grid_Factor are used, GridSizePips will take precedence.
  5. s_GridSizeFactor/c_GridSizeFactor: When GridSizePips=0, a value from 1 to 15 can be used to calculate the grid size/distance. A small value increases the grid size and does open fewer orders, biggest values decrease grid size and scalp more. I see it as a scalping intensity level. Grid size will be calculated by using daily ATR or daily range values, divided by Grid_Factor. When GridSizeFactor and GridSizePips are both zero, ExpandGrid will use the spread in pips (not points) as grid size.
  6. s_OrderMultiplier: in symmetry mode, the value used to multiply next order quantity.
  7. s_AccumulationFiltered=true: Delay accumulation order execution by M1 fractals and M1 moving average cross over. The true value is recommended to pause execution on news releases or fast market moves.
  8. c_ChannelMultiplier: Order multiplier for Channel mode. It is used when price touches opposite direction of the grid.
  9. s_StartTime/s_EndTime, c_StartTime/c_EndTime: ExpandGrid will not open new cycles outside the time specified. Opened cycles will continue executing.
  10. c_ChannelType: Channel-static - is an stop order style. the EA multiply the quantity by a multiplier and open positions in the opposite direction. the center of the grid does not move creating a static channel. Channel-floating - same as Channel-static where the difference is the center of the grid that moves as new orders execute.
  11. TakeProfit: I do recommend keeping this value as zero (default).
  12. ProfitLevels=1: Use this parameter to override profit target in levels. Default is 1.
  13. Exit_By_M1MA=false: When this parameter is true, the EA will check first its profit target and second the mean price related to a M1 moving average. If cycle is long and price trade above M1 MA the cycle will not close. If cycle is short and price trade below M1 MA the cycle will not close. The EA will try to maximize profits.
  14. GridFactorMethod: Range_20day to use 20day range average, ATR_20day to use ATR 20 days to calculate grid distance/size when GridFactor parameter is used.
  15. PipsOffset=1: Exit order offset in pips. It is used to address latency and order execution delay. I do recommend its default value of one.
  16. Max_Money_Loss: Maximum money loss per grid style. It is recommended to keep it at zero (disabled)
  17. MaximunOrders=0: When this parameter has a value greater than zero, the EA will pause trading if accumulation orders are greater than its value.
  18. NeutralizeBalancePercent=0: Now a grid cycle can neutralize/hedge by EG104 NeutralizeBalancePercent, the default value is recommended. If you use this parameter, I do recommend values greater than 60%
  19. Expansion_Percent: Grid increasing/expanding percentage, the default is 20.
  20. FlatOnFriday: Will set the target to 0.01 and stops creating new cycles on Fridays after 14 GMT Hours.
  21. TimeToUse: Time EG104 will use when starttime/endtime is used.
  22. ResumeNTZd=false. When this parameter is false, after the cycle is neutralized/hedged, the EA will pause execution. You must continue trading manually or using TradingLines. When this parameter is true, the EA will continue trading as normal, closing and opening orders at it levels. If NeutralizeBalancePercent has a value, you may get multiple neutralization/profit taking orders. This scenario may expand the recovery zone and make the cycle look like it is losing more money.
  23. CONTINUE: It will open new grid cycle after targeted, if this parameter is set to false, the EA will stop the grid after all the positions close. ExpandGrid will continue managing opened positions.


I do continue testing and demoing this EA with the goal of finding the smaller drawdown and the best profit factor.

I do recommend checking the post 1 (this post) periodically and always check for the file uploaded date and compare it with your copy, also, when the change is significant, I do increase the version level. It is also recommended for you to keep the older copy in case you want to go back on any release.

To have files organized and to not confuse releases, I will upload EA files to post 1 only.

You all are welcome to this thread and allowed to post comments here, and it is also advised that EG has commercial intentions, the reason it is in the commercial area of this forum.

Risk disclosure: This EA is designed as instructional and illustration purposes only and it should be tested and demoed only. If you trade it live, you are doing so at your own risk and I am NOT TAKING LIABILITY if you lose your money.
==============================================================

Relevant posts:
Post 207
symmetry in action video here
Post 1,026: Trading with lines
Post 1 111 : Calculate minimum balance required
Post 1 169 : Lot Quantity recommendations.
Post 1,178: The meaning of the lines
Post 1204: Closure Mode
How to measure pips?
The Meaning of I-MinLot AvailableLots
Dynamic Grid Explained
Contract Size
EG104v032 initial rules
symmetry 034 explained
How to use i-MinLot script?

Version 035? Please Read:

Post 2293

Post 2302

M1 Filter in action

Version 036? Please read

Post 2491

Post 2547

Post 2,645

Version 038?
Post 2,847

Please post your results,
Thanks, bauta

Download files below to following locations:
...\MQL4\Experts\

EG104.ex4


...\MQL4\Scripts

ApplySettingsToAll.ex4

i-MinLot.ex4



Current Release: EG104 v038 (11/11/2017)
ApplySettingsToAll.ex4
i-MinLot.ex4
EG104.038.ex4

rajbrinder77 Jul 9, 2015 10:28am | Post# 2

hi
thanks for posing the ea here.
i just have started using it. there is two things. one there is no panding orders and second no t/p and s/l.
thanks

Blaiserboy Jul 9, 2015 10:31am | Post# 3

hi thanks for posing the ea here. i just have started using it. there is two things. one there is no panding orders and second no t/p and s/l. thanks

The design of many grids excludes TP and SL, the grid program takes care of theose at each level.

bauta Jul 9, 2015 10:32am | Post# 4

1 Attachment(s)
ExpandGrid main idea. Note this is version 103 and accumulating levels is zero. (v103-A0)
you may see an A8 version results here: http://www.forexfactory.com/bauta#69
Name:  Image2.png
Views: 32645
Size:  63 KB

bauta Jul 9, 2015 10:44am | Post# 5

hi thanks for posing the ea here. i just have started using it. there is two things. one there is no panding orders and second no t/p and s/l. thanks
No pending orders, not stop or take profits. transparent to the brokers. for your protection, you may create an EA to set stop losses and ExpandGrid will respect it.
Note that setting stop is not a good idea, you may try the parameters Max_Money_Loss or MoneyTakeProfit. I did test Max_Money_Loss of $500, $1000, $10,000 and the grid failed. in a test from 2000 to 2014 the maximum drawdown was $80,000. that is the number I do want to reduce.

FxMasterGuru Jul 10, 2015 12:17am | Post# 6

The same - very interesting - concept has been discussed on 50 pages in the following thread:

http://www.forexfactory.com/showthread.php?t=497448

"MGH EA" even had an "inside grid" functionality for extended periods while the market was ranging between the highest buy and lowest sell entry levels.

Unfortunately the DD was intolerable with all the experimental settings used for backtests, so the concept was eventually abandoned.

4xbroker Jul 11, 2015 4:54pm | Post# 7

Very interesting stuff here. I will follow this thread.

Thank you bauta. I have also posted it on my website, so I hope that you do not mind.

4xbroker Jul 11, 2015 5:13pm | Post# 8

By the way, when I try to increase the number of lots, the system keep using 0,01 lots. I biefly checked the code and I do not see any problem there, so I am slightly confused, if it is just my Metatrader or something.

meSohail Jul 12, 2015 9:50am | Post# 9

Nice effort Mr. bauta.

Both of you ideas are very well.

I am getting a little problem, I don't know this problem is with my MT4 platform or in EA
EA are opening just 5 trades in back test.

6th and more trades are not opening. In result account going empty.
please recheck them. If you set just 5 trades in the EA please code them for open more trades.

I am waiting for your reply

sohail_qasmi@yahoo.com

bauta Jul 12, 2015 11:17pm | Post# 10

By the way, when I try to increase the number of lots, the system keep using 0,01 lots. I biefly checked the code and I do not see any problem there, so I am slightly confused, if it is just my Metatrader or something.
i am using MODE_MINLOT in the Init session. in the future I will change it to use Star_Lot_Qty

bauta Jul 12, 2015 11:18pm | Post# 11

Nice effort Mr. bauta. Both of you ideas are very well. I am getting a little problem, I don't know this problem is with my MT4 platform or in EA EA are opening just 5 trades in back test. 6th and more trades are not opening. In result account going empty. please recheck them. If you set just 5 trades in the EA please code them for open more trades. I am waiting for your reply sohail_qasmi@yahoo.com
Test it with $100,000 and 10 spread.

maurineri Jul 14, 2015 4:09am | Post# 12

Really excellent work bauta, just some little adjustment needed in my opinion:

- expose as Extern bool Verbose variable (and put under this condition all objects and comments) ; this speedup testing
- add one variable to multiply grid increment every new order (to increase "cost" of any new order) ; in my experience with grids this help to have more safe trade sequece

Thank you far your share work ?

bauta Jul 14, 2015 2:06pm | Post# 13

1 Attachment(s)
Version v103.009
I did found that using smaller grid increments the drawdown vs. profit factor is better. Off course, this is scalping.
When I did test the grid, I did use 10 pips spread to cover commissions and swap costs. Please do not ask me for a way to save in commissions, I am not looking for a way to save in commission and take all the money myself, I am looking for a way to make money at the end of the day.
Now I am calculating the grid increments using daily ATR averages on every order as [maurineri ] recommended it on post 12. Because grid is calculated, now ExpanGrid may be used in different pairs, I like EUSUSD, GBPUSD, AUDUSD, USDCHF and NZDUSD. I am not in any of JPY yet. It must be tested.
ExpanGrid starts with the minimum lot quantity; in the future I will open the Start_Lot_Qty parameter. Ignore it for now.
Also I did add one more lot to the quantity, the formula to buy now is:
lastSellQty * gridSize+1 in levels + (minimunLot*2) - opened buy quantity.
Example: Buy 0.01, sell 0.04, buy 0.14-0.01, sell 0.58-0.04 and so on.
The quantity is bigger and the grid size is smaller, this combination speed up the grid.
I do recommend you to test it a least 10 years and demo for more than one month. When demo it, duplicate it using two charts with different magic numbers.
I am working now in the optimal accumulation levels, this version accumulates only one level. (See post 1)
Note that ExpandGrid will not open new positions on the second haft of Fridays.
After I completed testing, I will supply the source code.

PLEASE DO NOT TRADE IN LIVE ACCOUNT. this is a working in progress EA. Use it at your own risk.
ExpandGrid v103.009.ex4

PowerTrade Jul 14, 2015 2:16pm | Post# 14

Suscribed.

bauta Jul 14, 2015 4:44pm | Post# 15

I did linked my Explorer ExpandGrid103A1 to track performance. I did open an $50,000, 1:100 leverage demo account and I trading 4 charts of EURUSD, 4 charts of GBPUSD, 2 charts of AUDUS and 2 charts of NZDUSD. using different magic numbers to separate them. Lets play this for longer to see what's happens.

maurineri Jul 15, 2015 6:12am | Post# 16

Version v103.009 I did found that using smaller grid increments the drawdown vs. profit factor is better. Off course, this is scalping. When I did test the grid, I did use 10 pips spread to cover commissions and swap costs. Please do not ask me for a way to save in commissions, I am not looking for a way to save in commission and take all the money myself, I am looking for a way to make money at the end of the day. Now I am calculating the grid increments using daily ATR averages on every order as [maurineri ] recommended it on post 12. Because...
Hi bauta,
I think that it not really sustainable to make more thna 7-8 levels.. in my opinion obviously..
To fit risk adversion of different people I suggest you to "open" LotSize parameters as extern , related to trade level:

extern double LotSize_1 = 0.01;
extern double LotSize_2 = 0.02;
extern double LotSize_3 = 0.04;
extern double LotSize_4 = 0.08;
extern double LotSize_5 = 0.16;
extern double LotSize_6 = 0.32;
extern double LotSize_7 = 0.64;
extern double LotSize_8 = 1.28;

and assign related size to next order with switch structure.

If you share your last code I can contribute a little, just my two cents

gufi79 Jul 15, 2015 7:16pm | Post# 17

hi
also I started testing on Monday 07-13, on 7 pairs with different levels of grind: 12pps for pairs like AUD / USD 24pps for pairs like EUR / USD. We will see.
But I have a few suggestions
1. To reduce the risk and set the levels as maurineri written (as earlier I thought) transactions could be carried out on 2 levels. The first entry level and second on the grid away (down if we started from buying or up if we started sales) and of course the TP lvl well worth grid. example
(Prices are exemplary, grid 50pps)
a) buy 0.01lot at 1.0000 - TP: 1.0050
then if the price falls
b) sell 0.02lot set at 0.9950 and 1.0000 TP
then if the price rises
c) buy 0.04lot at 1.0000 - 1.0050 TP
and so on
when one of the directions reaches TP lvl it close the remaining transactions at a loss. always we earn 50pps with 0.01lot
in such an arrangement, nine transaction is at the level of 2,56lot (for the current system already the fifth transaction is at this level).
2. Can it be possible to introduce something like that: if we are already such transactions lvl 4th or 5th or 6th This was summed to profit from all open positions and if it reaches the level we are interested in $ (set in the parameters of the strategy) can be positive or negative (you can put up with a small loss at high risk). Then all trades are closed and start over again from the level of 0.01. This makes sense because a few times I've seen it lacked 2-3pps on the graph to close. but then it turn back and did the next transaction for 13lots and DD was huge. even if the whole came to a small plus its not worth it.

Greetings
(Text translated by google translate)

AshrafHonda Jul 15, 2015 7:56pm | Post# 18

Suscribed.
Hi, We try the ExpandGrid_v103, Gived good results stable - Is Ver. 103.009 is better?
Thanks
Ashraf

bauta Jul 15, 2015 11:09pm | Post# 19

{quote} .... LotSize_1 = 0.01; extern double LotSize_2 = 0.02; extern double LotSize_3 = 0.04; extern double LotSize_4 = 0.08; extern double LotSize_5 = 0.16; extern double LotSize_6 = 0.32; extern double LotSize_7 = 0.64; extern double LotSize_8 = 1.28; and assign related size to next order with switch structure. ..
Thanks [maurineri]. Note I am working in an accumulation mode before start expanding the grid. I am using the quantities you recommending but deferent way.
Example: buy 0.01 and if market goes down to grid then buy 0.02, if continues buy 0.04, then buy 0.08, 0.16, 0.32, 0.64 and so on. (Doubling the last qty).
I and testing now 10 levels accumulating with grid size of daily ATR divided by 8. What I am trying to do is accumulate at least 120% of daily ATR move, then start expanding.
I am testing 15 years, from 2000 to 2014, it will take some time. I am increasing grid size and decreasing accumulating levels and retesting again. At the end I will choose the best drawdown vs profit factor.
thanks,
bauta

maurineri Jul 16, 2015 2:44am | Post# 20

{quote} Thanks [maurineri]. Note I am working in an accumulation mode before start expanding the grid. I am using the quantities you recommending but deferent way. Example: buy 0.01 and if market goes down to grid then buy 0.02, if continues buy 0.04, then buy 0.08, 0.16, 0.32, 0.64 and so on. (Doubling the last qty). I and testing now 10 levels accumulating with grid size of daily ATR divided by 8. What I am trying to do is accumulate at least 120% of daily ATR move, then start expanding. I am testing 15 years, from 2000 to 2014, it will take some...
Hi bauta,
can you share setting of yours trials, please ?
I am searching in my old grid/hedge works some expedient for yourEA , to gain time is better to have your settings.
Thank you
maurizio


© Forex Factory