daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #property copyright "Copyright 2018, MetaQuotes Software Corp."
  2. #property link      "https://www.mql5.com"
  3. #property version   "1.00"
  4.  
  5. double lastask[10];
  6. double lastbid[10];
  7. int position;
  8.  
  9. int OnInit()
  10.   {
  11.      position = 0;
  12.      
  13.  
  14.  
  15.    return(INIT_SUCCEEDED);
  16.   }
  17.  
  18. void OnDeinit(const int reason)
  19.   {
  20. //---
  21.    
  22.   }
  23.  
  24. void OnTimer(){
  25.    Print(versusChange());
  26. }
  27.  
  28. void OnTick()
  29.   {
  30. //---
  31.       double Ask,Bid;
  32.      
  33.       Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  34.       Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  35.       //Print("Ask = ",Ask,"  Bid = ",Bid);
  36.       if (position < 10){
  37.          lastask[position] = Ask;
  38.          lastbid[position] = Bid;
  39.          position++;
  40.       }else{
  41.          for (int i = 1; i < 10 ; i++){
  42.             lastask[i-1] = lastask[i];
  43.             lastbid[i-1] = lastbid[i];
  44.          }
  45.          lastask[9] = Ask;
  46.          lastbid[9] = Bid;
  47.       }
  48.       EventKillTimer();
  49.       EventSetTimer( 2  );
  50.      
  51.   }
  52. //+------------------------------------------------------------------+
  53.  
  54. int versusChange()
  55. {
  56.    int result = 0;
  57.    for (int i = 0 ; i < 9 ; i++){
  58.       if (lastask[i] != lastask[i+1])
  59.          result++;
  60.       if (lastbid[i] != lastbid[i+1])
  61.          result--;
  62.    }
  63.    return result;
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top