_x_BidAskLogger

Author: Mr. T.
_x_BidAskLogger
Miscellaneous
Implements a curve of type %1
2 Views
0 Downloads
0 Favorites
_x_BidAskLogger
//+------------------------------------------------------------------+
//|                                                 SpreadLogger.mq4 |
//|                                                           Mr. T. |
//|                                         http://www.codeforex.com |
//+------------------------------------------------------------------+
#property copyright "Mr. T."
#property link      "http://www.codeforex.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2

extern int LastTicks = 500;

double Spread_Ask[];
double Spread_Bid[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   IndicatorBuffers(2);

   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, Spread_Ask);
   
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, Spread_Bid);
  
   short_name="Bid Ask Logger ("+LastTicks+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0, "ASK");
   SetIndexLabel(1, "BID");
   objectCreate("mrt",10,10,"CopyRight by Mr. T @ www.codeforex.com ");
   for (int i=0; i<LastTicks; i++)
   {
     Spread_Ask[i] = EMPTY_VALUE;
     Spread_Bid[i] = EMPTY_VALUE;
   }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("mrt");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   for (int i=LastTicks-1;i>0;i--)
   {    
    if (Spread_Ask[i-1]!=EMPTY_VALUE) Spread_Bid[i] = Spread_Bid[i-1];
    if (Spread_Bid[i-1]!=EMPTY_VALUE) Spread_Ask[i] = Spread_Ask[i-1];        
   }
      
   Spread_Bid[0] = Bid;
   Spread_Ask[0] = Ask;
      
   return(0);
  }

//+------------------------------------------------------------------+
//    Create an Object -                                             |       
//+------------------------------------------------------------------+   
void objectCreate(string name,int x,int y,string text="",int size=12,
                  string font="Arial",color colour=Red)
  {
   ObjectCreate(name,OBJ_LABEL,1,0,0);
   ObjectSet(name,OBJPROP_CORNER,2);
   ObjectSet(name,OBJPROP_COLOR,colour);
   ObjectSet(name,OBJPROP_XDISTANCE,x);
   ObjectSet(name,OBJPROP_YDISTANCE,y);
   ObjectSetText(name,text,size,font,colour);
  }

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 ---