Exit EA - Please add/correct code in my first self build EA

 

Hi ALL

I just used the EA Builder to make an Exit EA.

Many traders open a trade manually and would not like to sit in front of the PC to wait for the exit.

Thus an EA would be a good solution to free us from the PC.

BUT the most important use of this Exit EA is to eliminate the temptations and emotions that often ruin our trading.

There are already some exit EAs by, say Stockwet, and other trailing EA's around.

But I was unable to find any simple Exit EAs using simple Oscillators like RSI or MACD etc.

1. I would like to have a Magic Number / Ticket number so EA would monitor each particular opened trade.

2. Fixed stopLoss or Profit Target ( If the RSI exit logic is not triggered first )

3. EA closes a trade when RS1 crosses the 50 level

With the EA builder and it's template, I got the following EA

I tried running it on a DEMO account but it did not trigger for a exit on an opened trade. Please advice or help. I am using 5 digit broker.

If I can get this EA working, I will try to create some more with MACD ... etc and eventually explain which kind of opened trade operates best with which exit EA -

Need to further test first.

Thanks

Looking forward

Files:
 
highway3000:
Hi ALL

1. I would like to have a Magic Number / Ticket number so EA would monitor each particular opened trade.

2. Fixed stopLoss or Profit Target ( If the RSI exit logic is not triggered first )

3. EA closes a trade when RS1 crosses the 50 level

With the EA builder and it's template, I got the following EA. I tried running it on a DEMO account but it did not trigger for a exit on an opened trade. Please advice or help. I am using 5 digit broker.

Thanks - Looking forward

Hi Highway3000,

1) To add magic numbers to the signal close:

Change the following lines in the Signal END sections - Add OrderMagicNumber()=MagicNumber

//+------------------------------------------------------------------+

//| Signal End(Exit Buy) |

//+------------------------------------------------------------------+

//if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount))))

Change to ---

if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) && OrderMagicNumber() == MagicNumber

|| (!EachTickMode && (Bars != BarCount ) )))

//+------------------------------------------------------------------+

//| Signal End(Exit Sell) |

//+------------------------------------------------------------------+

//if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount))))

Change to ---

if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) && OrderMagicNumber() == MagicNumber

|| (!EachTickMode && (Bars != BarCount ) )))

2) Fixed SL and TP are already built in. Use an extra zero (0) for 5 digit brokers.

3) RSI close and exits - Change the settings to greater than/less than () so if for some reason it missing the =50 it will still close and exit when it goes above or below 50.

if (CloseBuy1_1 <= CloseBuy1_2) Order = SIGNAL_CLOSEBUY;

if (CloseSell1_1 >= CloseSell1_2) Order = SIGNAL_CLOSESELL;

Hope this helps. Have fun learning and trying new things!

Robert

Reason: