Advertisement
maxkhl

Untitled

Jun 6th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.49 KB | None | 0 0
  1. //datetime Globalflag1 = GlobalVariableSet("LotsResStr1", NormalizeDouble(GlobalVariableGet("LotsResStr1"),2));
  2. //datetime Globalflag2 = GlobalVariableSet("LotsResStr2", NormalizeDouble(GlobalVariableGet("LotsResStr2"),2));
  3. //datetime Globalflag3 = GlobalVariableSet("LotsResStr3", NormalizeDouble(GlobalVariableGet("LotsResStr3"),2));
  4. //datetime Globalflag4 = GlobalVariableSet("LotsResStr4", NormalizeDouble(GlobalVariableGet("LotsResStr4"),2));
  5. //datetime Globalflag5 = GlobalVariableSet("LotsResStr5", NormalizeDouble(GlobalVariableGet("LotsResStr5"),2));
  6.  
  7. //datetime Globalflag6 = GlobalVariableSet("TakeProfitResStr1", GlobalVariableGet("TakeProfitResStr1"));
  8. //datetime Globalflag7 = GlobalVariableSet("TakeProfitResStr2", GlobalVariableGet("TakeProfitResStr2"));
  9. //datetime Globalflag8 = GlobalVariableSet("TakeProfitResStr3", GlobalVariableGet("TakeProfitResStr3"));
  10. //datetime Globalflag9 = GlobalVariableSet("TakeProfitResStr4", GlobalVariableGet("TakeProfitResStr4"));
  11. //datetime Globalflag10 = GlobalVariableSet("TakeProfitResStr5", GlobalVariableGet("TakeProfitResStr5"));
  12.  
  13. //datetime Globalflag11 = GlobalVariableSet("StopLossResStr1", GlobalVariableGet("StopLossResStr1"));
  14. //datetime Globalflag12 = GlobalVariableSet("StopLossResStr2", GlobalVariableGet("StopLossResStr2"));
  15. //datetime Globalflag13 = GlobalVariableSet("StopLossResStr3", GlobalVariableGet("StopLossResStr3"));
  16. //datetime Globalflag14 = GlobalVariableSet("StopLossResStr4", GlobalVariableGet("StopLossResStr4"));
  17. //datetime Globalflag15 = GlobalVariableSet("StopLossResStr5", GlobalVariableGet("StopLossResStr5"));
  18.  
  19. #property copyright "Copyright 2015, MetaQuotes Software Corp."
  20. #property link      "https://www.mql5.com"
  21. #property version   "1.00"
  22. #property strict
  23.  
  24. string DrawInfo(string ProfileStr, int ProfileRes, string LotsStr, double LotsResStr, string TakeProfitStr, double TakeProfitResStr, string StopLossStr, double StopLossResStr, string LockStr)
  25. {
  26. return(StringConcatenate(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  27. }
  28.  
  29. string KeyInt(const long &lparam, string StrVar)
  30. {
  31.    if (lparam == 49)
  32.    {
  33.       StringAdd(StrVar, "1");  
  34.       return(StrVar);
  35.    }
  36.    if (lparam == 50)
  37.    {
  38.       StringAdd(StrVar, "2");  
  39.       return(StrVar);
  40.    }
  41.    if (lparam == 51)
  42.    {
  43.       StringAdd(StrVar, "3");  
  44.       return(StrVar);
  45.    }
  46.    if (lparam == 52)
  47.    {
  48.       StringAdd(StrVar, "4");  
  49.       return(StrVar);
  50.    }
  51.    if (lparam == 53)
  52.    {
  53.       StringAdd(StrVar, "5");  
  54.       return(StrVar);
  55.    }
  56.    if (lparam == 54)
  57.    {
  58.       StringAdd(StrVar, "6");  
  59.       return(StrVar);
  60.    }
  61.    if (lparam == 55)
  62.    {
  63.       StringAdd(StrVar, "7");  
  64.       return(StrVar);
  65.    }
  66.    if (lparam == 56)
  67.    {
  68.       StringAdd(StrVar, "8");  
  69.       return(StrVar);
  70.    }
  71.    if (lparam == 57)
  72.    {
  73.       StringAdd(StrVar, "9");  
  74.       return(StrVar);
  75.    }
  76.    if (lparam == 48)
  77.    {
  78.       StringAdd(StrVar, "0");
  79.       return(StrVar);
  80.    }
  81.    if (lparam == 46)
  82.    {
  83.       StrVar = "";
  84.       return(StrVar);
  85.    }
  86.    if (lparam == 190)
  87.    {
  88.       StringAdd(StrVar, ".");
  89.       return(StrVar);
  90.    }
  91.    return(StrVar);
  92. }
  93.  
  94. bool Buffer = false;
  95. string Key = "";
  96. int Lock = 1;
  97. string LockStr = "\nLOCKED";
  98. string LotsStr = " \nLots: ";
  99. string LotsResStr = "";
  100. int ProfileRes = GlobalVariableGet("ProfileRes");
  101. string ProfileStr = "Profile: ";
  102. int Selector = 1;
  103. string StopLossStr = " \nStop Loss: ";
  104. string StopLossResStr = "";
  105. string TakeProfitStr = " \nTake Profit: ";
  106. string TakeProfitResStr = "";
  107. int Ticket = 0;
  108.  
  109. int OnInit()
  110. {
  111.  
  112. LotsResStr = GlobalVariableGet(StringConcatenate("LotsResStr", ProfileRes ));
  113. TakeProfitResStr = GlobalVariableGet(StringConcatenate("TakeProfitResStr", ProfileRes ));
  114. StopLossResStr = GlobalVariableGet(StringConcatenate("StopLossResStr", ProfileRes ));
  115. GlobalVariableSet("ActiveLotsRes",GlobalVariableGet(StringConcatenate("LotsResStr", ProfileRes )));
  116. GlobalVariableSet("ActiveTakeProfitRes",GlobalVariableGet(StringConcatenate("TakeProfitResStr", ProfileRes )));
  117. GlobalVariableSet("ActiveStopLossRes",GlobalVariableGet(StringConcatenate("StopLossResStr", ProfileRes )));
  118. Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  119.    
  120.  
  121. if (ProfileRes == 1)
  122. {
  123.    datetime GlobalFlag16 = GlobalVariableSet("ProfileRes", 1);
  124. }
  125. if (ProfileRes == 2)
  126. {
  127.    datetime GlobalFlag17 = GlobalVariableSet("ProfileRes", 2);
  128. }
  129. if (ProfileRes == 3)
  130. {
  131.    datetime GlobalFlag18 = GlobalVariableSet("ProfileRes", 3);
  132. }
  133. if (ProfileRes == 4)
  134. {
  135.    datetime GlobalFlag19 = GlobalVariableSet("ProfileRes", 4);
  136. }
  137. if (ProfileRes == 5)
  138. {
  139.    datetime GlobalFlag20 = GlobalVariableSet("ProfileRes", 5);
  140. }
  141.    ProfileStr = "-> Profile: ";
  142.    Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  143.    return(INIT_SUCCEEDED);
  144. }
  145.  
  146. void OnTimer()
  147. {
  148.    Buffer = false;
  149.    Key = "";
  150.    EventKillTimer();
  151. }
  152.  
  153. void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  154. {
  155.    if (id == CHARTEVENT_KEYDOWN && Buffer == false)
  156.    {
  157.       Print("Key: ", lparam);
  158.       Buffer = true;
  159.       EventKillTimer();
  160.       EventSetMillisecondTimer(50);
  161.      
  162.       if (lparam == "16")
  163.       {
  164.          Key = "Shift";
  165.       }
  166.       if (lparam == "87")
  167.       {
  168.          Key = "W";
  169.       }
  170.       if (lparam == "65")
  171.       {
  172.          Key = "A";
  173.       }
  174.       if (lparam == "83")
  175.       {
  176.          Key = "S";
  177.       }
  178.       if (lparam == "68")
  179.       {
  180.          Key = "D";
  181.       }
  182.       if (lparam == "81")
  183.       {
  184.          Key = "Q";
  185.       }
  186.       if (lparam == "69")
  187.       {
  188.          Key = "E";
  189.       }
  190.          
  191.       if (Key == "Shift")
  192.       {
  193.          Lock = !Lock;
  194.          if (Lock == 0)
  195.          {
  196.             LockStr = "\nUNLOCKED";
  197.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  198.          }
  199.          if (Lock == 1)
  200.          {
  201.             LockStr = "\nLOCKED";
  202.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  203.          }
  204.       }
  205.       if (Key == "Q" && Lock == 0)
  206.       {
  207.          Ticket = OrderSend(Symbol(), OP_BUY, GlobalVariableGet("ActiveLotsRes"), Ask, 1000, GlobalVariableGet("ActiveStopLossRes"), GlobalVariableGet("ActiveTakeProfitRes"));
  208.          Print(Ticket);
  209.       }
  210.        if (Key == "E" && Lock == 0)
  211.       {
  212.          Ticket = OrderSend(Symbol(), OP_SELL, GlobalVariableGet("ActiveLotsRes"), Bid, 1000, GlobalVariableGet("ActiveStopLossRes"), GlobalVariableGet("ActiveTakeProfitRes"));
  213.          Print(Ticket);
  214.       }
  215.       if (Key == "W" && Lock == 0 && Selector > 1)
  216.       {
  217.          Selector--;
  218.       }
  219.       if (Key == "S" && Lock == 0 && Selector < 4)
  220.       {
  221.          Selector++;
  222.       }
  223.       if (Selector == 1)
  224.       {
  225.          ProfileStr = "-> Profile: ";
  226.          LotsStr = " \nLots: ";
  227.          TakeProfitStr = " \nTake Profit: ";
  228.          StopLossStr = " \nStop Loss: ";
  229.          Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  230.          if (Key == "D" && Lock == 0 && ProfileRes < 5)
  231.          {
  232.             ProfileRes++;
  233.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  234.          }
  235.          if (Key == "A" && Lock == 0 && ProfileRes > 1)
  236.          {
  237.             ProfileRes--;
  238.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  239.          }
  240.       }
  241.       if (Selector == 2)
  242.       {
  243.          ProfileStr = "Profile: ";
  244.          LotsStr = " \n-> Lots: ";
  245.          TakeProfitStr = " \nTake Profit: ";
  246.          StopLossStr = " \nStop Loss: ";
  247.          
  248.          LotsResStr = KeyInt(lparam, LotsResStr);
  249.          if (ProfileRes == 1)
  250.          {
  251.             GlobalVariableSet("LotsResStr1", LotsResStr);
  252.          }
  253.          if (ProfileRes == 2)
  254.          {
  255.             GlobalVariableSet("LotsResStr2", LotsResStr);
  256.          }
  257.          if (ProfileRes == 3)
  258.          {
  259.             GlobalVariableSet("LotsResStr3", LotsResStr);
  260.          }
  261.          if (ProfileRes == 4)
  262.          {
  263.             GlobalVariableSet("LotsResStr4", LotsResStr);
  264.          }
  265.          if (ProfileRes == 5)
  266.          {
  267.             GlobalVariableSet("LotsResStr5", LotsResStr);
  268.          }
  269.          Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  270.       }
  271.       if (Selector == 3)
  272.       {
  273.          ProfileStr = "Profile: ";
  274.          LotsStr = " \nLots: ";
  275.          TakeProfitStr = " \n-> Take Profit: ";
  276.          StopLossStr = " \nStop Loss: ";
  277.        
  278.          TakeProfitResStr = KeyInt(lparam, TakeProfitResStr);
  279.          if (ProfileRes == 1)
  280.          {
  281.             GlobalVariableSet("TakeProfitResStr1", TakeProfitResStr);
  282.          }
  283.          if (ProfileRes == 2)
  284.          {
  285.             GlobalVariableSet("TakeProfitResStr2", TakeProfitResStr);
  286.          }
  287.          if (ProfileRes == 3)
  288.          {
  289.             GlobalVariableSet("TakeProfitResStr3", TakeProfitResStr);
  290.          }
  291.          if (ProfileRes == 4)
  292.          {
  293.             GlobalVariableSet("TakeProfitResStr4", TakeProfitResStr);
  294.          }
  295.          if (ProfileRes == 5)
  296.          {
  297.             GlobalVariableSet("TakeProfitResStr5", TakeProfitResStr);
  298.          }  
  299.          Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  300.       }
  301.       if (Selector == 4)
  302.       {
  303.          ProfileStr = "Profile: ";
  304.          LotsStr = " \nLots: ";
  305.          TakeProfitStr = " \nTake Profit: ";
  306.          StopLossStr = " \n-> Stop Loss: ";
  307.  
  308.          StopLossResStr = KeyInt(lparam, StopLossResStr);
  309.          if (ProfileRes == 1)
  310.          {
  311.             GlobalVariableSet("StopLossResStr1", StopLossResStr);
  312.          }
  313.          if (ProfileRes == 2)
  314.          {
  315.             GlobalVariableSet("StopLossResStr2", StopLossResStr);
  316.          }
  317.          if (ProfileRes == 3)
  318.          {
  319.             GlobalVariableSet("StopLossResStr3", StopLossResStr);
  320.          }
  321.          if (ProfileRes == 4)
  322.          {
  323.             GlobalVariableSet("StopLossResStr4", StopLossResStr);
  324.          }
  325.          if (ProfileRes == 5)
  326.          {
  327.             GlobalVariableSet("StopLossResStr5", StopLossResStr);
  328.          }
  329.          Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  330.       }
  331.       if (Key == "A" || Key == "D")
  332.       {
  333.          if (ProfileRes == 1)
  334.          {
  335.             datetime GlobalFlag16 = GlobalVariableSet("ProfileRes", 1);
  336.             LotsResStr = GlobalVariableGet("LotsResStr1");
  337.             TakeProfitResStr = GlobalVariableGet("TakeProfitResStr1");
  338.             StopLossResStr = GlobalVariableGet("StopLossResStr1");
  339.             GlobalVariableSet("ActiveLotsRes",GlobalVariableGet("LotsResStr1"));
  340.             GlobalVariableSet("ActiveTakeProfitRes",GlobalVariableGet("TakeProfitResStr1"));
  341.             GlobalVariableSet("ActiveStopLossRes",GlobalVariableGet("StopLossResStr1"));
  342.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  343.          }
  344.          if (ProfileRes == 2)
  345.          {
  346.             datetime GlobalFlag17 = GlobalVariableSet("ProfileRes", 2);
  347.             LotsResStr = GlobalVariableGet("LotsResStr2");
  348.             TakeProfitResStr = GlobalVariableGet("TakeProfitResStr2");
  349.             StopLossResStr = GlobalVariableGet("StopLossResStr2");
  350.             GlobalVariableSet("ActiveLotsRes",GlobalVariableGet("LotsResStr2"));
  351.             GlobalVariableSet("ActiveTakeProfitRes",GlobalVariableGet("TakeProfitResStr2"));
  352.             GlobalVariableSet("ActiveStopLossRes",GlobalVariableGet("StopLossResStr2"));
  353.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  354.          }
  355.          if (ProfileRes == 3)
  356.          {
  357.             datetime GlobalFlag18 = GlobalVariableSet("ProfileRes", 3);
  358.             LotsResStr = GlobalVariableGet("LotsResStr3");
  359.             TakeProfitResStr = GlobalVariableGet("TakeProfitResStr3");
  360.             StopLossResStr = GlobalVariableGet("StopLossResStr3");
  361.             GlobalVariableSet("ActiveLotsRes",GlobalVariableGet("LotsResStr3"));
  362.             GlobalVariableSet("ActiveTakeProfitRes",GlobalVariableGet("TakeProfitResStr3"));
  363.             GlobalVariableSet("ActiveStopLossRes",GlobalVariableGet("StopLossResStr3"));
  364.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  365.          }
  366.          if (ProfileRes == 4)
  367.          {
  368.             datetime GlobalFlag19 = GlobalVariableSet("ProfileRes", 4);
  369.             LotsResStr = GlobalVariableGet("LotsResStr4");
  370.             TakeProfitResStr = GlobalVariableGet("TakeProfitResStr4");
  371.             StopLossResStr = GlobalVariableGet("StopLossResStr4");
  372.             GlobalVariableSet("ActiveLotsRes",GlobalVariableGet("LotsResStr4"));
  373.             GlobalVariableSet("ActiveTakeProfitRes",GlobalVariableGet("TakeProfitResStr4"));
  374.             GlobalVariableSet("ActiveStopLossRes",GlobalVariableGet("StopLossResStr4"));
  375.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  376.          }
  377.          if (ProfileRes == 5)
  378.          {
  379.             datetime GlobalFlag20 = GlobalVariableSet("ProfileRes", 5);
  380.             LotsResStr = GlobalVariableGet("LotsResStr5");
  381.             TakeProfitResStr = GlobalVariableGet("TakeProfitResStr5");
  382.             StopLossResStr = GlobalVariableGet("StopLossResStr5");
  383.             GlobalVariableSet("ActiveLotsRes",GlobalVariableGet("LotsResStr5"));
  384.             GlobalVariableSet("ActiveTakeProfitRes",GlobalVariableGet("TakeProfitResStr5"));
  385.             GlobalVariableSet("ActiveStopLossRes",GlobalVariableGet("StopLossResStr5"));
  386.             Comment(DrawInfo(ProfileStr, ProfileRes, LotsStr, LotsResStr, TakeProfitStr, TakeProfitResStr, StopLossStr, StopLossResStr, LockStr));
  387.          }
  388.       }
  389.    }
  390. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement