I really need help, How to make Break Even work on Bid if buy and on Ask if sell?
-
Hi,
Please any body tell me how to make Break Even work on Bid if buy and on Ask for sell?
Original code:
void block35(int parent=0)
{
if (disabled[35] || FXD_BREAK) {return;}
FXD_CURRENT_FUNCTION_ID=35;static string OnProfitMode = "fixed"; double OnProfitPips = _externs::inp36_OnProfitPips; double OnProfitPercentSL = 50; double OnProfitPercentTP = 50; static string BEoffsetMode = "pips"; double BEPoffsetPips = _externs::inp36_BEPoffsetPips; static string OrdersScope = "group"; static string OrdersGroup = ""; static string SymbolScope = "symbol"; static string SYMBOL; SYMBOL = CurrentSymbol(); static string BuysOrSells = "both"; for (int pos=OrdersTotal()-1; pos>=0; pos--) { if (!OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)) {continue;} if (!FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {continue;} double PipsToSet=0; SetSymbol(attrSymbol()); if (OnProfitMode=="fixed") {PipsToSet = OnProfitPips;} else if (OnProfitMode=="percentSL") {PipsToSet = toPips(MathAbs(attrOpenPrice()-attrStopLoss()))*OnProfitPercentSL/100;} else if (OnProfitMode=="percentTP") {PipsToSet = toPips(MathAbs(attrOpenPrice()-attrTakeProfit()))*OnProfitPercentTP/100;} if ( (attrType()==OP_BUY && (SymbolAsk()-attrOpenPrice() > toDigits(PipsToSet)) && (attrStopLoss() < attrOpenPrice())) || (attrType()==OP_SELL && (attrOpenPrice()-SymbolBid() > toDigits(PipsToSet)) && ((attrStopLoss() > attrOpenPrice()) || attrStopLoss()==0)) ) { double be_offset=0; if (BEoffsetMode=="pips") { be_offset=toDigits(BEPoffsetPips); if (attrType()==OP_SELL ) {be_offset=be_offset*(-1);} } ModifyStops(attrTicket(),attrOpenPrice()+be_offset,attrTakeProfit()); } }Regards
-
Use the trailing stop block instead. Posting the source code doesn't help, because you can't change it from the EA builder. For the trailing stop try to set Step to 1000 (some huge number), Start to the profit that is needed and Stop... the same as Start