//+------------------------------------------------------------------+ //| System_Show.mq4 | //| | //| https://www.exodustrader.de | //+------------------------------------------------------------------+ #property copyright "MU" #property link "https://www.exodustrader.de" #property version "1.00" #property strict //--- input parameters input int LRot; input int LBlau; int hour; int minute; double OpenPrice; double iniStop; double actSL; int OrderNumber; int lastbartime; double lotSize; bool orderCheck = true; double red[12]; double blue[12]; // Highest von 12 bestimmen bool highest(int beginn, int ende){ bool highesth = true; for (int i = beginn; i <= ende; i++) { if (High[beginn]< High[i]) highesth = false; } return highesth; } //Lowest von 12 bestimmen bool lowest(int beginn, int ende) { bool lowestl = true; for (int j = beginn; j <= ende; j++) { if (Low[beginn]> Low[j]) lowestl = false; } return lowestl; } // Stop lowest double setStop (int beginn, int ende) { double highpoint = Low[0]; for(int i = beginn; i<= ende; i++) { if(Low[i] < highpoint){ highpoint = Low[i]; } } return highpoint; } //CandleCounter bool IsNewCandle() { static int BarsOnChart=0; // static Var. wird nur ein mal gesetzt und ist nur in der Function sichtbar = Local Variable if(Bars == BarsOnChart) return(false); BarsOnChart = Bars; return(true); } //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick(){ hour = TimeHour(TimeCurrent()); minute = TimeMinute(TimeCurrent()); //if(IsNewCandle()){ if (lastbartime != Bars){ lastbartime = Bars; //Red-Array aktualisieren for (int i = 11; i >=1; i--) { red[i] = red[i-1]; } red[0] = iMA(Symbol(),PERIOD_CURRENT,LRot,0,MODE_EMA,PRICE_CLOSE,1); //EMA mit Periode LRot //Blue-Array aktualisieren for (int j = 11; j >=1; j--){ blue[j] = blue[j-1]; } blue[0] = iMA(Symbol(),PERIOD_CURRENT,LBlau,0,MODE_SMA,PRICE_CLOSE,1); // SMA mit Periode LBlau //Ordergenerierung Opening nur zwischen XY_Uhr if (hour >= 8 && minute==30 && hour <21 && minute<55 ){ //++++ENTRY-SETUPS++++ // Check ob offene Orders vorliegen if (OrdersTotal() < 1){ //Stop berechenen iniStop = 27;//MathMin(25, Ask-(Ask-Low[1]-2));9 //LotSize berechenen lotSize = 0.1;//MathRound((AccountBalance()*0.01)/iniStop); //Entry-Setup LONG //mit ASK als Market Order if (Low[1]>Low[2]) { OrderNumber = OrderSend(Symbol(), OP_BUY, lotSize, Ask, 5,Low[1]-iniStop, 0,"BlauerPunkt",202,0,Blue); } } } // ++++Exits & Stops++++ // Checke offene Orders if (OrdersTotal() > 0){ orderCheck = OrderSelect(0,SELECT_BY_POS,0); actSL = OrderStopLoss(); OrderNumber = OrderTicket(); OpenPrice = OrderOpenPrice();//OpenPrice der offenen Order wird gespeichert //Long-Exits if (OrderType() == OP_BUY) { //Modify auf trailing Stop Close[1]>blue[0] && if (Close[1]>blue[0] && setStop(1,20) > actSL && OrderComment() == "BlauerPunktDOW5") { orderCheck = OrderModify(OrderNumber,OpenPrice,setStop(1,20),0,0,Blue); orderCheck = OrderSelect(0,SELECT_BY_POS,0); actSL = OrderStopLoss(); } if (hour == 20 && minute ==55) { orderCheck = OrderClose(OrderNumber,lotSize,Bid,5,Blue); } } //Order send & modify errors if (OrderNumber == -1){ Print("Order failed. Error code: ", GetLastError()); } if(!orderCheck) { Print("Modifying failed. Error code: ", GetLastError()); orderCheck = true; } } } }