//—————————————————————————————————————————————————————————————————————————————— //Функция для ядра string GPU_kernel(int HL1NeuronCount,int HL2NeuronCount,int SampleCount,int SignalInCount) { return( "//#pragma OPENCL EXTENSION cl_khr_fp64: enable \r\n" "#define HL1Count " +(string)HL1NeuronCount+" \r\n" "#define HL2Count " +(string)HL2NeuronCount+" \r\n" //---------------------------------------------------------------------- "#define PorogSell1 " +(string)PorogSell1+" \r\n" "#define PorogSell2 " +(string)PorogSell2+" \r\n" "#define PorogBuy1 " +(string)PorogBuy1+" \r\n" "#define PorogBuy2 " +(string)PorogBuy2+" \r\n" //---------------------------------------------------------------------- "#define SampleCount " +(string)SampleCount+" \r\n" //---------------------------------------------------------------------- "#define SignalInCount "+(string)SignalInCount+" \r\n" //---------------------------------------------------------------------- "#define StrArrSaSize "+(string)(sizeof(ArrSample)/sizeof(float))+"\r\n" "typedef struct{float C[StrArrSaSize];} ArrSa; \r\n" //---------------------------------------------------------------------- "#define StrArrWeSize "+(string)(sizeof(ArrWe)/sizeof(float))+" \r\n" "typedef struct{float C[StrArrWeSize];} ArrWe; \r\n" //---------------------------------------------------------------------- "#define StrArrCrSize "+(string)(sizeof(ArrCr)/sizeof(float))+" \r\n" "typedef struct{float C[StrArrCrSize];}ArrCr; \r\n" //---------------------------------------------------------------------- "#define Spread "+(string)(SpreadTraining_P*Point())+" \r\n" //---------------------------------------------------------------------- "#define MinAllowTradeCount "+(string)(MinAllowTradeCount_P)+" \r\n" "#define K_MinAllowTradeCount "+(string)(K_MinAllowTradeCount_P)+" \r\n" //---------------------------------------------------------------------- //---------------------------------------------------------------------- "__kernel void Work(__global ArrSa *Sample, \r\n" " __global ArrWe *Weights, \r\n" " __global ArrCr *Result, \r\n" " __global float *KoOfCrit) \r\n" "{ \r\n" //---------------------------------------------------------------------- " int thread = get_global_id(0); \r\n" " //------------------Переменные нейронной сети-------------------\r\n" " float HL1[HL1Count]; // Нейроны первого скрытого слоя \r\n" " float HL2[HL2Count]; // Нейроны второго скрытого слоя \r\n" " ArrWe weights = Weights[thread]; \r\n" " int cnt_W = 0; // счетчик весов \r\n" " float Out = 0.0; // выход сети \r\n" " //--------------------------------------------------------------\r\n" " //------------------Переменные для торговли---------------------\r\n" " float temp = 0.0; // для временного хранения чего нибудь \r\n" " float PriceOpen = 0.0; // цена открытия открытой сделки \r\n" " float Price = 0.0; // текущая цена \r\n" " float High = 0.0; // максимум предыдущей свечи \r\n" " float Low = 0.0; // минимум предыдущей свечи \r\n" " bool TypeBuy = true; // тип сделки: buy-true, sell-false \r\n" " //--------------------Статистика торговли----------------------------\r\n" " float PipsAllProfit = 0.00001; // полученная прибыль в пипсах + \r\n" " float PipsAllLoss =-0.00001; // полученный убыток в пипсах - \r\n" " int TradeProfitCount = 1; // кол-во приб. сделок + \r\n" " int TradeLossCount = 1; // кол-во уб. сделок + \r\n" " float TradeDrawdown = 0.0; // просадка в трейде + \r\n" " float SummDrawdown = 0.00001; // сумма всех просадок для подсч.средн.+ \r\n" " int LossSeries = 0; // серия убыточных ордеров + \r\n" " int MaxLossSer = 0; // самая длинная серия уб.ордеров + \r\n" " //-------------------------------------------------------------- \r\n" " // Тут прогон по истории \r\n" " for(int hist=0;histHigh)?(Price-PriceOpen+Spread):(High-PriceOpen+Spread);\r\n" " TradeDrawdown=(TradeDrawdown0.0) \r\n" " { \r\n" " PipsAllProfit+=temp; \r\n" " TradeProfitCount++; \r\n" " LossSeries=0; \r\n" " } \r\n" " else \r\n" " { \r\n" " PipsAllLoss+=temp; \r\n" " LossSeries++; \r\n" " MaxLossSer=(MaxLossSerHigh)?(Price-PriceOpen+Spread):(High-PriceOpen+Spread); \r\n" " TradeDrawdown=(TradeDrawdown0.0) \r\n" " { \r\n" " PipsAllProfit+=temp; \r\n" " TradeProfitCount++; \r\n" " LossSeries=0; \r\n" " } \r\n" " else \r\n" " { \r\n" " PipsAllLoss+=temp; \r\n" " LossSeries++; \r\n" " MaxLossSer=(MaxLossSerPorogBuy1) \r\n" " { \r\n" " temp=PriceOpen-Price-Spread; \r\n" " if(temp>0.0) \r\n" " { \r\n" " PipsAllProfit+=temp; \r\n" " TradeProfitCount++; \r\n" " LossSeries=0; \r\n" " } \r\n" " else \r\n" " { \r\n" " PipsAllLoss+=temp; \r\n" " LossSeries++; \r\n" " MaxLossSer=(MaxLossSerPorogBuy2) \r\n" " { \r\n" " PriceOpen=Price; \r\n" " TypeBuy=true; \r\n" " } \r\n" " } \r\n" " //-------------------------------------------------------------------\r\n" " } \r\n" " \r\n" " float AveDrawdown = SummDrawdown/(TradeProfitCount+TradeLossCount); \r\n" " float AveProf = PipsAllProfit/TradeProfitCount; \r\n" " float AveLoss = PipsAllLoss/TradeLossCount; \r\n" " float PipsAll = PipsAllProfit+PipsAllLoss; \r\n" " float ProfitFactor =-AveProf/AveLoss; \r\n" " float koOfCr = 1.0; \r\n" " //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\r\n" " \r\n" " if(TradeProfitCount+TradeLossCount5) \r\n" " // koOfCr=koOfCr*0.8; \r\n" " \r\n" " Result [thread].C[0] = PipsAll; \r\n" " Result [thread].C[1] = ProfitFactor; \r\n" " Result [thread].C[2] =-AveDrawdown; \r\n" " Result [thread].C[3] = TradeProfitCount/TradeLossCount; \r\n" " Result [thread].C[3] =-MaxLossSer; \r\n" " \r\n" " KoOfCrit[thread] = koOfCr; \r\n" "} \r\n" ); //HL2[u]=5.0*HL2[u]/(1.0+fabs(4.02*HL2[u])); } //——————————————————————————————————————————————————————————————————————————————