당사 팬 페이지에 가입하십시오
- 조회수:
- 8320
- 평가:
- 게시됨:
- 2012.02.13 07:53
- 업데이트됨:
- 2016.11.22 07:32
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
С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](https://c.mql5.com/i/code/indicator.png)
The indicator of the market entry signals using fractals.
![Forecast Oscillator](https://c.mql5.com/i/code/indicator.png)
Normalized oscillator provided by the signal line and colored dots for making deals.
![TrendTriggerMod](https://c.mql5.com/i/code/indicator.png)
The indicator displays trend power and direction.
![Fx10](https://c.mql5.com/i/code/indicator.png)
The semaphore signal indicator with the values based on five technical indicators: LWMA, SMA, RSI, Stochastic, MACD.