//--- indicator settings #property indicator_chart_window #property indicator_buffers 4 #property indicator_type1 DRAW_ARROW #property indicator_width1 4 #property indicator_color1 DeepSkyBlue #property indicator_label1 "Buy Entry" #property indicator_type2 DRAW_ARROW #property indicator_width2 4 #property indicator_color2 DeepPink #property indicator_label2 "Sell Entry" #import "libSSA.dll" void fastSingular(double &sourceArray[],int arraySize,int lag,int numberOfComputationLoops,double &destinationArray[]); #import //--- indicator buffers double Buffer1[]; double Buffer2[]; double myPoint; //initialized in OnInit void myAlert(string type, string message) { if(type == "print") Print(message); else if(type == "error") { Print(type+" | New indicator_1803261924 @ "+Symbol()+","+Period()+" | "+message); } else if(type == "order") { } else if(type == "modify") { } } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorBuffers(4); SetIndexBuffer(0, Buffer1); SetIndexEmptyValue(0, 0); SetIndexArrow(0, 233); SetIndexBuffer(1, Buffer2); SetIndexEmptyValue(1, 0); SetIndexArrow(1, 234); //initialize myPoint myPoint = Point(); if(Digits() == 5 || Digits() == 3) { myPoint *= 10; } return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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 limit = rates_total - prev_calculated; //--- counting from 0 to rates_total ArraySetAsSeries(Buffer1, true); ArraySetAsSeries(Buffer2, true); //--- initial zero if(prev_calculated < 1) { ArrayInitialize(Buffer1, 0); ArrayInitialize(Buffer2, 0); } else limit++; //-- Stair Bars int m1_bar=0,m5_bar=0,h1_bar=0; //--- main loop for(int i = limit-1; i >= 0; i--) { if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation //Get HTF Bars GetBars(i,m1_bar,m5_bar,h1_bar); //Indicator Buffer 1 // Buy Entry if(iCustom(NULL, PERIOD_H1, "OIH_TDI_SSA_Simple_v1.0", PRICE_CLOSE, 10, 2, 20, 500, 2, MODE_LWMA, 7, MODE_LWMA, 10, MODE_LWMA, 98, 0, -0.40, 0.0, 0.40, 2, 1+h1_bar) > iCustom(NULL, PERIOD_H1, "OIH_TDI_SSA_Simple_v1.0", PRICE_CLOSE, 10, 2, 20, 500, 2, MODE_LWMA, 7, MODE_LWMA, 10, MODE_LWMA, 98, 0, -0.40, 0.0, 0.40, 0, 1+h1_bar) //OIH_TDI_SSA_Simple_v1.0 > OIH_TDI_SSA_Simple_v1.0 && iCustom(NULL, PERIOD_M5, "OIH_AdvancedParabolic_v1.1_1st", 0, 0, 0.02, 0.02, 0.2, 0.0, 0.0, 1, 1000, 3, 1+m5_bar) == -1.00000 //OIH_AdvancedParabolic_v1.1_1st is equal to fixed value && iCustom(NULL, PERIOD_M5, "OIH_AdvancedParabolic_v1.1_2nd", 0, 0, 0.02, 0.005, 0.2, 0.0, 0.0, 1, 1000, 2, 1+m5_bar) == 1.00000 //OIH_AdvancedParabolic_v1.1_2nd is equal to fixed value && iCustom(NULL, PERIOD_M5, "OIH_TDI_SSA_Simple_v1.0", PRICE_CLOSE, 10, 2, 20, 500, 2, MODE_LWMA, 7, MODE_LWMA, 10, MODE_LWMA, 98, 0, -0.40, 0.0, 0.40, 2, 1+m5_bar) < iCustom(NULL, PERIOD_M5, "OIH_TDI_SSA_Simple_v1.0", PRICE_CLOSE, 10, 2, 20, 500, 2, MODE_LWMA, 7, MODE_LWMA, 10, MODE_LWMA, 98, 0, -0.40, 0.0, 0.40, 3, 1+m5_bar) //OIH_TDI_SSA_Simple_v1.0 < OIH_TDI_SSA_Simple_v1.0 ) { Buffer1[i] = iLow(NULL, PERIOD_M1, 1+i); //Set indicator value at Candlestick Low } else { Buffer1[i] = 0; } //Indicator Buffer 2 // Sell Entry if(iCustom(NULL, PERIOD_H1, "OIH_TDI_SSA_Simple_v1.0", PRICE_CLOSE, 10, 2, 20, 500, 2, MODE_LWMA, 7, MODE_LWMA, 10, MODE_LWMA, 98, 0, -0.40, 0.0, 0.40, 2, 1+i) < iCustom(NULL, PERIOD_H1, "OIH_TDI_SSA_Simple_v1.0", PRICE_CLOSE, 10, 2, 20, 500, 2, MODE_LWMA, 7, MODE_LWMA, 10, MODE_LWMA, 98, 0, -0.40, 0.0, 0.40, 1, 1+i) //OIH_TDI_SSA_Simple_v1.0 < OIH_TDI_SSA_Simple_v1.0 && iCustom(NULL, PERIOD_M5, "OIH_AdvancedParabolic_v1.1_1st", 0, 0, 0.02, 0.02, 0.2, 0.0, 0.0, 1, 1000, 2, 1+i) == 1.00000 //OIH_AdvancedParabolic_v1.1_1st is equal to fixed value && iCustom(NULL, PERIOD_M5, "OIH_AdvancedParabolic_v1.1_2nd", 0, 0, 0.02, 0.005, 0.2, 0.0, 0.0, 1, 1000, 3, 1+i) == -1.00000 //OIH_AdvancedParabolic_v1.1_2nd is equal to fixed value && iCustom(NULL, PERIOD_M5, "OIH_TDI_SSA_Simple_v1.0", PRICE_CLOSE, 10, 2, 20, 500, 2, MODE_LWMA, 7, MODE_LWMA, 10, MODE_LWMA, 98, 0, -0.40, 0.0, 0.40, 2, 1+i) > iCustom(NULL, PERIOD_M5, "OIH_TDI_SSA_Simple_v1.0", PRICE_CLOSE, 10, 2, 20, 500, 2, MODE_LWMA, 7, MODE_LWMA, 10, MODE_LWMA, 98, 0, -0.40, 0.0, 0.40, 3, 1+i) //OIH_TDI_SSA_Simple_v1.0 > OIH_TDI_SSA_Simple_v1.0 ) { Buffer2[i] = iHigh(NULL, PERIOD_M1, i); //Set indicator value at Candlestick High } else { Buffer2[i] = 0; } } return(rates_total); } //+------------------------------------------------------------------+ void GetBars(int bar,int &m1_bar,int &m5_bar,int &h1_bar) { m1_bar = iBarShift(NULL,PERIOD_M1,Time[bar]); m5_bar = iBarShift(NULL,PERIOD_M5,Time[bar]); h1_bar= iBarShift(NULL,PERIOD_H1,Time[bar]); } //*------------------------------------------------------------------*