English

## Indicator to calculate spread between pairs

 164 rod178 2016.08.10 08:54 #   DeanDeV: Hey Guys,I seem to be pulling my hair out on this one. All I would like to do is have an indicator in a new window measuring the spread between two pairs by drawing a line with it's price? Could anyone help with this?  Any suggestions are welcome. ThanksDean Doubt that you have tried as the solution(s) are rather simpleStart with ```  double bid  =MarketInfo(Symbol(),MODE_BID);   // Request for the value of Bid   double ask  =MarketInfo(Symbol(),MODE_ASK);```
 120 DeanDeV 2016.08.10 15:17 #   Thaddeus_39: The standard answer in this forum to posts like yours, where you describe what you want without any display of effort (and I am not saying you haven't tried - it's just that we need an indication of your attempt), is to either pay someone to do it or learn to do it yourself.If, after an indication of a legitimate attempt, you are still struggling, share your code and the community will help you.Cheers Thanks for the reply, below is my attempt, however, I want to use Ask and Bid prices? Is it possible? :/```#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Black #property indicator_minimum 0 //---- buffers double Spread[]; double XPrice[]; double YPrice[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function                         | //+------------------------------------------------------------------+ int init()   {    IndicatorShortName("spread");    IndicatorDigits(Digits - 3);    IndicatorBuffers(3);    SetIndexBuffer(0, Spread);    SetIndexBuffer(1, XPrice);    SetIndexBuffer(2, YPrice);    SetIndexStyle(0, DRAW_LINE);    SetIndexLabel(0, "spread");    return(0);   } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function                       | //+------------------------------------------------------------------+ int deinit()   {    return(0);   } //+------------------------------------------------------------------+ //| Custom indicator iteration function                              | //+------------------------------------------------------------------+ int start()   {    int i, counted_bars = IndicatorCounted(); //---- check for possible errors    if(counted_bars < 0)        return(-1); //---- last counted bar will be recounted    if(counted_bars > 0)        counted_bars--;    int limit = Bars - counted_bars;            for(i = 0; i < limit; i++)           {            XPrice[i] = NormalizeDouble(iClose("X",0,i),2);            YPrice[i] = NormalizeDouble(iClose("Y",0,i),2);           }         for(i = limit - 1; i >= 0; i--)          {           Spread[i] = XPrice[i] - YPrice[i];          } //----    return(0);   }``` Thanks in advance...,