Trying to get tick[0] for SAR indicator (MT5)

 

Hi Guys,

Hoping someone can point out where I'm going wrong. 


I'm trying to get the current tick value of some indicators (PAR in the example below). I assume it's doable since I can see the chart indicator moving in response to the tick changes on the live chart.

I can get the closing indicator value by bar easily enough, and I can see the tick price, but I can't work out how to get the matching indicator value. Is there an equivalent function to CopyClose() for indicators or hidden PERIOD_TICK somewhere?

(Please excuse the coding, I'm new to MQL and still steal stuff directly from the help files! :) )

// somewhere in the code...

   iSAR_handle=iSAR(my_symbol,my_timeframe, SARAF, SARAFMax);           //apply the indicator and get its handle
   if(iSAR_handle==INVALID_HANDLE)                                      //check the availability of the indicator handle
     {
      Print("Failed to get the SL indicator handle");                  //if the handle is not obtained, print the relevant error message into the log file
      return(-1);                                                       //complete handling the error
     }
   ChartIndicatorAdd(ChartID(),0, iSAR_handle);
   ArraySetAsSeries(bufSL,true);

//

//

//copying SL[] from series]
   err4=CopyBuffer(iSAR_handle,0,0,1,bufSL);
   err5=CopyClose(my_symbol,my_timeframe,0,1,Close_buf);     //copy the price chart data into the dynamic array Close_buf for further work with them

//

//
OnTick()
{
        string com = StringFormat ("Last Bar stop: %s, Current Tick Stop: %s\r\n", DoubleToString(bufSL[1],2), DoubleToString(/* what goes here? */,2));
               com = com + StringFormat ("Current Price: %s\r\n", DoubleToString(Close_buf[0],2));

        Comment(com);
}


Cheers,


Chris

 
VoiceOfTheBear: Hoping someone can point out where I'm going wrong. 

I'm trying to get the current tick value of some indicators (PAR in the example below). I assume it's doable since I can see the chart indicator moving in response to the tick changes on the live chart.

I can get the closing indicator value by bar easily enough, and I can see the tick price, but I can't work out how to get the matching indicator value. Is there an equivalent function to CopyClose() for indicators or hidden PERIOD_TICK somewhere?

The most recent Close price is the Bid price of the most recent tick, so the most recent PSAR value is the the value of the PSAR for the most recent tick that arrived.

It is that simple. Simply read off the PSAR value at index 0. It will get updated on every new tick.