Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #property copyright "Copyright (c) 2018, Neetkun.io"
  2. #property link "https://neetkun.io/"
  3. #property version "1.0"
  4. // pips
  5. double currencyUnitPerPips(string symbol)
  6. {
  7. double digits = MarketInfo(symbol, MODE_DIGITS);
  8. double point = MarketInfo(symbol, MODE_POINT);
  9. double currencyUnit = 0.0;
  10. if(digits == 3.0 || digits == 5.0){
  11. currencyUnit = point * 10.0;
  12. } else {
  13. currencyUnit = point;
  14. }
  15. return currencyUnit;
  16. }
  17.  
  18.  
  19. // BestLot
  20. double BestLot(double lotpercent) {
  21. return NormalizeDouble(AccountBalance() * AccountInfoInteger(ACCOUNT_LEVERAGE) / Close[0] / 100000 * (lotpercent / 100), 2);
  22. }
  23.  
  24. // TrailingStop
  25. int trailingPrice = 0;
  26. void TrailingStop(int ticket, double profit) {
  27. if(OrdersTotal() == 0) {
  28. trailingPrice = 0;
  29. }
  30.  
  31.  
  32. if (OrderSelect(ticket, SELECT_BY_TICKET) == true) {
  33. // 買い処理
  34. if (OrderType() == OP_BUY && OrderOpenPrice() < Bid) {
  35. if (trailingPrice > Bid - profit * Point) {
  36. OrderModify(OrderTicket(), OrderOpenPrice(), Bid - profit * Point, 0, 0, clrNONE);
  37. trailingPrice = Bid - profit * Point;
  38. }
  39. }
  40. // 売り処理
  41. if (OrderType() == OP_SELL && OrderOpenPrice() < Ask) {
  42. if (trailingPrice < Ask + profit * Point) {
  43. OrderModify(OrderTicket(), OrderOpenPrice(), Ask + profit * Point, 0, 0, clrNONE);
  44. trailingPrice = Ask + profit * Point;
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement