Reply

EA help needed–not following trading rules

3 replies

deweymcg

Subscriber, bbp_participant, community, 24 replies.

Visit profile

10 years ago #112119

I need some help please! This strategy seemed like something that would be easy to put together with EA Wizard, but I cannot seem to get it to follow the trade rules and am not sure where I am screwing up.

 

.

There is a little more to it, but in a nutshell this is a mean reversion strategy to use on ranging pairs. I want to take a sell order when price reaches and then crosses under the upper ATR 2 levels shown by the ATR Channels indicator and buy orders when it reaches then crosses back above the lower ATR2. There is more I will add when I can get this part to work. Orders should close when price reverts to the mean, which in this case is LWMA 240. That is also the center line for the ATR channels. (see PIC).

 

To simplify things to start I put trade rules to sell when price crosses below upper ATR2 (Ch2upBuffer3) and buy when it crosses above lower ATR3 (Ch2upBuffer4). orders should close when price equals LWMA 240. However, as you can see from the PICS, it does a sell when it should do a buy and also sometimes takes orders right at the center line instead of the upper or lower ATR2 lines. Orders are not closed where they should either. This is driving me nuts.

 

Can someone have a look and point me in the right direction?

 

Thanks.

 

 

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #124459

Hello,

 

one problem I see is that Ask and Bid values don’t have history in MT4. So you shouldn’t use them in cross above/below comparisons.

 

‘Bid crosses below indicator; effectively means:

Bid > (indicator value at previous candle) and Bid < (indicator value at current candle)

 

but it uses the same current Bid value, not Bid value from previous candle.

 

You should use Open or Close values in these comparisons. I would assume that there should be Close instead of Bid in your logic.

 

 

You also have one mistake in go long 1 rule – the direction of order is set to Short, but it should be Long.

Mark
StrategyQuant architect

0

deweymcg

Subscriber, bbp_participant, community, 24 replies.

Visit profile

10 years ago #124473

Thanks. That actually helped a lot. I would have preferred to have it open a trade when price hit the ATR2, but the results are still good when using open price. I have  a  few more tweaks to add though before this is ready for prime time.

0

JTamas

Subscriber, bbp_participant, community, 26 replies.

Visit profile

10 years ago #124476

Hi Deweymcg,

 

There are two other ways to solve this problem. It is a bit more complicated but will do exactly that you want.

 

1. After the price pierced throuh the line you can place a pending order on the line. Like this IF High > atr and is bar open is true line THEN sell stop at price Atr line.

The problem wtih this is that some broker doesn’t allow orders within a given distance of the price. The other is that is there was just a spike the order might not be triggered.

 

So the other is way better. You have to make the EA to rememer that it previously crossed the given line. it can be done by turning a hidden (pipe off so invisible to the user) boolean parameter into true when it happens.

1. make a hidden boolean lets say UpperATRcross as false.

2. Rule 1# IF bid crosses above the upper ATR line THEN assing variable UpperATRcross as true

3. Rule 2# IF UpperATRcross is true and ask crosses below upper ATR line THEN sell with a TP set on the mid line whatever it is. MA I guess.

 

You can also set this to a lower time period then the one you are trading on to be even more precise.

 

Good luck.

 

T

0

Viewing 3 replies - 1 through 3 (of 3 total)