Hello everyone. I am trying to write a simple indicator to just plot the daily PSAR as a line above and below the current price on a 4HR chart and having no success. It does plot the lines and if I look at the daily chart it is perfeclty alligned the the PSAR dots. BUt when I go to my 4HR chart the lines don't correspond to the daily PSAR values. I know this because I plotted the daily PSAR on a 4HR chart and they didn't line up correctly. I'm sure it's simple but this is the first time I am attempting to make one.
Thanks for any info.
//+------------------------------------------------------------------+
//| PSAR-ADX.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//|
Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
extern bool Send_Mail = true;
//---- buffers
double DailyPSARBuy[];
double DailyPSARSell[];
int init()
{
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,Blue);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2,Red);
SetIndexBuffer(0,DailyPSARBuy);
SetIndexBuffer(1,DailyPSARSell);
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
double DailyPSARValue,CandleClose;
string message;
static bool TradeOn;
if(Bars<=100) return(0);
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- the last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int i=Bars-counted_bars;
while(i>=0)
{
DailyPSARValue = iSAR(NULL,PERIOD_D1,0.02,0.2,i);
CandleClose = iClose(NULL,0,i);
if (DailyPSARValue < CandleClose)
DailyPSARBuy[i]= High[i]+30*Point;
if (DailyPSARValue > CandleClose)
DailyPSARSell[i]= Low[i]-30*Point;
i--;
}
return(0);
}