ANN_Strategy_HTF_Indicator

Author: Copyright 2018, MetaQuotes Software Corp.
Price Data Components
Series array that contains open time of each barSeries array that contains open prices of each barSeries array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
0 Views
0 Downloads
0 Favorites
ANN_Strategy_HTF_Indicator
ÿþ//+------------------------------------------------------------------+

//|                                   ANN_Strategy_HTF_Indicator.mq5 |

//|                        Copyright 2018, MetaQuotes Software Corp. |

//|                                                 https://mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2018, MetaQuotes Software Corp."

#property link      "https://mql5.com"

#property version   "1.00"

#property description "Artificial Neural Network Strategy Higher Time Frame Indicator"

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_plots   2

//--- plot HighBar

#property indicator_label1  "Bullish Bar"

#property indicator_type1   DRAW_HISTOGRAM

#property indicator_color1  clrDeepSkyBlue

#property indicator_style1  STYLE_SOLID

#property indicator_width1  8

//--- plot LowBar

#property indicator_label2  "Bearish Bar"

#property indicator_type2   DRAW_HISTOGRAM

#property indicator_color2  clrRed

#property indicator_style2  STYLE_SOLID

#property indicator_width2  8

//--- input parameters

input double            InpThreshold   =  0.0014;     // Threshold

input ENUM_TIMEFRAMES   InpTimeframe   =  PERIOD_H4;  // Higher timeframe

//--- indicator buffers

double         BufferHB[];

double         BufferLB[];

//--- global variables

ENUM_TIMEFRAMES   timeframe_h;

double            threshold;

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- timer

   EventSetTimer(90);

//--- set global variables

   timeframe_h=(InpTimeframe>Period() ? InpTimeframe : Period());

   threshold=InpThreshold;

//--- indicator buffers mapping

   SetIndexBuffer(0,BufferHB,INDICATOR_DATA);

   SetIndexBuffer(1,BufferLB,INDICATOR_DATA);

//--- setting plot buffer parameters

   PlotIndexSetString(0,PLOT_LABEL,TimeframeToString(timeframe_h)+" Bullish Bar");

   PlotIndexSetString(1,PLOT_LABEL,TimeframeToString(timeframe_h)+" Bearish Bar");

//--- setting buffer arrays as timeseries

   ArraySetAsSeries(BufferHB,true);

   ArraySetAsSeries(BufferLB,true);

//--- setting indicator parameters

   IndicatorSetString(INDICATOR_SHORTNAME,"ANN Strategy "+TimeframeToString(timeframe_h)+" Indicator("+DoubleToString(threshold,4)+")");

   IndicatorSetInteger(INDICATOR_DIGITS,Digits());

//--- Get time

   Time(NULL,timeframe_h,1);

//---

   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[])

  {

//--- #AB0=>2:0 <0AA82>2 1CD5@>2 :0: B09<A5@89

   ArraySetAsSeries(open,true);

   ArraySetAsSeries(high,true);

   ArraySetAsSeries(low,true);

   ArraySetAsSeries(close,true);

   ArraySetAsSeries(time,true);

//--- @>25@:0 :>;8G5AB20 4>ABC?=KE 10@>2

   if(rates_total<4 || Time(NULL,timeframe_h,1)==0) return 0;

//--- @>25@:0 8 @0AGQB :>;8G5AB20 ?@>AG8BK205<KE 10@>2

   int limit=rates_total-prev_calculated;

   if(limit>1)

     {

      limit=rates_total-2;

      ArrayInitialize(BufferHB,EMPTY_VALUE);

      ArrayInitialize(BufferLB,EMPTY_VALUE);

     }



//---  0AGQB 8=48:0B>@0

   for(int i=limit; i>=0 && !IsStopped(); i--)

     {

      double Diff=GetDiff(i,timeframe_h,time);

      double X=PineActivationLinear(Diff);



      double x0_0=X;

      double x0_1=X;

      double x0_2=X;

      double x0_3=X;

      double x0_4=X;

      double x0_5=X;

      double x0_6=X;

      double x0_7=X;

      double x0_8=X;

      double x0_9=X;

      double x0_10=X;

      double x0_11=X;

      double x0_12=X;

      double x0_13=X;

      double x0_14=X;



      double x1_0=PineActivationTanh(x0_0*5.040340774    + x0_1*-1.3025994088 + x0_2*19.4225543981 + x0_3*1.1796960423 + x0_4*2.4299395823  + x0_5*3.159003445  + x0_6*4.6844527551  + x0_7*-6.1079267196 + x0_8*-2.4952869198 + x0_9*-4.0966081154 + x0_10*-2.2432843111 + x0_11*-0.6105764807 + x0_12*-0.0775684605 + x0_13*-0.7984753138 + x0_14*3.4495907342);

      double x1_1=PineActivationTanh(x0_0*5.9559031982   + x0_1*-3.1781960056 + x0_2*-1.6337491061 + x0_3*-4.3623166512+ x0_4*0.9061990402  + x0_5*-0.731285093 + x0_6*-6.2500232251 + x0_7*0.1356087758  + x0_8*-0.8570572885 + x0_9*-4.0161353298 + x0_10*1.5095552083  + x0_11*1.324789197   + x0_12*-0.1011973878 + x0_13*-2.3642090162 + x0_14*-0.7160862442);

      double x1_2=PineActivationTanh(x0_0*4.4350881378   + x0_1*-2.8956461034 + x0_2*1.4199762607  + x0_3*-0.6436844261+ x0_4*1.1124274281  + x0_5*-4.0976954985+ x0_6*2.9317456342  + x0_7*0.0798318393  + x0_8*-5.5718144311 + x0_9*-0.6623352208 + x0_10*3.2405203222  + x0_11*-10.6253384513+ x0_12*4.7132919253  + x0_13*-5.7378151597 + x0_14*0.3164836695);

      double x1_3=PineActivationTanh(x0_0*-6.1194605467  + x0_1*7.7935605604  + x0_2*-0.7587522153 + x0_3*9.8382495905 + x0_4*0.3274314734  + x0_5*1.8424796541 + x0_6*-1.2256355427 + x0_7*-1.5968600758 + x0_8*1.9937700922  + x0_9*5.0417809111  + x0_10*-1.9369944654 + x0_11*6.1013201778  + x0_12*1.5832910747  + x0_13*-2.148403244  + x0_14*1.5449437366);

      double x1_4=PineActivationTanh(x0_0*3.5700040028   + x0_1*-4.4755892733 + x0_2*0.1526702072  + x0_3*-0.3553664401+ x0_4*-2.3777962662 + x0_5*-1.8098849587+ x0_6*-3.5198449134 + x0_7*-0.4369370497 + x0_8*2.3350169623  + x0_9*1.9328960346  + x0_10*1.1824141812  + x0_11*3.0565148049  + x0_12*-9.3253401534 + x0_13*1.6778555498  + x0_14*-3.045794332);

      double x1_5=PineActivationTanh(x0_0*3.6784907623   + x0_1*1.1623683715  + x0_2*7.1366362145  + x0_3*-5.6756546585+ x0_4*12.7019884334 + x0_5*-1.2347823331+ x0_6*2.3656619827  + x0_7*-8.7191778213 + x0_8*-13.8089238753+ x0_9*5.4335943836  + x0_10*-8.1441181338 + x0_11*-10.5688113287+ x0_12*6.3964140758  + x0_13*-8.9714236223 + x0_14*-34.0255456929);

      double x1_6=PineActivationTanh(x0_0*-0.4344517548  + x0_1*-3.8262167437 + x0_2*-0.2051098003 + x0_3*0.6844201221 + x0_4*1.1615893422  + x0_5*-0.404465314 + x0_6*-0.1465747632 + x0_7*-0.006282458  + x0_8*0.1585655487  + x0_9*1.1994484991  + x0_10*-0.9879081404 + x0_11*-0.3564970612 + x0_12*1.5814717823  + x0_13*-0.9614804676 + x0_14*0.9204822346);

      double x1_7=PineActivationTanh(x0_0*-4.2700957175  + x0_1*9.4328591157  + x0_2*-4.3045548    + x0_3*5.0616868842 + x0_4*3.3388781058  + x0_5*-2.1885073225+ x0_6*-6.506301518  + x0_7*3.8429000108  + x0_8*-1.6872237349 + x0_9*2.4107095799  + x0_10*-3.0873985314 + x0_11*-2.8358325447 + x0_12*2.4044366491  + x0_13*0.636779082   + x0_14*-13.2173215035);

      double x1_8=PineActivationTanh(x0_0*-8.3224697492  + x0_1*-9.4825530183 + x0_2*3.5294389835  + x0_3*0.1538618049 + x0_4*-13.5388631898+ x0_5*-0.1187936017+ x0_6*-8.4582741139 + x0_7*5.1566299292  + x0_8*10.345519938  + x0_9*2.9211759333  + x0_10*-5.0471804233 + x0_11*4.9255989983  + x0_12*-9.9626142544 + x0_13*23.0043143258 + x0_14*20.9391809343);

      double x1_9=PineActivationTanh(x0_0*-0.9120518654  + x0_1*0.4991807488  + x0_2*-1.877244586  + x0_3*3.1416466525 + x0_4*1.063709676   + x0_5*0.5210126835 + x0_6*-4.9755780108 + x0_7*2.0336532347  + x0_8*-1.1793121093 + x0_9*-0.730664855  + x0_10*-2.3515987428 + x0_11*-0.1916546514 + x0_12*-2.2530340504 + x0_13*-0.2331829119 + x0_14*0.7216218149);

      double x1_10=PineActivationTanh(x0_0*-5.2139618683 + x0_1*1.0663790028  + x0_2*1.8340834959  + x0_3*1.6248173447 + x0_4*-0.7663740145 + x0_5*0.1062788171 + x0_6*2.5288021501  + x0_7*-3.4066549066 + x0_8*-4.9497988755 + x0_9*-2.3060668143 + x0_10*-1.3962486274 + x0_11*0.6185583427  + x0_12*0.2625299576  + x0_13*2.0270246444  + x0_14*0.6372015811);

      double x1_11=PineActivationTanh(x0_0*0.2020072665  + x0_1*0.3885852709  + x0_2*-0.1830248843 + x0_3*-1.2408598444+ x0_4*-0.6365798088 + x0_5*1.8736534268 + x0_6*0.656206442   + x0_7*-0.2987482678 + x0_8*-0.2017485963 + x0_9*-1.0604095303 + x0_10*0.239793356   + x0_11*-0.3614172938 + x0_12*0.2614678044  + x0_13*1.0083551762  + x0_14*-0.5473833797);

      double x1_12=PineActivationTanh(x0_0*-0.4367517149 + x0_1*-10.0601304934+ x0_2*1.9240604838  + x0_3*-1.3192184047+ x0_4*-0.4564760159 + x0_5*-0.2965270368+ x0_6*-1.1407423613 + x0_7*2.0949647291  + x0_8*-5.8212599297 + x0_9*-1.3393321939 + x0_10*7.6624548265  + x0_11*1.1309391851  + x0_12*-0.141798054  + x0_13*5.1416736187  + x0_14*-1.8142503125);

      double x1_13=PineActivationTanh(x0_0*1.103948336   + x0_1*-1.4592033032 + x0_2*0.6146278432  + x0_3*0.5040966421 + x0_4*-2.4276090772 + x0_5*-0.0432902426+ x0_6*-0.0044259999 + x0_7*-0.5961347308 + x0_8*0.3821026107  + x0_9*0.6169102373  + x0_10*-0.1469847611 + x0_11*-0.0717167683 + x0_12*-0.0352403695 + x0_13*1.2481310788  + x0_14*0.1339628411);

      double x1_14=PineActivationTanh(x0_0*-9.8049980534 + x0_1*13.5481068519 + x0_2*-17.1362809025+ x0_3*0.7142100864 + x0_4*4.4759163422  + x0_5*4.5716161777 + x0_6*1.4290884628  + x0_7*8.3952862712  + x0_8*-7.1613700432 + x0_9*-3.3249489518 + x0_10*-0.7789587912 + x0_11*-1.7987628873 + x0_12*13.364752545  + x0_13*5.3947219678  + x0_14*12.5267547127);

      double x1_15=PineActivationTanh(x0_0*0.9869461803  + x0_1*1.9473351905  + x0_2*2.032925759   + x0_3*7.4092080633 + x0_4*-1.9257741399 + x0_5*1.8153585328 + x0_6*1.1427866392  + x0_7*-0.3723167449 + x0_8*5.0009927384  + x0_9*-0.2275103411 + x0_10*2.8823012914  + x0_11*-3.0633141934 + x0_12*-2.785334815  + x0_13*2.727981E-4   + x0_14*-0.1253009512);

      double x1_16=PineActivationTanh(x0_0*4.9418118585  + x0_1*-2.7538199876 + x0_2*-16.9887588104+ x0_3*8.8734475297 + x0_4*-16.3022734814+ x0_5*-4.562496601 + x0_6*-1.2944373699 + x0_7*-9.6022946986 + x0_8*-1.018393866  + x0_9*-11.4094515429+ x0_10*24.8483091382 + x0_11*-3.0031522277 + x0_12*0.1513114555  + x0_13*-6.7170487021 + x0_14*-14.7759227576);

      double x1_17=PineActivationTanh(x0_0*5.5931454656  + x0_1*2.22272078    + x0_2*2.603416897   + x0_3*1.2661196599 + x0_4*-2.842826446  + x0_5*-7.9386099121+ x0_6*2.8278849111  + x0_7*-1.2289445238 + x0_8*4.571484248   + x0_9*0.9447425595  + x0_10*4.2890688351  + x0_11*-3.3228258483 + x0_12*4.8866215526  + x0_13*1.0693412194  + x0_14*-1.963203112);

      double x1_18=PineActivationTanh(x0_0*0.2705520264  + x0_1*0.4002328199  + x0_2*0.1592515845  + x0_3*0.371893552  + x0_4*-1.6639467871 + x0_5*2.2887318884 + x0_6*-0.148633664  + x0_7*-0.6517792263 + x0_8*-0.0993032992 + x0_9*-0.964940376  + x0_10*0.1286342935  + x0_11*0.4869943595  + x0_12*1.4498648166  + x0_13*-0.3257333384 + x0_14*-1.3496419812);

      double x1_19=PineActivationTanh(x0_0*-1.3223200798 + x0_1*-2.2505204324 + x0_2*0.8142804525  + x0_3*-0.848348177 + x0_4*0.7208860589  + x0_5*1.2033423756 + x0_6*-0.1403005786 + x0_7*0.2995941644  + x0_8*-1.1440473062 + x0_9*1.067752916   + x0_10*-1.2990534679 + x0_11*1.2588583869  + x0_12*0.7670409455  + x0_13*2.7895972983  + x0_14*-0.5376152512);

      double x1_20=PineActivationTanh(x0_0*0.7382351572  + x0_1*-0.8778865631 + x0_2*1.0950766363  + x0_3*0.7312146997 + x0_4*2.844781386   + x0_5*2.4526730903 + x0_6*-1.9175165077 + x0_7*-0.7443755288 + x0_8*-3.1591419438 + x0_9*0.8441602697  + x0_10*1.1979484448  + x0_11*2.138098544   + x0_12*0.9274159536  + x0_13*-2.1573448803 + x0_14*-3.7698356464);

      double x1_21=PineActivationTanh(x0_0*5.187120117   + x0_1*-7.7525670576 + x0_2*1.9008346975  + x0_3*-1.2031603996+ x0_4*5.917669142   + x0_5*-3.1878682719+ x0_6*1.0311747828  + x0_7*-2.7529484612 + x0_8*-1.1165884578 + x0_9*2.5524942323  + x0_10*-0.38623241   + x0_11*3.7961317445  + x0_12*-6.128820883  + x0_13*-2.1470707709 + x0_14*2.0173792965);

      double x1_22=PineActivationTanh(x0_0*-6.0241676562 + x0_1*0.7474455584  + x0_2*1.7435724844  + x0_3*0.8619835076 + x0_4*-0.1138406797 + x0_5*6.5979359352 + x0_6*1.6554154348  + x0_7*-3.7969458806 + x0_8*1.1139097376  + x0_9*-1.9588417    + x0_10*3.5123392221  + x0_11*9.4443103128  + x0_12*-7.4779291395 + x0_13*3.6975940671  + x0_14*8.5134262747);

      double x1_23=PineActivationTanh(x0_0*-7.5486576471 + x0_1*-0.0281420865 + x0_2*-3.8586839454 + x0_3*-0.5648792233+ x0_4*-7.3927282026 + x0_5*-0.3857538046+ x0_6*-2.9779885698 + x0_7*4.0482279965  + x0_8*-1.1522499578 + x0_9*-4.1562500212 + x0_10*0.7813134307  + x0_11*-1.7582667612 + x0_12*1.7071109988  + x0_13*6.9270873208  + x0_14*-4.5871357362);

      double x1_24=PineActivationTanh(x0_0*-5.3603442228 + x0_1*-9.5350611629 + x0_2*1.6749984422  + x0_3*-0.6511065892+ x0_4*-0.8424823239 + x0_5*1.9946675213 + x0_6*-1.1264361638 + x0_7*0.3228676616  + x0_8*5.3562230396  + x0_9*-1.6678168952 + x0_10*1.2612580068  + x0_11*-3.5362671399 + x0_12*-9.3895191366 + x0_13*2.0169228673  + x0_14*-3.3813191557);

      double x1_25=PineActivationTanh(x0_0*1.1362866429  + x0_1*-1.8960071702 + x0_2*5.7047307243  + x0_3*-1.6049785053+ x0_4*-4.8353898931 + x0_5*-1.4865381145+ x0_6*-0.2846893475 + x0_7*2.2322095997  + x0_8*2.0930488668  + x0_9*1.7141411002  + x0_10*-3.4106032176 + x0_11*3.0593289612  + x0_12*-5.0894813904 + x0_13*-0.5316299133 + x0_14*0.4705265416);

      double x1_26=PineActivationTanh(x0_0*-0.9401400975 + x0_1*-0.9136086957 + x0_2*-3.3808688582 + x0_3*4.7200776773 + x0_4*3.686296919   + x0_5*14.2133723935+ x0_6*1.5652940954  + x0_7*-0.2921139433 + x0_8*1.0244504511  + x0_9*-7.6918299134 + x0_10*-0.594936135  + x0_11*-1.4559914156 + x0_12*2.8056435224  + x0_13*2.6103905733  + x0_14*2.3412348872);

      double x1_27=PineActivationTanh(x0_0*1.1573980186  + x0_1*2.9593661909  + x0_2*0.4512594325  + x0_3*-0.9357210858+ x0_4*-1.2445804495 + x0_5*4.2716471631 + x0_6*1.5167912375  + x0_7*1.5026853293  + x0_8*1.3574772038  + x0_9*-1.9754386842 + x0_10*6.727671436   + x0_11*8.0145772889  + x0_12*7.3108970663  + x0_13*-2.5005627841 + x0_14*8.9604502277);

      double x1_28=PineActivationTanh(x0_0*6.3576350212  + x0_1*-2.9731672725 + x0_2*-2.7763558082 + x0_3*-3.7902984555+ x0_4*-1.0065574585 + x0_5*-0.7011836061+ x0_6*-1.0298068578 + x0_7*1.201007784   + x0_8*-0.7835862254 + x0_9*-3.9863597435 + x0_10*6.7851825502  + x0_11*1.1120256721  + x0_12*-2.263287351  + x0_13*1.8314374104  + x0_14*-2.279102097);

      double x1_29=PineActivationTanh(x0_0*-7.8741911036 + x0_1*-5.3370618518 + x0_2*11.9153868964 + x0_3*-4.1237170553+ x0_4*2.9491152758  + x0_5*1.0317132502 + x0_6*2.2992199883  + x0_7*-2.0250502364 + x0_8*-11.0785995839+ x0_9*-6.3615588554 + x0_10*-1.1687644976 + x0_11*6.3323478015  + x0_12*6.0195076962  + x0_13*-2.8972208702 + x0_14*3.6107747183);



      double x2_0=PineActivationTanh(x1_0*-0.590546797  + x1_1*0.6608304658  + x1_2*-0.3358268839+ x1_3*-0.748530283  + x1_4*-0.333460383  + x1_5*-0.3409307681+ x1_6*0.1916558198 + x1_7*-0.1200399453 + x1_8*-0.5166151854 + x1_9*-0.8537164676+ x1_10*-0.0214448647 + x1_11*-0.553290271  + x1_12*-1.2333302892 + x1_13*-0.8321813811 + x1_14*-0.4527761741 + x1_15*0.9012545631 + x1_16*0.415853215 + x1_17*0.1270548319    + x1_18*0.2000460279 + x1_19*-0.1741942671 + x1_20*0.419830522   + x1_21*-0.059839291  + x1_22*-0.3383001769 + x1_23*0.1617814073  + x1_24*0.3071848006 + x1_25*-0.3191182045 + x1_26*-0.4981831822 + x1_27*-1.467478375  + x1_28*-0.1676432563 + x1_29*1.2574849126);

      double x2_1=PineActivationTanh(x1_0*-0.5514235841 + x1_1*0.4759190049  + x1_2*0.2103576983 + x1_3*-0.4754377924 + x1_4*-0.2362941295 + x1_5*0.1155082119 + x1_6*0.7424215794 + x1_7*-0.3674198672 + x1_8*0.8401574461  + x1_9*0.6096563193 + x1_10*0.7437935674  + x1_11*-0.4898638101 + x1_12*-0.4168668092 + x1_13*-0.0365111095 + x1_14*-0.342675224  + x1_15*0.1870268765 + x1_16*-0.5843050987 + x1_17*-0.4596547471 + x1_18*0.452188522  + x1_19*-0.6737126684 + x1_20*0.6876072741  + x1_21*-0.8067776704 + x1_22*0.7592979467  + x1_23*-0.0768239468 + x1_24*0.370536097  + x1_25*-0.4363884671 + x1_26*-0.419285676  + x1_27*0.4380251141  + x1_28*0.0822528948  + x1_29*-0.2333910809);

      double x2_2=PineActivationTanh(x1_0*-0.3306539521 + x1_1*-0.9382247194 + x1_2*0.0746711276 + x1_3*-0.3383838985 + x1_4*-0.0683232217 + x1_5*-0.2112358049+ x1_6*-0.9079234054+ x1_7*0.4898595603  + x1_8*-0.2039825863 + x1_9*1.0870698641 + x1_10*-1.1752901237 + x1_11*1.1406403923  + x1_12*-0.6779626786 + x1_13*0.4281048906  + x1_14*-0.6327670055 + x1_15*-0.1477678844+ x1_16*0.2693637584 + x1_17*0.7250738509   + x1_18*0.7905904504 + x1_19*-1.6417250883 + x1_20*-0.2108095534 + x1_21*-0.2698557472 + x1_22*-0.2433656685 + x1_23*-0.6289943273 + x1_24*0.436428207  + x1_25*-0.8243825184 + x1_26*-0.8583496686 + x1_27*0.0983131026  + x1_28*-0.4107462518 + x1_29*0.5641683087);

      double x2_3=PineActivationTanh(x1_0*1.7036869992  + x1_1*-0.6683507666 + x1_2*0.2589197112 + x1_3*0.032841148   + x1_4*-0.4454796342 + x1_5*-0.6196149423+ x1_6*-0.1073622976+ x1_7*-0.1926393101 + x1_8*1.5280232458  + x1_9*-0.6136527036+ x1_10*-1.2722934357 + x1_11*0.2888655811  + x1_12*-1.4338638512 + x1_13*-1.1903556863 + x1_14*-1.7659663905 + x1_15*0.3703086867 + x1_16*1.0409140889 + x1_17*0.0167382209   + x1_18*0.6045646461 + x1_19*4.2388788116  + x1_20*1.4399738234  + x1_21*0.3308571935  + x1_22*1.4501137667  + x1_23*0.0426123724  + x1_24*-0.708479795 + x1_25*-1.2100800732 + x1_26*-0.5536278651 + x1_27*1.3547250573  + x1_28*1.2906250286  + x1_29*0.0596007114);

      double x2_4=PineActivationTanh(x1_0*-0.462165126  + x1_1*-1.0996742176 + x1_2*1.0928262999 + x1_3*1.806407067   + x1_4*0.9289147669  + x1_5*0.8069022793 + x1_6*0.2374237802 + x1_7*-2.7143979019 + x1_8*-2.7779203877 + x1_9*0.214383903  + x1_10*-1.3111536623 + x1_11*-2.3148813568 + x1_12*-2.4755355804 + x1_13*-0.6819733236 + x1_14*0.4425615226  + x1_15*-0.1298218043+ x1_16*-1.1744832824 + x1_17*-0.395194848  + x1_18*-0.2803397703+ x1_19*-0.4505071197 + x1_20*-0.8934956598 + x1_21*3.3232916348  + x1_22*-1.7359534851 + x1_23*3.8540421743  + x1_24*1.4424032523 + x1_25*0.2639823693  + x1_26*0.3597053634  + x1_27*-1.0470693728 + x1_28*1.4133480357  + x1_29*0.6248098695);

      double x2_5=PineActivationTanh(x1_0*0.2215807411  + x1_1*-0.5628295071 + x1_2*-0.8795982905+ x1_3*0.9101585104  + x1_4*-1.0176831976 + x1_5*-0.0728884401+ x1_6*0.6676331658 + x1_7*-0.7342174108 + x1_8*9.4428E-4     + x1_9*0.6439774272 + x1_10*-0.0345236026 + x1_11*0.5830977027  + x1_12*-0.4058921837 + x1_13*-0.3991888077 + x1_14*-1.0090426973 + x1_15*-0.9324780698+ x1_16*-0.0888749165 + x1_17*0.2466351736  + x1_18*0.4993304601 + x1_19*-1.115408696  + x1_20*0.9914246705  + x1_21*0.9687743445  + x1_22*0.1117130875  + x1_23*0.7825109733  + x1_24*0.2217023612 + x1_25*0.3081256411  + x1_26*-0.1778007966 + x1_27*-0.3333287743 + x1_28*1.0156352461  + x1_29*-0.1456257813);

      double x2_6=PineActivationTanh(x1_0*-0.5461783383 + x1_1*0.3246015999  + x1_2*0.1450605434 + x1_3*-1.3179944349 + x1_4*-1.5481775261 + x1_5*-0.679685633 + x1_6*-0.9462335139+ x1_7*-0.6462399371 + x1_8*0.0991658683  + x1_9*0.1612892194 + x1_10*-1.037660602  + x1_11*-0.1044778824 + x1_12*0.8309203243  + x1_13*0.7714766458  + x1_14*0.2566767663  + x1_15*0.8649416329 + x1_16*-0.5847461285 + x1_17*-0.6393969272 + x1_18*0.8014049359 + x1_19*0.2279568228  + x1_20*1.0565217821  + x1_21*0.134738029   + x1_22*0.3420395576  + x1_23*-0.2417397219 + x1_24*0.3083072038 + x1_25*0.6761739059  + x1_26*-0.4653817053 + x1_27*-1.0634057566 + x1_28*-0.5658892281 + x1_29*-0.6947283681);

      double x2_7=PineActivationTanh(x1_0*-0.5450410944 + x1_1*0.3912849372  + x1_2*-0.4118641117+ x1_3*0.7124695074  + x1_4*-0.7510266122 + x1_5*1.4065673913 + x1_6*0.9870731545 + x1_7*-0.2609363107 + x1_8*-0.3583639958 + x1_9*0.5436375706 + x1_10*0.4572450099  + x1_11*-0.4651538878 + x1_12*-0.2180218212 + x1_13*0.5241262959  + x1_14*-0.8529323253 + x1_15*-0.4200378937+ x1_16*0.4997885721 + x1_17*-1.1121528189  + x1_18*0.5992411048 + x1_19*-1.0263270781 + x1_20*-1.725160642  + x1_21*-0.2653995722 + x1_22*0.6996703032  + x1_23*0.348549086   + x1_24*0.6522482482 + x1_25*-0.7931928436 + x1_26*-0.5107994359 + x1_27*0.0509642698  + x1_28*0.8711187423  + x1_29*0.8999449627);

      double x2_8=PineActivationTanh(x1_0*-0.7111081522 + x1_1*0.4296245062  + x1_2*-2.0720732038+ x1_3*-0.4071818684 + x1_4*1.0632721681  + x1_5*0.8463224325 + x1_6*-0.6083948423+ x1_7*1.1827669608  + x1_8*-0.9572307844 + x1_9*-0.9080517673+ x1_10*-0.0479029057 + x1_11*-1.1452853213 + x1_12*0.2884352688  + x1_13*0.1767851586  + x1_14*-1.089314461  + x1_15*1.2991763966 + x1_16*1.6236630806 + x1_17*-0.7720263697  + x1_18*-0.5011541755+ x1_19*-2.3919413568 + x1_20*0.0084018338  + x1_21*0.9975216139  + x1_22*0.4193541029  + x1_23*1.4623834571  + x1_24*-0.6253069691+ x1_25*0.6119677341  + x1_26*0.5423948388  + x1_27*1.0022450377  + x1_28*-1.2392984069 + x1_29*1.5021529822);



      double x3_=PineActivationTanh(x2_0*0.3385061186+x2_1*0.6218531956+x2_2*-0.7790340983+x2_3*0.1413078332+x2_4*0.1857010624+x2_5*-0.1769456351+x2_6*-0.3242337911+x2_7*-0.503944883+x2_8*0.1540568869);



      BufferHB[i]=BufferHB[i+1];

      BufferLB[i]=BufferLB[i+1];

      if(x3_>threshold)

        {

         BufferHB[i]=1;

         BufferLB[i]=0;

        }

      if(x3_<-threshold)

        {

         BufferLB[i]=-1;

         BufferHB[i]=0;

        }

     }

   

//--- return value of prev_calculated for next call

   return(rates_total);

  }

//+------------------------------------------------------------------+

//| Custom indicator timer function                                  |

//+------------------------------------------------------------------+

void OnTimer()

  {

   if(timeframe_h==Period())

      return;

   Time(NULL,timeframe_h,1);

  }  

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

double PineActivationLinear(double v)

  {

   return((exp(v)+exp(-v))!=0 ? (exp(v)-exp(-v))/(exp(v)+exp(-v)) : 0);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

double PineActivationTanh(double v)

  {

   return((exp(v)+exp(-v))!=0 ? (exp(v)-exp(-v))/(exp(v)+exp(-v)) : 0);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

double GetDiff(int shift,const ENUM_TIMEFRAMES timeframe,const datetime &time[])

  {

   int bar=iBarShift(NULL,timeframe,time[shift],false);

   if(bar==WRONG_VALUE)

      return 0;

   double open0=iOpen(NULL,timeframe,bar);

   double open1=iOpen(NULL,timeframe,bar+1);

   double close0=iClose(NULL,timeframe,bar);

   double close1=iClose(NULL,timeframe,bar+1);

   double high0=iHigh(NULL,timeframe,bar);

   double high1=iHigh(NULL,timeframe,bar+1);

   double low0=iLow(NULL,timeframe,bar);

   double low1=iLow(NULL,timeframe,bar+1);

   if(open0==0 || open1==0 || high0==0 || high1==0 || low0==0 || low1==0 || close0==0 || close1==0)

      return 0;

   double yesterday=(open1+close1+high1+low1)/4;

   double today = (open0+close0+high0+low0)/4;

   double delta = today - yesterday;

   return(yesterday!=0 ? delta/yesterday : 0);

  }

//+------------------------------------------------------------------+

//| >72@0I05B Time                                                  |

//+------------------------------------------------------------------+

datetime Time(const string symbol_name,const ENUM_TIMEFRAMES timeframe,const int shift)

  {

   datetime array[];

   return(CopyTime(symbol_name,timeframe,shift,1,array)==1 ? array[0] : 0);

  }

//+------------------------------------------------------------------+

//| Timeframe to string                                              |

//+------------------------------------------------------------------+

string TimeframeToString(const ENUM_TIMEFRAMES timeframe)

  {

   return StringSubstr(EnumToString(timeframe),7);

  }

//+------------------------------------------------------------------+

Comments