ALGORITMA
JAMBI
Servis elektronik Jambi
#property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 #property indicator_label1 "CCI" #property indicator_type1 DRAW_LINE #property indicator_color1 DodgerBlue #property indicator_width1 2 input int CCIPeriod = 14; input double LevelUp = 100.0; input double LevelDown = -100.0; double CCIBuffer[]; int handleCCI; int OnInit() {SetIndexBuffer(0, CCIBuffer, INDICATOR_DATA); handleCCI = iCCI(_Symbol, _Period, CCIPeriod, PRICE_TYPICAL); if(handleCCI == INVALID_HANDLE) {Print("Gagal membuat handle CCI"); return(INIT_FAILED);} 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[]) {int start = prev_calculated; if(start < 1) start = 1; CopyBuffer(handleCCI, 0, 0, rates_total, CCIBuffer); for(int i = start; i < rates_total; i++) {double prev = CCIBuffer[i-1]; double curr = CCIBuffer[i]; // CROSS UP if(curr > LevelUp && prev <= LevelUp) {string msg = _Symbol + " | CCI Cross UP level " + DoubleToString(LevelUp,0) + " pada TF " + IntegerToString(_Period); Alert(msg);} // CROSS DOWN if(curr < LevelDown && prev >= LevelDown) {string msg = _Symbol + " | CCI Cross DOWN level " + DoubleToString(LevelDown,0) + " pada TF " + IntegerToString(_Period); Alert(msg); }} return(rates_total);