Parabolic SAR is a trailing stop-and-reverse dot that accelerates toward price over time; dots below price mark an uptrend, dots above mark a downtrend. It works both as a trend filter and a dynamic trailing stop, flipping sides when price crosses it. Copy the version for your platform.
//@version=5
indicator("Parabolic SAR", overlay=true)
psar = ta.sar(0.02, 0.02, 0.2)
plot(psar, title="SAR", style=plot.style_cross, color=color.orange)#property indicator_chart_window
#property indicator_buffers 1
extern double SAR_Step = 0.02;
extern double SAR_Max = 0.2;
double SarBuffer[];
int OnInit() {
SetIndexBuffer(0, SarBuffer);
return 0;
}
int OnCalculate(const int rates_total, const int prev_calculated, const double &close[]) {
for (int i = prev_calculated; i < rates_total; i++)
SarBuffer[i] = iSAR(NULL, 0, SAR_Step, SAR_Max, i);
return rates_total;
}#property indicator_chart_window
#property indicator_buffers 1
input double SAR_Step = 0.02;
input double SAR_Max = 0.2;
double SarBuffer[];
int OnInit() {
SetIndexBuffer(0, SarBuffer);
return INIT_SUCCEEDED;
}
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[]) {
for (int i = prev_calculated; i < rates_total; i++)
SarBuffer[i] = iSAR(NULL, 0, SAR_Step, SAR_Max, i);
return rates_total;
}inputs: AfStep(0.02), AfMax(0.2);
variables: MySAR(0);
MySAR = ParabolicSAR(AfStep, AfMax);
Plot1(MySAR, "Parabolic SAR");{Parabolic SAR}
psar := SAR(0.02, 0.2);
psarTo use it inside dtcharts, paste any version into the Script Converter and it becomes a native indicator on your chart.