Explorar o código

Ticket # 5159

Code updated to partial close and break even on same message
AhtashamShahzad3 hai 9 meses
pai
achega
8ec9d17780
Modificáronse 2 ficheiros con 19 adicións e 19 borrados
  1. BIN=BIN
      blTelegramToMT4.ex4
  2. 19 19
      blTelegramToMT4.mq4

BIN=BIN
blTelegramToMT4.ex4


+ 19 - 19
blTelegramToMT4.mq4

@@ -288,6 +288,24 @@ void execute_functionality_on_new_message(int i)
 
          if(ticket != -1)
            {
+            if(StringFind(message,"set") != -1 && StringFind(message,"stop") != -1 && StringFind(message,"loss") != -1 && StringFind(message,"entry") != -1)
+              {
+
+               if(OrderSelect(ticket,SELECT_BY_TICKET))
+                 {
+
+                  bool result = OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,clrNONE);
+
+                  if(result)
+                    {
+                     Print("Order Sl Modify to Open Price ", ticket);
+                    }
+                  else
+                    {
+                     Print("Error in Modify order SL : ", GetLastError()," Setting SL at: ",OrderOpenPrice()," price: ",OrderClosePrice());
+                    }
+                 }
+              }
 
             if(StringFind(message,"take") != -1 && StringFind(message,"some") != -1 && StringFind(message,"partial") != -1 && StringFind(message,"profit") != -1)
               {
@@ -297,7 +315,7 @@ void execute_functionality_on_new_message(int i)
 
                   double lot = NormalizeDouble(OrderLots()*(partialClose/100),2);
 
-                  bool result = OrderClose(ticket,lot,OrderOpenPrice(),10, clrNONE);
+                  bool result = OrderClose(ticket,lot,OrderClosePrice(),10, clrNONE);
 
                   if(result)
                     {
@@ -331,24 +349,6 @@ void execute_functionality_on_new_message(int i)
                  }
               }
 
-            if(StringFind(message,"set") != -1 && StringFind(message,"stop") != -1 && StringFind(message,"loss") != -1 && StringFind(message,"entry") != -1)
-              {
-
-               if(OrderSelect(ticket,SELECT_BY_TICKET))
-                 {
-
-                  bool result = OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,clrNONE);
-
-                  if(result)
-                    {
-                     Print("Order Sl Modify to Open Price ", ticket);
-                    }
-                  else
-                    {
-                     Print("Error in Modify order SL : ", GetLastError());
-                    }
-                 }
-              }
            }