//+------------------------------------------------------------------+
//|                                               FixChartBidAsk.mq4 |
//|                                      Copyright 2017, nicholishen |
//|                         https://www.forexfactory.com/nicholishen |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, nicholishen"
#property link      "https://www.forexfactory.com/nicholishen"
#property version   "1.00"
#property strict
#property indicator_chart_window
//--- input parameters
input bool     InpShowAsk=true;     //Show Ask line
input color    InpAskColor=clrRed;  //Ask Line Color
input color    InpBidColor=clrGray; //Bid Line Color

#include <ChartObjects\ChartObjectsLines.mqh>

CChartObjectHLine bid,ask;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
   ChartSetInteger(0,CHART_SHOW_BID_LINE,false);
   ChartSetInteger(0,CHART_SHOW_ASK_LINE,false);
   bid.Create(0,"__bid__",0,0.0);
   bid.Color(InpBidColor);
   bid.Tooltip("Bid");
   if(InpShowAsk)
   {
      ask.Create(0,"__ask__",0,0.0);
      ask.Color(InpAskColor);
      ask.Tooltip("Ask");
   }
//---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
//---
   MqlTick tick;
   SymbolInfoTick(_Symbol,tick);
   bid.Price(0,tick.bid);
   if(InpShowAsk)
      ask.Price(0,tick.ask);
//--- return value of prev_calculated for next call
   return(rates_total);
}
//+------------------------------------------------------------------+
