IsNewBar_Example

Author: Copyright 2011, MetaQuotes Software Corp.
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 supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---