XavierAndreu

Break Even

Sep 5th, 2022
1,063
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. //Youtube https://youtu.be/cGjuHFqVqlI
  2.  
  3. #include<Trade\Trade.mqh> CTrade trade;
  4.  
  5. double Apertura=0;double SL=0;double TP=0;
  6. int ValorBE=0;
  7.  
  8. void OnStart()
  9. {
  10. if(_Symbol=="US500"){ ValorBE=1;}
  11. if(_Symbol=="DE40") { ValorBE=1;}
  12.  
  13. for(int a=0; a<PositionsTotal() ; a++)
  14. {
  15. ulong Ticket=PositionGetTicket(a);
  16.  
  17. Apertura=PositionGetDouble(POSITION_PRICE_OPEN);
  18. TP= PositionGetDouble(POSITION_TP);
  19. SL= PositionGetDouble(POSITION_SL);
  20.  
  21. if(_Symbol == PositionGetString(POSITION_SYMBOL))
  22. {
  23. //BUY
  24. if(PositionGetInteger(POSITION_TYPE)== POSITION_TYPE_BUY)
  25. {
  26. if(SL<Apertura)
  27. {
  28. SL= Apertura + ValorBE*_Point;
  29. trade.PositionModify(Ticket,SL,TP);
  30. }
  31. if(SL>Apertura)
  32. {
  33. SL= SL + ValorBE*_Point;
  34. trade.PositionModify(Ticket,SL,TP);
  35. }
  36. }
  37. //SELL
  38. if(PositionGetInteger(POSITION_TYPE)== POSITION_TYPE_SELL)
  39. {
  40. if(SL>Apertura)
  41. {
  42. SL= Apertura - ValorBE*_Point;
  43. trade.PositionModify(Ticket,SL,TP);
  44. }
  45. if(SL<Apertura)
  46. {
  47. SL= SL - ValorBE*_Point;
  48. trade.PositionModify(Ticket,SL,TP);
  49. }
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment