# Amazing

#### Forex-Fox

##### Newbie
Dear Enivid,

thank you for sharing this great EA with us. I'm trying to get through the lines and understand the algorithm. Right now I have some trouble to get behind the Break-Even Function. Could you explain the algorithm and what it does in just a few sentences?

With the best wishes for 2015,
Forex-Fox (Germany)

#### Enivid

##### Administrator
Staff member
Dear Enivid,

thank you for sharing this great EA with us. I'm trying to get through the lines and understand the algorithm. Right now I have some trouble to get behind the Break-Even Function. Could you explain the algorithm and what it does in just a few sentences?

With the best wishes for 2015,
Forex-Fox (Germany)
It is pretty straightforward. DoBE() function is called every tick if Break-Even pips are set via input parameter. The function searches all orders on the current symbol and that originated from this EA. It will look at whether the current price puts the order into enough profit (more than BEPips). And whether the stop-loss is still below open (for Buys), or above it (for Sells). Then it sets the order stop-loss to break-even + 1 pip.

#### amsteronline

##### Master Trader
Hello Enivid

So I've been testing out some of the functions of the Amazing EA and I was wondering if you could fix a problem with one of the functions: OCO=false

The problem right now is that when OCO is set to false, the EA does indeed not cancel the other order if one order is filled, but if the market reverses and the other order gets filled the EA closes out the previous order but not place the order.

For example, let's say I have OCO set to false, and we want GBPAUD to have a pending buy order at 1.9230 and a pending sell order at 1.9200, the market moves and the buy order gets filled. It goes the right way for some time and then it suddenly reverses. Now it hits our sell order at 1.9200 thus it closes our previous buy order....and that's all it does. What the EA should be doing is not only close out the first buy order at 1.9200 but also place a sell order immediately.

What do you think? Do you think you could fix this issue I have been having with this EA.

Thank you.

PS> I have also attached the latest version of the EA.

#### Attachments

• AmazingEA_EveryDay_AnyHour_AnyMM_CloseAll_NEW.mq4
51.7 KB · Views: 67

#### Enivid

##### Administrator
Staff member
What does it say in the Experts tab of the Terminal subwindow. The EA is pretty verbose, it should output the reason for deleting. Is it the end of the waiting time (STWAN)?

#### amsteronline

##### Master Trader
STWAN does cancel pending orders, but my example above describes how the already filled order affects the not filled pending order and the unfilled pending order acts to close the filled order but it should also place the order...can you fix the oco function so the unfilled pending order's gets filled it not only closes the filled order but also opens a new order.

Thanks

Last edited:

#### Enivid

##### Administrator
Staff member
In your example, at this point - is there a pending sell order in the system?
Now it hits our sell order at 1.9200 thus it closes our previous buy order....and that's all it does.
Or does it get deleted the moment the buy position hits a stop-loss?

If it does get deleted by the EA, please provide the output of Experts tab of the Terminal subwindow.

#### amsteronline

##### Master Trader
Thanks man. I'm gonna do some chart testing to see if the EA works the right way. Sometimes i just need more information before I proceed.

#### amsteronline

##### Master Trader
Ok so I did a little research. The ea works fine.

Now, there is a AnyHour function. The slight change that I would like to make to this EA is to make it trade not every hour but every 4 hours, so trades would be placed starting from hour 0, then, 4, 8, 12, 16, 20...

Can you please help me make this change to the AnyHour function, would call it any4hour, or anything you like.

Thanks in advance.

#### Enivid

##### Administrator
Staff member
Try replacing line 319 with these:
MQL4:
```	if (Any4Hour)
{
secofnews = (Hour() / 4 + 1) * 4 * 3600;
if (secofnews == 24) secofnews = 0;
}```
Then rename the input parameter from AnyHour to Any4Hour.

Last edited:

#### amsteronline

##### Master Trader
Thanks, I will try if it works

#### amsteronline

##### Master Trader
Hello Enivid.

The code worked perfectly.

Now, I'm trying to add the function to open trades at certain price level, like for example . Open pending orders at every 50 pips or every 100 pips the market reaches that price level and only once within 12 ours, so there won't be too many pending orders every time the market hits let's 1.4850 (GBPUSD)...and also to just close out the previous open position, so the new pending positions won't be affected by the old ones!

Because I have been experimenting with CTBN and/or pips away but the market is so unpredictable, but at certain price levels the market does tend to move!

What do you think?

Last edited:

#### Enivid

##### Administrator
Staff member
It does look like a completely different EA to me. What you are describing is probably already available in many of the grid trading EAs.

#### amsteronline

##### Master Trader
maybe, but not likely because this is different, you only need to add three features:

-Ea places pending orders based on every 100 pip price intervals
-The Ea only places one of these pending orders within 12 hours
-Once new pending orders are placed, the previous open positions are closed (because the market has reached another price level)

Do you think you could code these functions, The function could be called "Price away" or something similar which could be set to different price levels including the above specifications.

Example: lets' say right now the price is at 1.2550 and the price interval is set to every 100 pips. The market moves and the price is 1.2600. Now, based on "Pipsaway" which was set to 20 pips, when the market is at 1.2600, two pending orders will be placed 20 pips away from each other. The market moves more and now the price is at 1.2620 and our buy order gets filled. Great! The market keeps on moving up and is at 1.2700, this is when our previous buy order gets closed out, and a new set of pending orders 20 pips away are pending again. And on and on it will go like this.

Last edited:

#### Enivid

##### Administrator
Staff member
I cannot promise that I'll do it. Perhaps if I will have a lot of free time.

#### amsteronline

##### Master Trader
Let me know please, much would be appreciated

#### amsteronline

##### Master Trader
Hello Enivid,

When you are programming this Update, you don't have to worry about the closing out positions since the TP will take care of that...

Thank you.

#### vasco

##### Newbie
Hello, I am new to the forum and I have already download the amazing ea for the news
I have an idea about a strategy that could work profitable during a news release and some minutes after, and I would like to share with you.
If we take a position at the breakout of previous bar with no stop loss or take profit
and use a trailing function of a number of points n
If the price go to my favour and reverse in order to hit the trailing, close the profitable position and open a new one with the initial lot to the new direction of the price (opposite the first one).
If the price go against my position and hit the trailing open a position with 2* initial lot to the direction of the price (opposite the previous order), so I would have two open positions the initial and the hedge (with double lot) with a distance between them =< n due to the trailing function. If the price continue to that direction for at least twice the distance n and reverse again to hit the trailing then close the hedge position (if price is in profit according to the breakeven of the total sequence) and keep the initial position but consider it as a new position with open price value the price of the trailing at the time of the close of the hedge position.
If the price is moving up down up, then new positions must be opened always to the direction of the price with lot size: 1) 1lot, 2) 2lot, 3)3lot, 4)6lot, 5) double previous .....etc.
When the price move to one direction and the trailing pass through the breakeven of the sequence and the price reverse to hit the trailing then close all positions except one with initial lot (if none partially close one position) to the direction of the price
At the time of a major news release there is a large movement of the price not necessarily to one direction but often going up for some points and then down and then up again with large movements. I beleive that this strategy could have good profits a few minutes after a news release. Also must have a stop time some minutes after the time of the event when the volatility of the market return to normal.
Please tell me your opinion about this strategy and if there is a case any programmer to build a robot based on this.
Thank you

#### Enivid

##### Administrator
Staff member
Sorry, but I do not think it has anything to do with the Amazing EA's current strategy. Also, normally, I do not implement any EAs with Martingale position sizing.

#### amsteronline

##### Master Trader
Helle Enivid,

So are you working on the the ea according to the changes that I thought should be implemented?

#### Enivid

##### Administrator
Staff member
No, I am currently working on other projects.

Replies
0
Views
246
Replies
26
Views
27K
Replies
5
Views
893
Replies
7
Views
10K