Einzelnen Beitrag anzeigen
  #12 (permalink)  
Alt 02.07.14
Benutzerbild von fxdaytrader
fxdaytrader fxdaytrader ist offline
Premium Mitglied
 
Registriert seit: Dec 2013
Ort: hier und dort
Beiträge: 433
fxdaytrader befindet sich auf einem aufstrebenden Ast
Standard

Nun ja, ...

Nicht getestet, aber teste das mal:

Code:
//+------------------------------------------------------------------+
//|                                     //| TPSL-Insert EA mod.mq4 | |
//|                                                    Copyright © ? |
//|           mod. fxdaytrader, http://ForexFactory.com/fxdaytrader_ |
//|                                            http://ForexBaron.net |
//+------------------------------------------------------------------+
//////////////////////////////////////////////////////////////////////
// !!! YOU (probably) MUST COMPILE THIS EA WITH THE BUILD 509 COMPILER, download the metaeditor for build 509 at http://www.forexfactory.com/showthread.php?t=470340 !!!
//////////////////////////////////////////////////////////////////////
#property copyright "? // mod. fxdaytrader, http://ForexBaron.net "
#property link "http://ForexBaron.net"

//---- input parameters
extern double TakeProfitPips=100;
extern double StopLossPips=150;
double TPp, SLp;

//fxdaytrader:
extern bool ModifyTakeProfit = TRUE;
extern bool ModifyStopLoss   = TRUE;
extern int MagicNumber = 0;//0=manual trades
extern bool FilterByMagicNumber = TRUE;
extern bool FilterBySymbol      = TRUE;
double pips2dbl;//fxdaytrader

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init(){}

//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit(){}

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
 if(OrdersTotal()!=0) TradeManager(Symbol(),MagicNumber);
 return(0);
}// Start()

//////////////////////////////////////////
//fxdaytrader:
void BrokerDigitAdjust(string symbol) {
 int Multiplier = 1;
 int digits=MarketInfo(symbol,MODE_DIGITS);
 if (digits==3 || digits==5) Multiplier = 10;
 if (digits==6) Multiplier = 100;   
 if (digits==7) Multiplier = 1000;
 pips2dbl = Multiplier*MarketInfo(symbol,MODE_POINT);
}

void TradeManager(string symbol,int magicnumber) {
 bool result;
 for (int cnt=OrdersTotal()-1; cnt>=0; cnt--) {
  if (!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) continue;
  if (FilterBySymbol && OrderSymbol()!=symbol) continue;
  if (FilterByMagicNumber && OrderMagicNumber()!=magicnumber) continue;
   {
    //---
    BrokerDigitAdjust(OrderSymbol());
//--------------Take Profit--------------------------------

 if (ModifyTakeProfit && OrderTakeProfit()==0 && TakeProfitPips !=0.00000) {
  if (OrderType()<=OP_SELL) {
   if(OrderType()==OP_BUY)  TPp = OrderOpenPrice()+TakeProfitPips*pips2dbl;
   if(OrderType()==OP_SELL) TPp = OrderOpenPrice()-TakeProfitPips*pips2dbl;
   result = OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),TPp,OrderExpiration(),CLR_NONE);
  }
 } 

//--------------Stop Loss--------------------------------

 if (ModifyStopLoss && OrderStopLoss()==0 && StopLossPips !=0.00000) {
  if (OrderType()<=OP_SELL) {
   if(OrderType()==OP_BUY)  SLp = OrderOpenPrice()-StopLossPips*pips2dbl;
   if(OrderType()==OP_SELL) SLp = OrderOpenPrice()+StopLossPips*pips2dbl;
      result = OrderModify(OrderTicket(),OrderOpenPrice(),SLp,OrderTakeProfit(),OrderExpiration(),CLR_NONE);
  }
 }
    //---
   }
  }//for (int cnt=OrdersTotal()-1; cnt>=0; cnt--) {
}
Angehängte Dateien
Dateityp: ex4 TPSL-Insert EA mod.ex4 (4,8 KB, 1x aufgerufen)
__________________
krank im Kopf aber sonst ganz nett
build 509 mql4 editor download