# Internal grid ea

#### saambasp

##### Member
HI FRIENDS,
i hope my forex hunt is stopped for some days.i think i finally solved solution to range and trend markets with my internal grid idea.it is developing from nearly 3 years,finally after seeing back test of dream builderfx ,i find solution to this.iam going to trade manually from today.if somebody study this and code would be great for all.
thank you

#### Attachments

• Internal Grid 1.doc
27.5 KB · Views: 2

#### lerxst

##### Member
Hello MS Reddy,

Thanks for sharing this method and document with all of us. So from what I can understand, we would initially place orders on both sides up or down. For example.

Let's say market is in downtrend at 1.3100 we then sell at 1.3100, 1.3090, 1.3080 until 30 pips is reached. At the other side, we also have sell limits above, so at 1.3110, 1.3120, etc. Close basket for 30 pips total. If direction goes against the last buy/sell order by 70 points, then we start going opposite direction.

I hope that this is correct, once again, great explanation and document.

#### saambasp

##### Member
hello ms reddy,

thanks for sharing this method and document with all of us. So from what i can understand, we would initially place orders on both sides up or down. For example.

Let's say market is in downtrend at 1.3100 we then sell at 1.3100, 1.3090, 1.3080 until 30 pips is reached. At the other side, we also have sell limits above, so at 1.3110, 1.3120, etc. Close basket for 30 pips total. If direction goes against the last buy/sell order by 70 points, then we start going opposite direction.

I hope that this is correct, once again, great explanation and document.
hi,
you are right.if market is down trend we do 7 sell orders with 10pips interval like you said 1.3080,1.3090,1.3100,1.3110,1.3120,1.3130,1.3140
then 1.3150is buy order.
Our basket profit is 30usd not 30 pips
.thank you for following .i can explain with patience.
This system defenetley going to strike

#### jvmgupta

##### Member
i think this system is perfect for range and trend markets.please somebody code it
jvm gupta

#### maximo

##### Member
Okay I'll attempt to clarify this strategy from what I see.

Buy signal from indicator: Trade in buy direction opening buys at 10 pip intervals, closing them at 70 pips from first buy.

Sell signal from indicator: Trade in sell direction opening sells at 10 pip intervals, closing them at 70 pips from first sell.

Now the bit that is not so clear is, do we continue trading in direction of trend or do we reverse/counter trend orders?

I have coded a couple of grid systems, the biggest problem is getting stuck with a bunch of unclosed orders in the wrong direction.

#### saambasp

##### Member
okay i'll attempt to clarify this strategy from what i see.

buy signal from indicator: trade in buy direction opening buys at 10 pip intervals, closing them at 70 pips from first buy.

sell signal from indicator: trade in sell direction opening sells at 10 pip intervals, closing them at 70 pips from first sell.

Now the bit that is not so clear is, do we continue trading in direction of trend or do we reverse/counter trend orders?

I have coded a couple of grid systems, the biggest problem is getting stuck with a bunch of unclosed orders in the wrong direction.
hi max,
yes you are right ,in grid systems there is problem of unclosed orders in wrong direction.
Here in this internal grid system ,iam aware what you said and that is the problem in grid systems.
After i seen back test of dream builder fx .my idea clear
in this internal grid system we close some part of orders with some basket profit.that too we close orders from bottom or top[like you said wrong direction orders]remaining orders will be there.so we close orders part and part.
To your question answer is after close all orders with profit.next we go along with trend.
Max my request is please go through my word document ,you understand first step well ,the second step is crucial in this internal grid .i will explain pin by pin to your questions

##### Member
saambasp, one thing for clarification:
The basket profit is taken with maximum 20 Long and 7 Sells or vice versa if price finally gets to the outer range and goes far enough.

But what if price reverses and opens more Sells ?

For example: 20 Longs are active and now 20 Shorts are active too.

Then price reverses again and opens more Longs above the last Long.

Then price reverses again and now we have 40 Longs and 40 Shorts and we only sail along in big Draw-down ?

#### saambasp

##### Member
saambasp, one thing for clarification: The basket profit is taken with maximum 20 long and 7 sells or vice versa if price finally gets to the outer range and goes far enough. But what if price reverses and opens more sells ? For example: 20 longs are active and now 20 shorts are active too. Then price reverses again and opens more longs above the last long. Then price reverses again and now we have 40 longs and 40 shorts and we only sail along in big draw-down ?

hi best fx,
my idea is partial closed grid ea.please go through my document.

step 1.
After 7 sells and 7 longs.price moves upper then we take buy orders up to 19 then close 7sells and 19 longs.this is ok
2.but like you said.
after 7 sells and 7 longs price reversed we take sell orders below 70 pips here price moved down 70 pips so we take 7 sell if price continuously down we take sell orders with 10 pips interval untill we reach basket profit.in another case after 7 sells price reversed then from last sell porder 70 pips up we start buy orders.like that buy sell mess forms .now the strategy works from bottom we have 14 sells and 27 buys[7+7+13]we close 7sells and 19 buys.now the existings are 7 sells and 9buys if price moves up we take continouous buys when bottom 7 seels fullfill with buy 19 or more buy orders we close bottom sell orders.in between some gaps happen .that is not a problem.when price retrace that gaps fill.
Here the logic is close bottom sell orders or top buy orders with middle or above/ below opposite orders
here we wont fix to 7 sells 19 buys.we close as per necessity like 6 sells and 17 buys or 5 sells and 15 buysor 4 sells and 13 buys [if some gap happen middle buy /sell orders take profit increase.

The difference between normal grid and internal grid is
1.we dont carry all open postions untill we reach final basket profit ,we close partial orders from bottom or top.
2.like maximo said in grid systems bunch of unclosed orders in wrong direction ,here in internal grid system we close wrong direction orders[top buy orders and bottom sell orders] first sothat if we can go by trend.

Internal grid main rules that deffers to normal grid
---------------------------------------------------------
1.we start opposite orders from end sell /buy orders WITH 70 PIPS
2.we close partial orders with basket profit reached[from bot tom or top]
3.we have options to close orders with these basket profit
7 sells and 19 buys
6 and 17
5and 15
4 and 13
[this would help in gaps.

I have clear idea on this system ,iam developing this from last 2 years,but because of my average english knowledge i think that iam unable to explain perfectly

here i asked my friends express your doubts.and identify the big drawdown situation.10 of my friends or working to find 20% above draw down situations

we do this with proper money managent ,i identified 5000usd for 0.01 lot expected return 10% month .drawdown 20% maximum

thank you for listening

##### Member
saambasp,
thanks for clarification.

I already coded an EA with my wrong understanding and since I don?t know mql , it took me 2 hours to manage to get all the pending and active orders closed.

I used routines from other EAs for closing all open and pending orders and they work, but in my EA they left many orders open.

Implementing the correct strategy is too complicated for me.
The logic is clear but how to code it is not clear for me.

I hope that maximo or Stovedude or the other good coders will help.

The advantage of your internal grid is the partial close.

I have read a thread on ForexPeaceArmy from williama who said that he makes 100 - 500 % monthly with his grid strategy.
He attracted much attention - in order to get clients for managing their funds - and then he lost 100k from his clients within some weeks
because his strategy wasn?t as brilliant as he had made it to appear.

He used to pile up orders on both sides of the median line but not as you do. If price whipsawed he could get many orders on the same level and then he started to double or triple the lot-size and did not understand that it was a martingale strategy.

Ok, in your grid it can happen that you have a Sell and a Buy order at the same price-level, could be even more Buys and Sells if price whipsaws,
but it should clear up soon because of the partial close ( 7 against 19 ).

Great idea.
Maybe others experimented with it before, but I haven?t seen it anywhere so far.

#### saambasp

##### Member
saambasp,
thanks for clarification.

I already coded an EA with my wrong understanding and since I don?t know mql , it took me 2 hours to manage to get all the pending and active orders closed.

I used routines from other EAs for closing all open and pending orders and they work, but in my EA they left many orders open.

Implementing the correct strategy is too complicated for me.
The logic is clear but how to code it is not clear for me.

I hope that maximo or Stovedude or the other good coders will help.

The advantage of your internal grid is the partial close.

I have read a thread on ForexPeaceArmy from williama who said that he makes 100 - 500 % monthly with his grid strategy.
He attracted much attention - in order to get clients for managing their funds - and then he lost 100k from his clients within some weeks
because his strategy wasn?t as brilliant as he had made it to appear.

He used to pile up orders on both sides of the median line but not as you do. If price whipsawed he could get many orders on the same level and then he started to double or triple the lot-size and did not understand that it was a martingale strategy.

Ok, in your grid it can happen that you have a Sell and a Buy order at the same price-level, could be even more Buys and Sells if price whipsaws,
but it should clear up soon because of the partial close ( 7 against 19 ).

Great idea.
Maybe others experimented with it before, but I haven?t seen it anywhere so far.

hi bestfx,
i dont know somebody used this partial close idea,but as iam a mathematician i daily excersice with numbers with my students may be i got this.if some of us cleary understand this and clearly explain here with some examples so that our great forum coders like SD and MAX could write easily as iam unable to explain them clearly because of language problem.
bestfx if you understand clearly this system please explain here with some examples in word or pdf document
thankyou
the main reason in partial close from bottom or top,let give way to trend and decrease open orders

##### Member
saambasp,
you summarized it well :

Internal grid main rules that deffers to normal grid
---------------------------------------------------------
1.we start opposite orders from end sell /buy orders WITH 70 PIPS
2.we close partial orders with basket profit reached[from bot tom or top]
3.we have options to close orders with these basket profit
7 sells and 19 buys
6 and 17
5and 15
4 and 13
[this would help in gaps.
In my words:

Somewhere the very first market-order is placed.
Long or Short ?
Depends on the trend-filter .

Let us assume we place a BUY order.
We hope that price will move up to give us 30 Dollars profit.

The first LONG-Grid :

6 BUYSTOP orders above the initial BUY order, distance 10 Pips each.
6 BUYLIMIT orders below the intial BUY order, distance 10 Pips each.

Let us assume that price doesn?t go up, so the second BUYSTOP will
not be opened, but price moves down, against the up-trend which
the trend-filter showed.

Att 70 Pips distance below the initial BUY order,
the first SELLSTOP order must be placed.

10 Pips below, the second SELLSTOP order must be placed.
10 Pips below, the 3rd SELLSTOP ......
10 Pips below, the 4th SELLSTOP ..... etc.

This is not all.

If price moves 70 Pips down from our initial BUY order, the first SELLSTOP order will be opened.

The rule says: 70 Pips distance from the top or bottom of the active orders (those opened, not pending) , the opposite pending order must be placed.

----> We must place a BUYSTOP order 70 Pips above the lowest active SELL order.

Where is that ?

It is at the entry-price of our initial BUY market order.
There we place a BUYSTOP order.

If price moves another 10 Pips down,
the second SELLSTOP order ( 80 Pips below the initial BUY market order ) will be opened.

Now we have 2 active SELL orders and 7 active BUY orders.

The lowest active SELL order is 80 Pips away from the initial BUY order.

The rule says: 70 Pips distance from the top or bottom of the active orders (those opened, not pending) , the opposite pending order must be placed.

----> We must place a BUYSTOP order 70 Pips above the lowest active SELL order.

At 70 Pips above the lowest active SELL order we find our second BUY order (10 Pips higher is the initial BUY market order, the second active BUY order has been our first BUYLIMIT order at the beginning).

If price moves another 10 Pips down,
the third SELLSTOP order is opened .......
we need to place a corresponding BUYSTOP order 70 Pips above.
(the 3rd BUY order which has been the second BUYLIMIT before)

This goes on every 10 Pips the price moves further down.

----------------------------------------------------------------------------

saambasp,
is this description correct ?

#### saambasp

##### Member
saambasp,
you summarized it well :

In my words:

Somewhere the very first market-order is placed.
Long or Short ?
Depends on the trend-filter .

Let us assume we place a BUY order.
We hope that price will move up to give us 30 Dollars profit.

The first LONG-Grid :

6 BUYSTOP orders above the initial BUY order, distance 10 Pips each.
6 BUYLIMIT orders below the intial BUY order, distance 10 Pips each.

Let us assume that price doesn?t go up, so the second BUYSTOP will
not be opened, but price moves down, against the up-trend which
the trend-filter showed.

Att 70 Pips distance below the initial BUY order,
the first SELLSTOP order must be placed.

10 Pips below, the second SELLSTOP order must be placed.
10 Pips below, the 3rd SELLSTOP ......
10 Pips below, the 4th SELLSTOP ..... etc.

This is not all.

If price moves 70 Pips down from our initial BUY order, the first SELLSTOP order will be opened.

If price moves another 10 Pips down,
the second SELLSTOP order ( 80 Pips below the initial BUY market order ) will be opened.

Now we have 2 active SELL orders and 7 active BUY orders.

The lowest active SELL order is 80 Pips away from the initial BUY order.

The rule says: 70 Pips distance from the top or bottom of the active orders (those opened, not pending) , the opposite pending order must be placed.

----> We must place a BUYSTOP order 70 Pips above the lowest active SELL order.

At 70 Pips above the lowest active SELL order we find our second BUY order (10 Pips higher is the initial BUY market order, the second active BUY order has been our first BUYLIMIT order at the beginning).

If price moves another 10 Pips down,
the third SELLSTOP order is opened .......
we need to place a corresponding BUYSTOP order 70 Pips above.
(the 3rd BUY order which has been the second BUYLIMIT before)

This goes on every 10 Pips the price moves further down.

----------------------------------------------------------------------------

saambasp,
is this description correct ?

yes best fx,
sofar you said correct,explain the next part which is most important.and if you write whole in a word document it is better.
it is good that you are explaining for coders simple understanding.
thank you for work on this .let we make perfect internalgrid ea

#### Richo

##### Member
I am following this thread with great interest, I hope we can get an EA developed to test it
Keep up the good work

#### lerxst

##### Member
Hi Saambasp,

Thanks for the response. If the basket close is set a 30 USD and not 30 pips, that means if we start with 0.01 lot; the total amount of pips is 300 pips for a basket closure? (If 0.01 lot = 1000 contract value, and so 0.01 EURUSD lot would equal to 0.10 per pip).

Just wanted to clear this up.

Best

#### hawkfx

##### New member
saambasp may I know where you from? Maybe I can get a person from your country/language so he could write better.

##### Member
Hi Saambasp,

Thanks for the response. If the basket close is set a 30 USD and not 30 pips, that means if we start with 0.01 lot; the total amount of pips is 300 pips for a basket closure? (If 0.01 lot = 1000 contract value, and so 0.01 EURUSD lot would equal to 0.10 per pip).

Just wanted to clear this up.

Best

That is correct, lerxst. ( saambasp will confirm )

Example LONG Grid:
Initial Long Market order = BUY-1

Pips moved
----------------
Total : 301

Market moved 73 Pips up .
Because we have a Buy-Stop every 10 Pips,
7 BUY orders are active and we get
301 Pips x \$0.10 = \$30.10

In a live account, the closure of all 7 active orders will take some time
and market can move up (= higher profit) or down (= less than 30 Dollars profit)

##### Member
saambasp,
you summarized it well :

In my words:

Somewhere the very first market-order is placed.
Long or Short ?
Depends on the trend-filter .

Let us assume we place a BUY order.
We hope that price will move up to give us 30 Dollars profit.

The first LONG-Grid :

6 BUYSTOP orders above the initial BUY order, distance 10 Pips each.
6 BUYLIMIT orders below the intial BUY order, distance 10 Pips each.

Let us assume that price doesn?t go up, so the second BUYSTOP will
not be opened, but price moves down, against the up-trend which
the trend-filter showed.

Att 70 Pips distance below the initial BUY order,
the first SELLSTOP order must be placed.

10 Pips below, the second SELLSTOP order must be placed.
10 Pips below, the 3rd SELLSTOP ......
10 Pips below, the 4th SELLSTOP ..... etc.

This is not all.

If price moves 70 Pips down from our initial BUY order, the first SELLSTOP order will be opened.

The rule says: 70 Pips distance from the top or bottom of the active orders (those opened, not pending) , the opposite pending order must be placed.

----> We must place a BUYSTOP order 70 Pips above the lowest active SELL order.

Where is that ?

It is at the entry-price of our initial BUY market order.
There we place a BUYSTOP order.

If price moves another 10 Pips down,
the second SELLSTOP order ( 80 Pips below the initial BUY market order ) will be opened.

Now we have 2 active SELL orders and 7 active BUY orders.

The lowest active SELL order is 80 Pips away from the initial BUY order.

The rule says: 70 Pips distance from the top or bottom of the active orders (those opened, not pending) , the opposite pending order must be placed.

----> We must place a BUYSTOP order 70 Pips above the lowest active SELL order.

At 70 Pips above the lowest active SELL order we find our second BUY order (10 Pips higher is the initial BUY market order, the second active BUY order has been our first BUYLIMIT order at the beginning).

If price moves another 10 Pips down,
the third SELLSTOP order is opened .......
we need to place a corresponding BUYSTOP order 70 Pips above.
(the 3rd BUY order which has been the second BUYLIMIT before)

This goes on every 10 Pips the price moves further down.

----------------------------------------------------------------------------

saambasp,
is this description correct ?

saambasp,
from here I need more clarification from you.

In my example the trend signal was UP
but price never went to the first BUYSTOP, it went 80 Pips down instead.

We have 7 active BUY orders in Drawdown
and 2 active SELL orders.

Example with price-levels:

BUY-1: 1.4000 + BUY-STOP (corresponding from SELL-1)
BUY-2: 1.3990 + BUY-STOP (corresponding from SELL-2)
SELL-1: 1.3930
SELL-2: 1.3920

But this is only part of the picture.

The EA placed 6 BUY-STOP orders above the initial BUY market order (BUY-1 at 1.4000).

I will expand the picture step by step to get your confirmation, if it is wrong or correct.

Here is the situation with the initial BUY-STOP orders.

There must be more BUY-STOP-orders above, but for now
I am asking if you would place the additional Buy-Stop orders which I
put in red color.
I would not place them because we would then pile up more Sell-Stop orders if price would reverse .
Please clarify this point, then I can move on with the description.

BUY-STOP-2: 1.4020 ?? + BUY-STOP (to get the basket profit earlier)
BUY-STOP-1: 1.4010 ?? + BUY-STOP (to get the basket profit earlier)
BUY-1: 1.4000 + BUY-STOP (corresponding from SELL-1)
BUY-2: 1.3990 + BUY-STOP (corresponding from SELL-2)
SELL-1: 1.3930
SELL-2: 1.3920
SELL-STOP: 1.3910
SELL-STOP: 1.3900
SELL-STOP: 1.3890
SELL-STOP: 1.3880
SELL-STOP: 1.3870
SELL-STOP: 1.3860
....
....
.... Total Sell orders (active + pending) = 19 because 7 Buys are active
and if price moves further down, we would need 19 Sells to get
the basket profit of \$30 .

#### saambasp

##### Member
hi best fx,
i feel i found clever person like you.i think you understand well, how grid strategies convert into martingale strategies .you are going nice.for your question i think i explained in document answer is,if we make extra buystop orders it convert as martingale system that we dont like.we have to put one buystop order row.because of this after close one 7-19 there made some gap between sell and buy orders .it wont bother us because we are in trend we expect trend buy so if price keep increasing our buy orders also inrease at one point we get our basket profit .in other case if price retrace then easily our gap fills.here is some exampl
buy-1.4100 here no extra order
[from here one order as usual]
SELL-1: 1.3930 + buy
SELL-2: 1.3920
SELL-3 1.3910
SELL-4: 1.3900
SELL-5: 1.3890
SELL-6: 1.3880
SELL-7: 1.3870
SELL-8: 1.3860price reverse here

##### Member
saambasp,
thanks for clarification.
The picture gets clearer as we progress.

But I still have questions because a coder looks a bit differently on a strategy than a non-coder.

Ok, here is the situation:

BUY-STOP-7: 1.4070 (placed when BUY-1 was opened)
BUY-1: 1.4000 + BUY-STOP (corresponding from SELL-1)
BUY-2: 1.3990 + BUY-STOP (corresponding from SELL-2)
BUY-3: 1.3980 + BUY-STOP (corresponding from SELL-3)
BUY-4: 1.3970 + BUY-STOP (corresponding from SELL-4)
BUY-5: 1.3960 + BUY-STOP (corresponding from SELL-5)
BUY-6: 1.3950 + BUY-STOP (corresponding from SELL-6)
BUY-7: 1.3940 + BUY-STOP (corresponding from SELL-7)
SELL-1: 1.3930 + BUY-STOP (corresponding from SELL-8)
SELL-2: 1.3920
SELL-3: 1.3910
SELL-4: 1.3900
SELL-5: 1.3890
SELL-6: 1.3880
SELL-7: 1.3870
SELL-8: 1.3860
Price reversed here and went up.
My idea for the trading logic: always place the next SELL_STOP 70 Pips
away from the lowest active SELL order.
I explain later.
If we do that , we have 7 SELL_STOP orders below the 1.3860 level
SELL-STOP-1: 1.3850 (placed when SELL-2 was triggered)
SELL-STOP-2: 1.3840 (placed when SELL-3 was triggered)
SELL-STOP-3: 1.3830 (placed when SELL-4 was triggered)
SELL-STOP-4: 1.3820 (placed when SELL-5 was triggered)
SELL-STOP-5: 1.3810 (placed when SELL-6 was triggered)
SELL-STOP-6: 1.3800 (placed when SELL-7 was triggered)
SELL-STOP-7: 1.3790 (placed when SELL-8 was triggered)

Here is my suggestion for the EA logic:

Place_Long_Grid function:
Opens initial BUY market order.
Places 6 BUY_STOP orders above
Places 6 BUY_LIMIT orders below

Place_Short_Grid function:
Opens initial SELL market order
Places 6 SELL_STOP orders below
Places 6 SELL_LIMIT orders above

for each active buy order :
a) if no corresponding BUY_STOP at 70 Pips distance from OrderOpenPrice exists ----> place BUY_STOP there
b) if no corresponding SELL_STOP at 70 Pips distance below
OrderOpenPrice exists ----> place SELL_STOP there

Check SELL function:
for each active Sell order (not pending orders but open orders):
a) if no corresponding BUY_STOP at 70 Pips distance above exists
------> place BUY_STOP there
b) if no corresponding SELL_STOP at 70 Pips distance below exists
-------> place SELL-STOP there

With these functions most of the work is done.
Only necessary corresponding orders are placed (for active BUY and SELL orders).

The rest is the profit check function:
Summarize the profit or loss of each active order ( OP_BUY and OP_SELL ).
If Order.Profit >= Basket.Profit.Dollars
??? here it may get complicated.
If all open and pending orders would be closed, it would be easy.
But there might be a partial closure of the active orders only,
starting at the bottom or top of the active range.

#### maximo

##### Member
I agree with lerxst in that TakeProfit should be in pips as that does not change according to lotsize, thanks. Apples is apples hehe.

Thanks bestfx-trader, I'm understanding most of it now, but I have 3 questions that should complete enough knowledge to do the coding.
These questions are directed to either saambasp or yourself.

1. On closing of TakeProfit do we open the next order and set another 6 pending orders above and below this?

2. If the market keeps heading down with your example, what happens to the 7 to 14 buy orders, which some would be filled?

3. What happens when an opposite signal comes from the indicator? Do we ignore this and just open orders according to the grid?
I know the indicator direction will be exact to the grid orders at first, but after some time a difference will grow between the grid and the indicator signal. How do we resync the grid to the indicator signal? This may only be a few pips later on, but may need to adjust grid then if indicator is important.

This strategy looks logically sound. Always trading in the direction of the trend and trades within the noise zone of that trends direction. I hope we have a positive outcome from this strategy

#### saambasp

##### Member
yes best,
you are right check basket profit sets from whole open orders[from bottom or top] is bit difficult to code.i think coding this logic is harder than normal eas,coder must have grid knowledge and mathematical internals for partial close.after partial close identify the remaining open orders and check profitable sets from them,i think it is difficult to check profitable sets.
if i will give an idea to this is .for some days we do this as semi auto mated like ea continuosly taking postions as per our [70pips opposite pattern].
you said making grid mess is easy,i also hope so.but closing orders is difficult thats why some days we can use it as semi auto type ea,then fully auto mated.
what do you say best fx?

##### Member
maximo,
I am glad you will help.
I will answer between the lines.

I agree with lerxst in that TakeProfit should be in pips as that does not change according to lotsize, thanks. Apples is apples hehe.

The only problem I have (besides not knowing how to code the logic in mql) is the TakeProfit part of the strategy.

I have started to create an excel spreadsheet for the calculation of the levels to get a picture about the profit or loss at each level,
but I would not be able to transfer that into a program-logic right now.

Thanks bestfx-trader, I'm understanding most of it now, but I have 3 questions that should complete enough knowledge to do the coding.
These questions are directed to either saambasp or yourself.

1. On closing of TakeProfit do we open the next order and set another 6 pending orders above and below this?

If we only have 7 active Buys and hit Basket-Take-Profit, the answer
is easy: Close all active and pending orders,
then check the trend-indicator and open either
an initial Long or initial Short and fill up with 6 pending orders above and below the initial market order.

I would close everything in case of 7 Buys and 19 Sells too if Basket-Profit is reached and start with a complete new grid.

But for all other cases ( 8 Buys and ??? Sells or whatever ) I have no
clear understanding yet.

Hopefully saambasp can help.

2. If the market keeps heading down with your example, what happens to the 7 to 14 buy orders, which some would be filled?

BUY-STOP-7: 1.4070 (placed when BUY-1 was opened)
BUY-1: 1.4000 + BUY-STOP (corresponding from SELL-1)
BUY-2: 1.3990 + BUY-STOP (corresponding from SELL-2)
BUY-3: 1.3980 + BUY-STOP (corresponding from SELL-3)
BUY-4: 1.3970 + BUY-STOP (corresponding from SELL-4)
BUY-5: 1.3960 + BUY-STOP (corresponding from SELL-5)
BUY-6: 1.3950 + BUY-STOP (corresponding from SELL-6)
BUY-7: 1.3940 + BUY-STOP (corresponding from SELL-7)
SELL-1: 1.3930 + BUY-STOP (corresponding from SELL-8)
SELL-2: 1.3920
SELL-3: 1.3910
SELL-4: 1.3900
SELL-5: 1.3890
SELL-6: 1.3880
SELL-7: 1.3870
SELL-8: 1.3860
SELL-STOP-1: 1.3850 (placed when SELL-2 was triggered)
SELL-STOP-2: 1.3840 (placed when SELL-3 was triggered)
SELL-STOP-3: 1.3830 (placed when SELL-4 was triggered)
SELL-STOP-4: 1.3820 (placed when SELL-5 was triggered)
SELL-STOP-5: 1.3810 (placed when SELL-6 was triggered)
SELL-STOP-6: 1.3800 (placed when SELL-7 was triggered)
SELL-STOP-7: 1.3790 (placed when SELL-8 was triggered)

Price is around 1.3860 right now.
If price goes up again and opens all 8 BUY-STOPs or some of them,
then again turns down,
we would need much much more distance for the price to go down
than before.

Some would therefore place additional SELL-STOPs ( 70 Pips below each BUY-STOP which is triggered )
and if you have a simple function which I suggested for checking the SELL and BUY orders and then placing a corresponding limit-order above and below,
the additional SELL-STOPS and BUY-STOPS would automatically placed
by the EA.

Here is the question for saambasp:
Would you do this ?

Advantage: Distance to hit Basket-Take-Profit is lower.
Disadvantage: More orders piling up ..... the Drawdown will increase.

The more I think about it, the more I tend to let the EA place the additional
limit orders for each of those BUY-STOP-orders which gets triggered.
Why ?
Because that triggered BUY-STOP-order which now is an active BUY order
represents the top of the Sell-Grid within the initial BUY-Grid ( I hope you understand this wording ).
We can view the initial Long-Orders as Long-Grid-1,
the Short-orders starting 70 Pips below the initial Buy-market order as
Short-Grid-1
and the additional BUY-STOP-orders triggered by the active Sell orders
as Long-Grid-2 .

Per our rules, the Long-Grid-2 demands a corresponding Short-Grid.
Therefore yes, each triggered BUY-STOP-level has to result in
a BUY-STOP order 70 Pips above and a SELL-STOP order 70 Pips below.

Since we have an active SELL order 70 Pips below the triggered BUY-STOP,
the already existing CHECK_SELL function will place that new SELL-STOP
order.
The CHECK_BUY function will fail to place the corresponding BUY-STOP 70 Pips above because there is already a BUY-STOP (triggered by SELL-1 in the above example). This needs more thinking for the coder.
We need that second BUY-STOP there.

3. What happens when an opposite signal comes from the indicator? Do we ignore this and just open orders according to the grid?
I know the indicator direction will be exact to the grid orders at first, but after some time a difference will grow between the grid and the indicator signal. How do we resync the grid to the indicator signal? This may only be a few pips later on, but may need to adjust grid then if indicator is important.

I would not care about the indicator once a grid is active.
It will get too complicated I think.
Better let the active grid come to an end ( when all active and pending orders can be closed ),
then checking the indicator and starting a new grid.

This strategy looks logically sound. Always trading in the direction of the trend and trades within the noise zone of that trends direction. I hope we have a positive outcome for this strategy

#### saambasp

##### Member
HI BEST,
'But for all other cases ( 8 Buys and ??? Sells or whatever ) I have no
clear understanding yet.,
ANSWER IS NO PROBLEM OF 7 ABOVE BUYS.WE CLOSE 7 BUYS AND LEAVE REMAINING BUYS.IN THAT CASE WE HAVE 1 BUY REMAIN.
IT CAN BE CLOSED WITH OTHER BUYS.FROM TOP THERE IS 1 OR 2,3, BUYS REMAIN WE CAN CLOSE THEM WITH
1BUY- 3SELLS SET[IF GAP HAPPENED BETWEEN BUY SELL ORDERS TP INCREASES.
3 BUYS-8 SELLS SET .
THE MAIN POINT IS,
TOP BUY AND BOTTOM SELL ORDERS SHOULD CLOSE FIRST WITH OPPOSITE ORDERS
FOR CLOSING TOP BUY ORDERS AND BOTTOM SELL ORDERS WE USE EXISTING BEST SETS.
ANOTHER ONE.
'More orders piling up ..... the Drawdown will increase'
FOR THIS WE USE 0.01 LOT FOR 5K ACCOUNT PER 1 PAIR .IF WE CLOSE 20ABOVE BASKET PROFITS PER MONTH IT IS MORE THAN 10% RETURN.
IF 200 BUY,SELL ORDERS ARE THER THAT IS 2 LOT WITH MAXIMUM HEDGING ORDERS,MORE OVER OUR BASKET PROFIT IS NEARER SO SOME ORDERS CONTINUOUSLY CLOSING.

#### maximo

##### Member
I think I fully understand the logic in simplest terms now

The TakeProfit cannot be set in pips, because we are running off a positive basket profit to exit and close all?

That means pips in either direction cannot be a set value because the number of orders opened is variable and that affects how many pips it will be to reach the basket profit. So a profit value in dollar terms must be set.

This is trading in the direction of the trend and if thats not working out it begins hedging in the opposite direction. If it continues it will reach basket profit. If it reverses again before basket profit is reached it may open more orders in the other direction again to reach basket profit. At some stage the trader must profit!

Perhaps this is why brokers in the United States have banned hedging, the smart ones have found a way to beat the system.

saambasp you are a genius!