//------------------------------------------------------------------ #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 1 #property indicator_type1 DRAW_COLOR_ARROW #property indicator_color1 clrPaleVioletRed,clrLimeGreen // // // // // enum enPrices { pr_close, // Close pr_open, // Open pr_high, // High pr_low, // Low pr_median, // Median pr_typical, // Typical pr_weighted, // Weighted pr_average // Average }; input double SARStep = 0.02; // Step input double SARMaximum = 0.2; // Maximum input enPrices PriceHigh = pr_high; // Price high input enPrices PriceLow = pr_low; // Price low double sar[]; double colors[]; //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // void OnInit() { SetIndexBuffer(0,sar); PlotIndexSetInteger(0,PLOT_ARROW,159); SetIndexBuffer(1,colors,INDICATOR_COLOR_INDEX); } //------------------------------------------------------------------ // //------------------------------------------------------------------ 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 &tickVolume[], const long &volume[], const int &spread[]) { // // // // // for (int i=(int)MathMax(prev_calculated-1,0); iworkSar[i-1][_high] && workSar[i][_af]workSar[i ][_olow]) workSar[i][_open] = workSar[i ][_olow]; if (workSar[i][_open]>workSar[i-1][_olow]) workSar[i][_open] = workSar[i-1][_olow]; } else if (high>=workSar[i][_open]) { workSar[i][_position] = 1; pChange = 1; pClose = workSar[i][_low]; workSar[i][_low] = low; workSar[i][_high] = high; workSar[i][_af] = step; workSar[i][_open] = pClose + workSar[i][_af]*(workSar[i][_high]-pClose); if (workSar[i][_open]>workSar[i ][_olow]) workSar[i][_open] = workSar[i ][_olow]; if (workSar[i][_open]>workSar[i-1][_olow]) workSar[i][_open] = workSar[i-1][_olow]; } else { pClose = workSar[i][_open]; if (workSar[i][_low]