0
Views
0
Downloads
0
Favorites
IsNewBar_Example
//+------------------------------------------------------------------+
//| IsNewBar_Example.mq5 |
//| Copyright 2011, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
#include <IsNewBar.mqh>
//+------------------------------------------------------------------+
//| 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
{
//--- 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
{
//--- 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 */
}
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---