Quote:
Originally Posted by AceFX
Ben,
Can't thank you enough for the quick and helpful reply. You were absolutely correct and I am a step closer because of it!
I do have one more question however, trying to add a break even point at a level less than the trailing stop but haven't gotten past:
extern bool UseBreak_Even = True;
extern int Break_Even = 20;
 ...
Any chance on some advice here as well?
Thanks again and take care!
-Ace
|
Hi, Breakeven is an easy function, you just need to understand what you need and then you'll be able to think of what you write to make it happen.
1. Breakeven = moving stoploss to order open price when stoploss is below open (for buy, above open for sell).
To check if its below we usually use this: OrderStopLoss()<OrderOpenPrice()
2. Before you move to breakeven you need to check if conditions are true. I use something like this:
if(bid>orderopenprice()+breakeven*point) move
3. Moving. I use something like this:
ordermodify(symbol(),bla-bla-bla,,,stoploss,takeprofit,0);
bla-bla-bla = set of parameters that don't change for opened orders like order open price (can be changed for pending orders)
stoploss = I usually put orderopenprice() here to that the order is closed at 0 pip profit.
takeprofit = if you don't want TP to change, just enter OrderTakeProfit() (case sensitive!)
Hope this helps

and yes it leaves you to do the job yourself.
Oh, and how to find the order you want to modify:
Code:
for(int i=0;i<=OrdersTotal();i++) {
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderMagicNumber!=MagicNumber) continue;
if(your-condition-here) your-action-here;
}
That should do the job just fine

this cycle simply cycles through orders and finds each and every order currently opened. It then filters out orders with different magic number (you'll need to define magic number first) and those with different symbol (currency pair).
Hope this helps
nck
thanks but the code is useless without the goldminer1 and goldminer2 indicators

New EA is attached. Couldn't test it for obvious reasons so please don't blame me if it doesn't work the way it should. It should close existing order when a new signal is received but there could be a conflict of signals because different indicators are used for buy and sell.
Have fun with the new EA!