거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
8320
평가:
(23)
게시됨:
2012.02.13 07:53
업데이트됨:
2016.11.22 07:32
\MQL5\Include\
isnewbar.mqh (1.41 KB) 조회
\MQL5\Experts\
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

СIsNewBar class is necessary for the efficient work of the Expert Advisors that make calculations at the moment the new bar appears.

Usually IsNewBar() function is used for such things instead of a class. But such a function contains a static variable, and therefore we cannot use several calls of this function. To be able to reuse such function repeatedly in Expert Advisor's code, it would be much easier to make it a class member. In this case that has been accomplished using IsNewBar.mqh.

The library code should be included in the file content on the global level using #include directive:

#include <IsNewBar.mqh>

Then, the required number of СIsNewBar class variables must be declared in OnTick() block of the Expert Advisor:

static CIsNewBar NB1,NB2;

After that we can make calls to IsNewBar() functions

bool IsNewBar(string symbol,            // currency symbol
              ENUM_TIMEFRAMES timeframe)// calculation chart timeframe

in the Expert Advisor code:

if(NB1.IsNewBar(Symbol(),PERIOD_D1)) // checking for a new bar
     {
      /* Here is a trading signal 1 receiving block code */
     }

Here is the possible example of the code that includes СIsNewBar class inside OnTick() function:

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//----

   double iClose1[1],iClose2[1];
//---- declaration of static variables
   static bool Recount1=true,Recount2=true;
   static CIsNewBar NB1,NB2;

//+----------------------------------------------+
//| Detecting market entry signals               |
//+----------------------------------------------+
   if(NB1.IsNewBar(Symbol(),PERIOD_D1) || Recount1) // checking for a new bar
     {
      Recount1=false;
      
      //---- copy newly appeared data in the arrays
      if(CopyClose(Symbol(),PERIOD_D1,1,1,iClose1)<=0) {Recount1=true; return;}
      
      /* Here is a trading signal 1 receiving block code */
      
     }
     
   if(NB2.IsNewBar(Symbol(),PERIOD_H4) || Recount2) // checking for a new bar
     {
      Recount2=false;
      
      //---- copy newly appeared data in the arrays
      if(CopyClose(Symbol(),PERIOD_H4,1,1,iClose2)<=0) {Recount2=true; return;}
      
      /* Here is a trading signal 2 receiving block code */
      
     }

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/768

i-Fractals-sig i-Fractals-sig

The indicator of the market entry signals using fractals.

Forecast Oscillator Forecast Oscillator

Normalized oscillator provided by the signal line and colored dots for making deals.

TrendTriggerMod TrendTriggerMod

The indicator displays trend power and direction.

Fx10 Fx10

The semaphore signal indicator with the values based on five technical indicators: LWMA, SMA, RSI, Stochastic, MACD.