+ Ответить в теме
Страница 1 из 3 1 2 3 ПоследняяПоследняя
Показано с 1 по 10 из 26

Тема: Volume Data in Experts

  1. #1
    ClusterDelta.com Team
    Регистрация
    27.10.2011
    Сообщений
    4,256
    Сказал(а) спасибо
    473
    Поблагодарили 2,157 раз(а) в 1,128 сообщениях

    Volume Data in Experts

    Отдельная благодарность за создание кода aorekhov@rambler.ru
    Ниже привожу исходное письмо отправленное мне от разработчика
    --------------------
    Volume & Delta Expert template

    Подготовил шаблон для робота который использует данные ваших индикаторов. Может работать как на истории так и на реале. Hужно только дописать торговую логику робота.
    Есть пара нюансов:
    1. Не стал заморачиваться и недоделал автоматическую GMT коррекцию, нужно ставить вручную.
    2. Если робот уже использовался и нужно протестировать историю на последних днях нужно стереть данные за последний месяц в папке сохраненных фаилов.
    3. Массив данных полностью стирается по 1 числу каждого месаца. И заполняеться данными на текущий месяц и дополнительно 2 недели предыдущего для возможности анализа в логике робота данных за последние 2 недели.
    4. Работает на М1, на других не проврялось
    Код:
    #property strict
    
    //################################################## ################## 
    //+----------------- CLUSTERDELTA VOLUME DATA --------------------------+
    
    #import "premium_mt4_v4x1.dll"
    int InitDLL(int &);
    string Receive_Information(int &, string);
    int Send_Query(int &, string, string, int, string, string, string,
    string, string, string, int, string, string, string,int);
    #import
    
    
    #import "online_mt4_v4x1.dll"
    int Online_Init(int&, string, int);
    string Online_Data(int&,string);
    int Online_Subscribe(int &, string, string, int, string, string, string,
    string, string, string, int, string, string, string,int);
    #import
    
    
    datetime TIME_Array[]; // Array for TIME
    double VOLUME_Array[]; // Array of Volumes, indexes of array are corelated to TIME_ARRAY
    double DELTA_Array[]; // Array of Deltas, indexes of array are corelated to TIME_ARRAY
    datetime last_loaded = 0;
    string indicator_client;
    bool VOLUMES_INIT, ReverseChart_SET = false; // not used in expert
    
    
    int Days_in_History;
    datetime Custom_Start_time, Custom_End_time;
    
    int INIT_DLL_result;
    
    
    
    int GMT_SET=1;
    int GMT =3; string MetaTrader_GMT = "+3"; // Change if GMT is different for both
    
    input string Ticker = "AUTO";
    
    
    //+------------------------------------------------------------------+
    //| Expert initialization function |
    //+------------------------------------------------------------------+
    int OnInit() {
    
    // --- Volume & Delta ---
    GlobalVariableDel(indicator_client);
    
    InitDLL(INIT_DLL_result); // in the next version you dont have use this function
    if(INIT_DLL_result==-1) { Print("Error during DLL init. ") ; ExpertRemove();}
    
    do // DO NOT CHANGE THIS CODE & DATA --- Volume & Delta
    {
    indicator_client =
    "CDPA" + StringSubstr(DoubleToString(TimeLocal(),0),7,3)+"" +DoubleToStr(MathAbs((MathRand()+3)%10),0);
    } while (GlobalVariableCheck(indicator_client));
    GlobalVariableTemp(indicator_client);
    
    if(!IsTesting())
    {
    Custom_Start_time = D'2017.01.01 00:00'; // Indicator parameters to load 14 last days
    Custom_End_time = D'2017.01.01 00:00';
    Days_in_History = 14;
    Online_Init(INIT_DLL_result, AccountCompany(), AccountNumber());
    }
    Vol_Delta_Cycle_Load();
    
    
    //--- create timer
    if(!IsTesting()) EventSetMillisecondTimer(100);
    
    //---
    return(INIT_SUCCEEDED);
    }
    //+------------------------------------------------------------------+
    //| Expert deinitialization function |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason) {
    EventKillTimer();
    GlobalVariableDel(indicator_client);
    
    for(int it = 1; it < 10; it ++) Print(Time[it]," / Vol ",VOLUME_by_index(it)," / Del ",DELTA_by_index(it)); // just yo check vol & delta is working
    }
    //+------------------------------------------------------------------+
    //| Expert tick function |
    //+------------------------------------------------------------------+
    void OnTick() {
    
    static int mmm, mn, vol, del; int vol_t, del_t;
    
    if(IsTesting() && mmm != Month()) {mmm = Month(); Testing_Load_ind_Vol_Del();}
    if(!IsTesting())
    {
    vol_t = VOLUME_by_index(1); del_t = DELTA_by_index(1);
    if(mn != Minute()) {mn = Minute(); vol = vol_t; del = del_t; Print("Vol ",vol," // Del ",del);}
    if(vol_t != vol || del_t != del) {vol = vol_t; del = del_t; Print("Update: Vol ",vol," // Del ",del);}
    }
    }
    //+------------------------------------------------------------------+
    //| Timer function |
    //+------------------------------------------------------------------+
    void OnTimer() {
    uchar static Timer, Timer_V;
    bool static Get_new_Vol = false;
    
    if(TimeHour(TimeCurrent()) < 1) return; // Do not download DPOC data before 1:00 (if set)
    if(!IsTesting())
    {
    Timer ++;
    if(TimeSeconds(TimeCurrent()) == 59) {VOLUMES_GetOnline();}
    else Timer_V ++;
    {
    Timer_V ++;
    if(Timer_V >= 10)
    {
    Timer_V = 0; VOLUMES_GetOnline();
    if(Get_new_Vol) { if(VOLUMES_GetData()) Get_new_Vol = false;}
    }
    }
    if(Timer >= 50) { VOLUMES_SetData(); Timer = 0; Get_new_Vol = true;}
    }
    
    }
    //+------------------------------------------------------------------+
    
    
    
    void Testing_Load_ind_Vol_Del() {
    
    ulong Timer_uSEC;
    int it, MM_0, MM_1, YY_0, YY_1, temp, cc;
    string mm_0, mm_1;
    int temp_1_Vol[], temp_2_Vol[], temp_1_Del[], temp_2_Del[];
    datetime temp_1_Time[], temp_2_Time[];
    
    ArrayFree(temp_1_Time); ArrayFree(temp_1_Vol); ArrayFree(temp_1_Del);
    ArrayFree(temp_2_Time); ArrayFree(temp_2_Vol); ArrayFree(temp_2_Del);
    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array);
    
    string f_name, f_handle, yyy, mmm;
    yyy = IntegerToString(Year());
    if(Month() < 10) mmm = "0"+ IntegerToString(Month()); else mmm = Month();
    f_name = Symbol() +"\\"+ IntegerToString(yyy) +"_"+ mmm +".csv";
    if(IsTesting() && FileIsExist(f_name)) {Testing_Load_file_Vol_Delta_by_Month(); return;}
    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array); // Reset Array for Vol & Delta: load 1st part
    MM_0 = Month() -1; YY_0 = Year(); MM_1 = Month(); YY_1 = YY_0;
    if(MM_0 == 0) {MM_0 = 12; YY_0 -= 1;}
    if(MM_0 < 10) mm_0 = "0"+ IntegerToString(MM_0); else mm_0 = IntegerToString(MM_0);
    if(MM_1 < 10) mm_1 = "0"+ IntegerToString(MM_1); else mm_1 = IntegerToString(MM_1);
    
    Custom_Start_time = StringToTime(IntegerToString(YY_0) +"."+ mm_0 +".12");
    Custom_End_time = StringToTime(IntegerToString(YY_1) +"."+ mm_1 +".01");
    Days_in_History = 0;
    Print("Load indicator data for period: ",TimeToString(Custom_Start_time)," - ",TimeToString(Custom_End_time));
    Vol_Delta_Cycle_Load(); if(!VOLUMES_INIT) {Print("Indicator Volume & Delta Data not loaded, exit"); ExpertRemove();}
    
    ArrayResize(temp_1_Time, ArraySize(TIME_Array));
    ArrayResize(temp_1_Vol , ArraySize(TIME_Array));
    ArrayResize(temp_1_Del, ArraySize(TIME_Array));
    for(it = 0; it < ArraySize(TIME_Array); it ++)
    {
    if(TimeMonth(TIME_Array[it]) == MM_1) continue;
    temp_1_Time[it] = TIME_Array[it];
    if(it < ArraySize(VOLUME_Array)) temp_1_Vol[it] = VOLUME_Array[it];
    if(it < ArraySize(DELTA_Array)) temp_1_Del[it] = DELTA_Array [it];
    }
    
    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array); // Reset Array for Vol & Delta: Load 2nd part
    MM_0 = Month(); YY_0 = Year(); MM_1 = Month() +1; YY_1 = YY_0;
    if(MM_1 == 13) {MM_1 = 1; YY_1 += 1;}
    if(MM_0 < 10) mm_0 = "0"+ IntegerToString(MM_0); else mm_0 = IntegerToString(MM_0);
    if(MM_1 < 10) mm_1 = "0"+ IntegerToString(MM_1); else mm_1 = IntegerToString(MM_1);
    Custom_Start_time = StringToTime(IntegerToString(YY_0) +"."+ mm_0 +".01");
    Custom_End_time = StringToTime(IntegerToString(YY_1) +"."+ mm_1 +".01");
    Days_in_History = 0;
    Print("Load indicator data for period: ",TimeToString(Custom_Start_time)," - ",TimeToString(Custom_End_time));
    Vol_Delta_Cycle_Load(); if(!VOLUMES_INIT) {Print("Indicator Volume & Delta Data not loaded, exit"); ExpertRemove();}
    
    ArrayResize(temp_2_Time, ArraySize(TIME_Array));
    ArrayResize(temp_2_Vol, ArraySize(TIME_Array));
    ArrayResize(temp_2_Del, ArraySize(TIME_Array));
    for(it = 0; it < ArraySize(TIME_Array); it ++)
    {
    if(TimeMonth(TIME_Array[it]) < MM_0) continue;
    temp_2_Time[it] = TIME_Array[it];
    if(it < ArraySize(VOLUME_Array)) temp_2_Vol[it] = VOLUME_Array[it];
    if(it < ArraySize(DELTA_Array)) temp_2_Del[it] = DELTA_Array [it];
    }
    
    
    
    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array); // Reset Array for Vol & Delta: merge 1st & 2nd parts
    for(it = 0; it < ArraySize(temp_1_Time); it ++)
    {
    ArrayResize(TIME_Array, ArraySize(TIME_Array) +1); TIME_Array [it] = temp_1_Time[it];
    ArrayResize(VOLUME_Array, ArraySize(VOLUME_Array) +1); VOLUME_Array[it] = temp_1_Vol [it];
    ArrayResize(DELTA_Array, ArraySize(DELTA_Array) +1); DELTA_Array [it] = temp_1_Del [it];
    }
    
    temp = ArraySize(temp_1_Time);
    for(it = 0; it < ArraySize(temp_2_Time); it ++)
    {
    ArrayResize(TIME_Array, ArraySize(TIME_Array) +1); TIME_Array [it +temp] = temp_2_Time[it];
    ArrayResize(VOLUME_Array, ArraySize(VOLUME_Array) +1); VOLUME_Array[it +temp] = temp_2_Vol [it];
    ArrayResize(DELTA_Array, ArraySize(DELTA_Array) +1); DELTA_Array [it +temp] = temp_2_Del [it];
    }
    
    Testing_Write_file_Vol_Delta_by_Month(); // save merged data to file
    
    }
    void Vol_Delta_Init() {
    
    indicator_client =
    "CDPA" + StringSubstr(DoubleToString(TimeLocal(),0),7,3)+"" +DoubleToStr(MathAbs((MathRand()+3)%10),0);
    }
    void Vol_Delta_Cycle_Load() {
    
    ulong Timer_uSEC;
    int it, itt, c;
    
    for(itt = 0; itt < 5; itt ++) // 5 attempt with reinitialization
    {
    Vol_Delta_Init(); Print("initialization Vol & Delta client # ",itt +1);
    for(it = 0; it < 3; it ++) // 3 attempt to load single request
    {
    Timer_uSEC = GetMicrosecondCount(); // ---------- send server request
    for(c = 1; c <= 3; c ++)
    {
    last_loaded = 0;
    if(VOLUMES_SetData() < 0) // Server request data
    {
    while(!IsStopped() && GetMicrosecondCount() < (Timer_uSEC + 5000000 *c)) { for( int cc = 0; cc < 100; cc ++)}
    Print("Volume - send server request #",c);
    }
    else break;
    }
    
    Timer_uSEC = GetMicrosecondCount(); // ---------- check for loaded data
    for(c = 1; c <= 5; c ++)
    {
    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array);
    if(VOLUMES_GetData() == 0) // Check is data ready ???
    {
    while(!IsStopped() && GetMicrosecondCount() < (Timer_uSEC + 5000000 * c)) for( int cc = 0; cc < 100; cc ++); // pause before next try
    }
    else
    { if(!VOLUMES_INIT)
    { while(!IsStopped() && GetMicrosecondCount() < (Timer_uSEC + 5000000 *c)) for( int cc = 0; cc < 100; cc ++); }}
    Print("Volume - check for loaded data #",c);
    if(VOLUMES_INIT) { Print("Volume Loaded # ",it); break;}
    }
    if(VOLUMES_INIT) break;
    }
    if(VOLUMES_INIT) break;
    }
    
    }
    int ArrayBsearchCorrect(datetime &array[], double value,
    int count = WHOLE_ARRAY, int start = 0,
    int direction = MODE_ASCEND) {
    if(ArraySize(array)==0) return(-1);
    int i = ArrayBsearch(array, (datetime)value, count, start, direction);
    if (value != array[i])
    {
    i = -1;
    }
    return (i);
    }
    void SortDictionary(datetime &keys[], double &values[], double &values2[], int sortDirection = MODE_ASCEND) {
    datetime keyCopy[];
    double valueCopy[];
    double valueCopy2[];
    ArrayCopy(keyCopy, keys);
    ArrayCopy(valueCopy, values);
    ArrayCopy(valueCopy2, values2);
    ArraySort(keys, WHOLE_ARRAY, 0, sortDirection);
    for (int i = 0; i < MathMin(ArraySize(keys), ArraySize(values)); i++)
    {
    values[ArrayBsearch(keys, keyCopy[i])] = valueCopy[i];
    values2[ArrayBsearch(keys, keyCopy[i])] = valueCopy2[i];
    }
    }
    void UpdateArray(datetime& td[],double& ad[], double& bd[], double dtp, double dta, double dtb) {
    datetime indexx = (datetime)dtp;
    
    int i=ArraySize(td);
    int iBase = ArrayBsearchCorrect(td, indexx );
    
    if (iBase >= 0) { i=iBase; }
    
    if(i>=ArraySize(td))
    {
    ArrayResize(td, i+1);
    ArrayResize(ad, i+1);
    ArrayResize(bd, i+1);
    } else {
    if(ad[i]>dta && i>=ArraySize(td)-2) { dta=ad[i]; dtb=bd[i]; }
    }
    
    td[i]= (datetime)dtp;
    ad[i]= dta;
    bd[i]= dtb;
    }
    int VOLUMES_SetData() {
    
    datetime Time_Current;
    datetime Time_bar_arr;
    
    if(IsTesting())
    {
    Time_Current = Custom_End_time;
    Time_bar_arr = Custom_End_time;
    }
    else
    {
    Time_Current = TimeCurrent();
    Time_bar_arr = Time[0];
    }
    
    
    int k=0,i;
    
    string Instrument = Ticker;
    string ver="4.1";
    
    
    
    i = Send_Query(k,indicator_client,
    Symbol(), Period(),
    TimeToStr(Time_Current), TimeToStr(Time_bar_arr),
    Instrument,TimeToStr(last_loaded),MetaTrader_GMT,v er,
    Days_in_History,TimeToStr(Custom_Start_time),TimeT oStr(Custom_End_time),
    AccountCompany(),AccountNumber());
    
    if (i < 0) { Alert ("Error during query registration"); return -1; }
    
    if(!IsTesting())
    {
    i = Online_Subscribe(k,indicator_client,
    Symbol(), Period(),
    TimeToStr(TimeCurrent()), TimeToStr(Time[0]),
    Instrument, TimeToStr(last_loaded),MetaTrader_GMT,ver,
    Days_in_History,TimeToStr(Custom_Start_time),TimeT oStr(Custom_End_time),
    AccountCompany(),AccountNumber()); //
    }
    
    VOLUMES_INIT = false;
    return 1;
    }
    int VOLUMES_GetData() {
    
    string response="";
    int length=0;
    int valid=0;
    int len=0,td_index;
    int i=0;
    double index;
    int iBase=0;
    double ask_value=0, bid_value=0;
    string result[];
    string bardata[];
    string MessageFromServer;
    
    // get query from dLL
    response = Receive_Information(length, indicator_client);
    if (length==0) { return 0; }
    
    if(StringLen(response)>1)
    {
    len=StringSplit(response,StringGetCharacter("\n",0 ),result);
    if(!len) { return 0; }
    MessageFromServer=result[0];
    
    for(i=1;i<len;i++)
    {
    if(StringLen(result[i])==0) continue;
    StringSplit (result[i],StringGetCharacter(";",0),bardata);
    // --- my check
    if(ArraySize(bardata) < 3)
    {
    Print("Zero Bardata");
    //Vol_Delta_Init(); // reinitialize Indicator
    //VOLUMES_SetData(); // resend server request
    return (0); // exit
    }
    // ---
    td_index = ArraySize(TIME_Array);
    index = (double)StrToTime (bardata[0]);
    ask_value = StringToDouble (bardata[1]);
    bid_value = StringToDouble (bardata[2])*(ReverseChart_SET?-1:1);
    
    
    if(index==0) continue;
    iBase = ArrayBsearchCorrect(TIME_Array, index );
    if(iBase >= 0) { td_index=iBase; }
    if(td_index >= ArraySize(TIME_Array))
    {
    ArrayResize(TIME_Array, td_index+1);
    ArrayResize(VOLUME_Array, td_index+1);
    ArrayResize(DELTA_Array, td_index+1);
    }
    else
    {
    if((VOLUME_Array[td_index]) > (ask_value) && td_index >= ArraySize(TIME_Array)-2)
    { ask_value = VOLUME_Array[td_index]; bid_value = DELTA_Array[td_index];}
    }
    
    TIME_Array [td_index] = (datetime)index;
    VOLUME_Array[td_index] = ask_value;
    DELTA_Array [td_index] = bid_value;
    
    }
    valid=ArraySize(TIME_Array);
    
    if (valid>0)
    {
    SortDictionary(TIME_Array,VOLUME_Array,DELTA_Array );
    int lastindex = ArraySize(TIME_Array);
    last_loaded=TIME_Array[lastindex-1];
    if(last_loaded>Time[0])last_loaded=Time[0];
    VOLUMES_INIT = true;
    }
    else return(0);
    
    }
    return (1);
    }
    int VOLUMES_GetOnline() {
    
    static int prnt_v_0, prnt_d_0, prnt_t_0, prnt_v_1, prnt_d_1, prnt_t_1;
    
    string response="";
    int length=0;
    string key="";
    string mydata="";
    int block=0;
    //if(Period()>60) return 0;
    response = Online_Data(length, indicator_client);
    if(length == 0) { return 0; }
    if(ArraySize(TIME_Array)<4) { return 0; }
    int key_i=StringFind(response, ":");
    key = StringSubstr(response,0,key_i);
    mydata = StringSubstr(response,key_i+1);
    int compare_minutes = 0;
    
    
    
    string result[];
    string bardata[];
    if(key == indicator_client)
    {
    StringSplit(mydata,StringGetCharacter("!",0),resul t);
    
    if(!GMT_SET)
    {
    StringSplit(result[2],StringGetCharacter(";",0),bardata);
    if(VOLUME_Array[ArraySize(VOLUME_Array)-3] == StringToDouble(bardata[1])) // 3-rd bar in stream is 3rd in series
    {
    StringSplit(result[0],StringGetCharacter(";",0),bardata);
    compare_minutes = int( (double)(TIME_Array[ArraySize(TIME_Array)-1]) - StringToDouble(bardata[0]) );
    GMT = int(compare_minutes / 3600);
    GMT_SET=0;
    } else
    if(VOLUME_Array[ArraySize(VOLUME_Array)-2] == StringToDouble(bardata[1])) // 3-rd bar in stream is 3rd in series
    {
    compare_minutes = int( (double)(TIME_Array[ArraySize(TIME_Array)-2]) - StringToDouble(bardata[0]) );
    GMT = int(compare_minutes / 3600);
    GMT_SET=0;
    }
    }
    
    StringSplit(result[0],StringGetCharacter(";",0),bardata);
    UpdateArray(TIME_Array, VOLUME_Array,DELTA_Array, StringToDouble(bardata[0])+3600*GMT, StringToDouble(bardata[1]),StringToDouble(bardata[2]));
    //if(prnt_t_0 != StrToInteger(bardata[0])+3600*GMT) {prnt_t_0 = StrToInteger(bardata[0])+3600*GMT; Print("Time_0 ",TimeToString(StrToInteger(bardata[0])+3600*GMT));}
    //if(prnt_v_0 != StrToInteger(bardata[1])) {prnt_v_0 = StrToInteger(bardata[1]); Print(" / Vol_0 ", bardata[1]);}
    //if(prnt_d_0 != StrToInteger(bardata[2])) {prnt_d_0 = StrToInteger(bardata[2]); Print(" / Delta_0 ", bardata[2]);}
    
    StringSplit(result[1],StringGetCharacter(";",0),bardata);
    UpdateArray(TIME_Array, VOLUME_Array,DELTA_Array, StringToDouble(bardata[0])+3600*GMT, StringToDouble(bardata[1]),StringToDouble(bardata[2]));
    //if(prnt_t_1 != StrToInteger(bardata[0])+3600*GMT) {prnt_t_1 = StrToInteger(bardata[0])+3600*GMT; Print("Time_1 ",TimeToString(StrToInteger(bardata[0])+3600*GMT));}
    //if(prnt_v_1 != StrToInteger(bardata[1])) {prnt_v_1 = StrToInteger(bardata[1]); Print(" / Vol_1 ", bardata[1]);}
    //if(prnt_d_1 != StrToInteger(bardata[2])) {prnt_d_1 = StrToInteger(bardata[2]); Print(" / Delta_1 ", bardata[2]);}
    }
    return 1;
    }
    int VOLUME_by_index(int ix, bool BrokehHour=true) {
    if(ArraySize(TIME_Array)<2) return 0;
    if(ArraySize(Time)<=ix) return 0;
    
    int iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] );
    
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 1*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 2*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 3*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 4*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M15 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 5*60 ); } // 5 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_H1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 30*60 ); } // 35 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 35*60 ); } // 35 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 60*60 ); } // 60 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 60*60 ); } // 60 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 2*60*60 ); } // 120 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_W1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 24*60*60); } // 35 Min BrokenHour / ES
    
    
    if (iBase >= 0)
    {
    return (int)VOLUME_Array[iBase];
    }
    
    return 0;
    }
    int DELTA_by_index (int ix, bool BrokehHour=true) {
    if(ArraySize(TIME_Array)<2) return 0;
    if(ArraySize(Time)<=ix) return 0;
    
    int iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] );
    
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 1*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 2*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 3*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 4*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M15 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 5*60 ); } // 5 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_H1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 30*60 ); } // 35 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 35*60 ); } // 35 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 60*60 ); } // 60 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 60*60 ); } // 60 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 2*60*60 ); } // 120 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_W1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 24*60*60); } // 35 Min BrokenHour / ES
    
    
    if (iBase >= 0)
    {
    return (int)DELTA_Array[iBase];
    }
    
    return 0;
    }
    void Testing_Write_file_Vol_Delta_by_Month() {
    
    if(!IsTesting()) return;
    int it, dt, vol, del;
    string f_name, f_handle, yyy, mmm, date;
    yyy = IntegerToString(Year());
    if(Month() < 10) mmm = "0"+ IntegerToString(Month()); else mmm = Month();
    f_name = Symbol() +"\\"+ IntegerToString(yyy) +"_"+ mmm +".csv"; if(FileIsExist(f_name)) return; // exit if file already exist
    
    f_handle = FileOpen(f_name, FILE_READ|FILE_WRITE|FILE_CSV);
    for(it = 0; it < ArraySize(TIME_Array); it ++)
    {
    dt = TIME_Array[it];
    date = TimeToString(dt);
    if(it < ArraySize(VOLUME_Array)) vol = VOLUME_Array[it];
    if(it < ArraySize(DELTA_Array)) del = DELTA_Array [it];
    if(f_handle > 0) FileWrite(f_handle, date, dt, vol, del);
    }
    FileClose(f_handle);
    }
    void Testing_Load_file_Vol_Delta_by_Month() {
    
    string f_name, yyy, mmm, date; int f_handle;
    yyy = IntegerToString(Year());
    if(Month() < 10) mmm = "0"+ IntegerToString(Month()); else mmm = Month();
    f_name = Symbol() +"\\"+ IntegerToString(yyy) +"_"+ mmm +".csv";
    
    f_handle = FileOpen(f_name, FILE_READ|FILE_WRITE|FILE_CSV);
    while(!FileIsEnding(f_handle))
    {
    ArrayResize(TIME_Array, ArraySize(TIME_Array) +1);
    ArrayResize(VOLUME_Array, ArraySize(VOLUME_Array) +1);
    ArrayResize(DELTA_Array, ArraySize(DELTA_Array) +1);
    
    date = FileReadString(f_handle);
    TIME_Array [ArraySize(TIME_Array) -1] = FileReadString(f_handle);
    VOLUME_Array[ArraySize(VOLUME_Array) -1] = FileReadString(f_handle);
    DELTA_Array [ArraySize(DELTA_Array) -1] = FileReadString(f_handle);
    }
    FileClose(f_handle);
    }

  2. #2
    ClusterDelta.com Team
    Регистрация
    27.10.2011
    Сообщений
    4,256
    Сказал(а) спасибо
    473
    Поблагодарили 2,157 раз(а) в 1,128 сообщениях
    Цитата Сообщение от deniss Посмотреть сообщение
    InitDLL(INIT_DLL_result); // in the next version you dont have use this function
    if(INIT_DLL_result==-1) { Print("Error during DLL init. ") ; ExpertRemove();}
    Если Вы будете подключать библотеку premiumt_mt4_v5x3.dll то эти две строки можно закомментировать.

  3. #3
    aorekhov@rambler.ru
    Гость
    Доработал советник.
    Теперь Metatrader GMT можно задавать в параметрах советника. Добавленна возможность записи объема и дельты в отдельный файл на каждый отдельный день.
    Это дает возможность очень быстро создавать индикаторы для оценки возможных торговых стратегий. Шаблоны советника и индикатора приложены.
    Также в качестве примера приложен индикатор объема с подсветкой событий: для положительного бара и отрицательной дельты и обратно. Индикатор работает только с историческими данными и может запускатся на графике резултата после прогона тестера. Родные индикаторы у меня не все и не всегда запускались в этом случае.
    В принцыпе в файл можно записывать и другую информацию для дальнейшего считывания этих данных для анализа через индикатор.
    Если будут интересные идеи могу попробывать их рализовать.

  4. #4
    aorekhov@rambler.ru
    Гость
    Советник работает на M1, M5, M15, M30, H1, H4

  5. #5
    aorekhov@rambler.ru
    Гость
    //+------------------------------------------------------------------+
    //| Volume & Delta Expert template.mq4 |
    //| |
    //| Alex. 20.07.2020 |
    //+------------------------------------------------------------------+
    #property strict

    //################################################## ################## //+----------------- CLUSTERDELTA VOLUM DATA --------------------------+

    #import "premium_mt4_v4x1.dll"
    int InitDLL(int &);
    string Receive_Information(int &, string);
    int Send_Query(int &, string, string, int, string, string, string,
    string, string, string, int, string, string, string,int);
    #import


    #import "online_mt4_v4x1.dll"
    int Online_Init(int&, string, int);
    string Online_Data(int&,string);
    int Online_Subscribe(int &, string, string, int, string, string, string,
    string, string, string, int, string, string, string,int);
    #import


    datetime TIME_Array[]; // Array for TIME
    double VOLUME_Array[]; // Array of Volumes, indexes of array are corelated to TIME_ARRAY
    double DELTA_Array[]; // Array of Deltas, indexes of array are corelated to TIME_ARRAY
    datetime last_loaded = 0;
    string indicator_client;
    bool VOLUMES_INIT, ReverseChart_SET = false; // not used in expert


    int Days_in_History;
    datetime Custom_Start_time, Custom_End_time;

    int INIT_DLL_result;



    int GMT_SET=1;
    // int GMT =3;
    string MetaTrader_GMT; //= "+3"; // Change if GMT is different for both

    input int GMT = 3; // MetaTrader_GMT
    input string Ticker = "AUTO";
    input bool Daily_File = true; // Make Daily Volume & Delta file


    //+------------------------------------------------------------------+
    //| Expert initialization function |
    //+------------------------------------------------------------------+
    int OnInit() {

    // --- Volume & Delta ---
    GlobalVariableDel(indicator_client);
    if(GMT > 0) MetaTrader_GMT = "+" + IntegerToString(GMT);
    if(GMT <= 0) MetaTrader_GMT = IntegerToString(GMT);


    InitDLL(INIT_DLL_result); // in the next version you dont have use this function
    if(INIT_DLL_result==-1) { Print("Error during DLL init. ") ; ExpertRemove();}

    do // DO NOT CHANGE THIS CODE & DATA --- Volume & Delta
    {
    indicator_client =
    "CDPA" + StringSubstr(DoubleToString(TimeLocal(),0),7,3)+"" +DoubleToStr(MathAbs((MathRand()+3)%10),0);
    } while (GlobalVariableCheck(indicator_client));
    GlobalVariableTemp(indicator_client);

    if(!IsTesting())
    {
    Custom_Start_time = D'2017.01.01 00:00'; // Indicator parameters to load 14 last days
    Custom_End_time = D'2017.01.01 00:00';
    Days_in_History = 14;
    Online_Init(INIT_DLL_result, AccountCompany(), AccountNumber());
    }
    Vol_Delta_Cycle_Load();


    //--- create timer
    if(!IsTesting()) EventSetMillisecondTimer(100);

    //---
    return(INIT_SUCCEEDED);
    }
    //+------------------------------------------------------------------+
    //| Expert deinitialization function |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason) {
    EventKillTimer();
    GlobalVariableDel(indicator_client);

    for(int it = 1; it < 10; it ++) Print(Time[it]," / Vol ",VOLUME_by_index(it)," / Del ",DELTA_by_index(it)); // just yo check vol & delta is working
    }
    //+------------------------------------------------------------------+
    //| Expert tick function |
    //+------------------------------------------------------------------+
    void OnTick() {

    static int mmm, ddd, mn, vol, del; int vol_t, del_t; datetime dt;

    if(IsTesting() && mmm != Month()) {mmm = Month(); Testing_Load_ind_Vol_Del();}
    if(IsTesting() && ddd != Day()) {ddd = Day(); if(Daily_File) Testing_Write_ind_Vol_Del_Daily();}

    if(!IsTesting())
    {
    vol_t = VOLUME_by_index(1); del_t = DELTA_by_index(1);
    if(mn != Minute()) {mn = Minute(); vol = vol_t; del = del_t; Print("Vol ",vol," // Del ",del);}
    if(vol_t != vol || del_t != del) {vol = vol_t; del = del_t; Print("Update: Vol ",vol," // Del ",del);}
    }
    }
    //+------------------------------------------------------------------+
    //| Timer function |
    //+------------------------------------------------------------------+
    void OnTimer() {
    uchar static Timer, Timer_V;
    bool static Get_new_Vol = false;

    if(TimeHour(TimeCurrent()) < 1) return; // Do not download DPOC data before 1:00 (if set)
    if(!IsTesting())
    {
    Timer ++;
    if(TimeSeconds(TimeCurrent()) == 59) {VOLUMES_GetOnline();}
    else Timer_V ++;
    {
    Timer_V ++;
    if(Timer_V >= 10)
    {
    Timer_V = 0; VOLUMES_GetOnline();
    if(Get_new_Vol) { if(VOLUMES_GetData()) Get_new_Vol = false;}
    }
    }
    if(Timer >= 50) { VOLUMES_SetData(); Timer = 0; Get_new_Vol = true;}
    }

    }
    //+------------------------------------------------------------------+



    void Testing_Load_ind_Vol_Del() {

    ulong Timer_uSEC;
    int it, MM_0, MM_1, YY_0, YY_1, temp, cc;
    string mm_0, mm_1;
    int temp_1_Vol[], temp_2_Vol[], temp_1_Del[], temp_2_Del[];
    datetime temp_1_Time[], temp_2_Time[];

    ArrayFree(temp_1_Time); ArrayFree(temp_1_Vol); ArrayFree(temp_1_Del);
    ArrayFree(temp_2_Time); ArrayFree(temp_2_Vol); ArrayFree(temp_2_Del);
    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array);

    string f_name, f_handle, yyy, mmm;
    yyy = IntegerToString(Year());
    if(Month() < 10) mmm = "0"+ IntegerToString(Month()); else mmm = Month();
    f_name = Symbol() +"\\"+ Period() +"\\"+ yyy +"_"+ mmm +".csv";
    if(IsTesting() && FileIsExist(f_name)) {Testing_Load_file_Vol_Delta_by_Month(); return;}
    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array); // Reset Array for Vol & Delta: load 1st part
    MM_0 = Month() -1; YY_0 = Year(); MM_1 = Month(); YY_1 = YY_0;
    if(MM_0 == 0) {MM_0 = 12; YY_0 -= 1;}
    if(MM_0 < 10) mm_0 = "0"+ IntegerToString(MM_0); else mm_0 = IntegerToString(MM_0);
    if(MM_1 < 10) mm_1 = "0"+ IntegerToString(MM_1); else mm_1 = IntegerToString(MM_1);

    Custom_Start_time = StringToTime(IntegerToString(YY_0) +"."+ mm_0 +".12");
    Custom_End_time = StringToTime(IntegerToString(YY_1) +"."+ mm_1 +".01");
    Days_in_History = 0;
    Print("Load indicator data for period: ",TimeToString(Custom_Start_time)," - ",TimeToString(Custom_End_time));
    Vol_Delta_Cycle_Load(); if(!VOLUMES_INIT) {Print("Indicator Volume & Delta Data not loaded, exit"); ExpertRemove();}

    ArrayResize(temp_1_Time, ArraySize(TIME_Array));
    ArrayResize(temp_1_Vol , ArraySize(TIME_Array));
    ArrayResize(temp_1_Del, ArraySize(TIME_Array));
    for(it = 0; it < ArraySize(TIME_Array); it ++)
    {
    if(TimeMonth(TIME_Array[it]) == MM_1) continue;
    temp_1_Time[it] = TIME_Array[it];
    if(it < ArraySize(VOLUME_Array)) temp_1_Vol[it] = VOLUME_Array[it];
    if(it < ArraySize(DELTA_Array)) temp_1_Del[it] = DELTA_Array [it];
    }

    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array); // Reset Array for Vol & Delta: Load 2nd part
    MM_0 = Month(); YY_0 = Year(); MM_1 = Month() +1; YY_1 = YY_0;
    if(MM_1 == 13) {MM_1 = 1; YY_1 += 1;}
    if(MM_0 < 10) mm_0 = "0"+ IntegerToString(MM_0); else mm_0 = IntegerToString(MM_0);
    if(MM_1 < 10) mm_1 = "0"+ IntegerToString(MM_1); else mm_1 = IntegerToString(MM_1);
    Custom_Start_time = StringToTime(IntegerToString(YY_0) +"."+ mm_0 +".01");
    Custom_End_time = StringToTime(IntegerToString(YY_1) +"."+ mm_1 +".01");
    Days_in_History = 0;
    Print("Load indicator data for period: ",TimeToString(Custom_Start_time)," - ",TimeToString(Custom_End_time));
    Vol_Delta_Cycle_Load(); if(!VOLUMES_INIT) {Print("Indicator Volume & Delta Data not loaded, exit"); ExpertRemove();}

    ArrayResize(temp_2_Time, ArraySize(TIME_Array));
    ArrayResize(temp_2_Vol, ArraySize(TIME_Array));
    ArrayResize(temp_2_Del, ArraySize(TIME_Array));
    for(it = 0; it < ArraySize(TIME_Array); it ++)
    {
    if(TimeMonth(TIME_Array[it]) < MM_0) continue;
    temp_2_Time[it] = TIME_Array[it];
    if(it < ArraySize(VOLUME_Array)) temp_2_Vol[it] = VOLUME_Array[it];
    if(it < ArraySize(DELTA_Array)) temp_2_Del[it] = DELTA_Array [it];
    }



    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array); // Reset Array for Vol & Delta: merge 1st & 2nd parts
    for(it = 0; it < ArraySize(temp_1_Time); it ++)
    {
    ArrayResize(TIME_Array, ArraySize(TIME_Array) +1); TIME_Array [it] = temp_1_Time[it];
    ArrayResize(VOLUME_Array, ArraySize(VOLUME_Array) +1); VOLUME_Array[it] = temp_1_Vol [it];
    ArrayResize(DELTA_Array, ArraySize(DELTA_Array) +1); DELTA_Array [it] = temp_1_Del [it];
    }

    temp = ArraySize(temp_1_Time);
    for(it = 0; it < ArraySize(temp_2_Time); it ++)
    {
    ArrayResize(TIME_Array, ArraySize(TIME_Array) +1); TIME_Array [it +temp] = temp_2_Time[it];
    ArrayResize(VOLUME_Array, ArraySize(VOLUME_Array) +1); VOLUME_Array[it +temp] = temp_2_Vol [it];
    ArrayResize(DELTA_Array, ArraySize(DELTA_Array) +1); DELTA_Array [it +temp] = temp_2_Del [it];
    }

    Testing_Write_file_Vol_Delta_by_Month(); // save merged data to file

    }
    void Vol_Delta_Init() {

    indicator_client =
    "CDPA" + StringSubstr(DoubleToString(TimeLocal(),0),7,3)+"" +DoubleToStr(MathAbs((MathRand()+3)%10),0);
    }
    void Vol_Delta_Cycle_Load() {

    ulong Timer_uSEC;
    int it, itt, c;

    for(itt = 0; itt < 5; itt ++) // 5 attempt with reinitialization
    {
    Vol_Delta_Init(); Print("initialization Vol & Delta client # ",itt +1);
    for(it = 0; it < 3; it ++) // 3 attempt to load single request
    {
    Timer_uSEC = GetMicrosecondCount(); // ---------- send server request
    for(c = 1; c <= 3; c ++)
    {
    last_loaded = 0;
    if(VOLUMES_SetData() < 0) // Server request data
    {
    while(!IsStopped() && GetMicrosecondCount() < (Timer_uSEC + 5000000 *c)) { for( int cc = 0; cc < 100; cc ++)}
    Print("Volume - send server request #",c);
    }
    else break;
    }

    Timer_uSEC = GetMicrosecondCount(); // ---------- check for loaded data
    for(c = 1; c <= 5; c ++)
    {
    ArrayFree(TIME_Array); ArrayFree(VOLUME_Array); ArrayFree(DELTA_Array);
    if(VOLUMES_GetData() == 0) // Check is data ready ???
    {
    while(!IsStopped() && GetMicrosecondCount() < (Timer_uSEC + 5000000 * c)) for( int cc = 0; cc < 100; cc ++); // pause before next try
    }
    else
    { if(!VOLUMES_INIT)
    { while(!IsStopped() && GetMicrosecondCount() < (Timer_uSEC + 5000000 *c)) for( int cc = 0; cc < 100; cc ++); }}
    Print("Volume - check for loaded data #",c);
    if(VOLUMES_INIT) { Print("Volume Loaded # ",it); break;}
    }
    if(VOLUMES_INIT) break;
    }
    if(VOLUMES_INIT) break;
    }

    }
    int ArrayBsearchCorrect(datetime &array[], double value,
    int count = WHOLE_ARRAY, int start = 0,
    int direction = MODE_ASCEND) {
    if(ArraySize(array)==0) return(-1);
    int i = ArrayBsearch(array, (datetime)value, count, start, direction);
    if (value != array[i])
    {
    i = -1;
    }
    return (i);
    }
    void SortDictionary(datetime &keys[], double &values[], double &values2[], int sortDirection = MODE_ASCEND) {
    datetime keyCopy[];
    double valueCopy[];
    double valueCopy2[];
    ArrayCopy(keyCopy, keys);
    ArrayCopy(valueCopy, values);
    ArrayCopy(valueCopy2, values2);
    ArraySort(keys, WHOLE_ARRAY, 0, sortDirection);
    for (int i = 0; i < MathMin(ArraySize(keys), ArraySize(values)); i++)
    {
    values[ArrayBsearch(keys, keyCopy[i])] = valueCopy[i];
    values2[ArrayBsearch(keys, keyCopy[i])] = valueCopy2[i];
    }
    }
    void UpdateArray(datetime& td[],double& ad[], double& bd[], double dtp, double dta, double dtb) {
    datetime indexx = (datetime)dtp;

    int i=ArraySize(td);
    int iBase = ArrayBsearchCorrect(td, indexx );

    if (iBase >= 0) { i=iBase; }

    if(i>=ArraySize(td))
    {
    ArrayResize(td, i+1);
    ArrayResize(ad, i+1);
    ArrayResize(bd, i+1);
    } else {
    if(ad[i]>dta && i>=ArraySize(td)-2) { dta=ad[i]; dtb=bd[i]; }
    }

    td[i]= (datetime)dtp;
    ad[i]= dta;
    bd[i]= dtb;
    }
    int VOLUMES_SetData() {

    datetime Time_Current;
    datetime Time_bar_arr;

    if(IsTesting())
    {
    Time_Current = Custom_End_time;
    Time_bar_arr = Custom_End_time;
    }
    else
    {
    Time_Current = TimeCurrent();
    Time_bar_arr = Time[0];
    }


    int k=0,i;

    string Instrument = Ticker;
    string ver="4.1";



    i = Send_Query(k,indicator_client,
    Symbol(), Period(),
    TimeToStr(Time_Current), TimeToStr(Time_bar_arr),
    Instrument,TimeToStr(last_loaded),MetaTrader_GMT,v er,
    Days_in_History,TimeToStr(Custom_Start_time),TimeT oStr(Custom_End_time),
    AccountCompany(),AccountNumber());

    if (i < 0) { Alert ("Error during query registration"); return -1; }

    if(!IsTesting())
    {
    i = Online_Subscribe(k,indicator_client,
    Symbol(), Period(),
    TimeToStr(TimeCurrent()), TimeToStr(Time[0]),
    Instrument, TimeToStr(last_loaded),MetaTrader_GMT,ver,
    Days_in_History,TimeToStr(Custom_Start_time),TimeT oStr(Custom_End_time),
    AccountCompany(),AccountNumber()); //
    }

    VOLUMES_INIT = false;
    return 1;
    }
    int VOLUMES_GetData() {

    string response="";
    int length=0;
    int valid=0;
    int len=0,td_index;
    int i=0;
    double index;
    int iBase=0;
    double ask_value=0, bid_value=0;
    string result[];
    string bardata[];
    string MessageFromServer;

    // get query from dLL
    response = Receive_Information(length, indicator_client);
    if (length==0) { return 0; }

    if(StringLen(response)>1)
    {
    len=StringSplit(response,StringGetCharacter("\n",0 ),result);
    if(!len) { return 0; }
    MessageFromServer=result[0];

    for(i=1;i<len;i++)
    {
    if(StringLen(result[i])==0) continue;
    StringSplit (result[i],StringGetCharacter(";",0),bardata);
    // --- my check
    if(ArraySize(bardata) < 3)
    {
    Print("Zero Bardata");
    //Vol_Delta_Init(); // reinitialize Indicator
    //VOLUMES_SetData(); // resend server request
    return (0); // exit
    }
    // ---
    td_index = ArraySize(TIME_Array);
    index = (double)StrToTime (bardata[0]);
    ask_value = StringToDouble (bardata[1]);
    bid_value = StringToDouble (bardata[2])*(ReverseChart_SET?-1:1);


    if(index==0) continue;
    iBase = ArrayBsearchCorrect(TIME_Array, index );
    if(iBase >= 0) { td_index=iBase; }
    if(td_index >= ArraySize(TIME_Array))
    {
    ArrayResize(TIME_Array, td_index+1);
    ArrayResize(VOLUME_Array, td_index+1);
    ArrayResize(DELTA_Array, td_index+1);
    }
    else
    {
    if((VOLUME_Array[td_index]) > (ask_value) && td_index >= ArraySize(TIME_Array)-2)
    { ask_value = VOLUME_Array[td_index]; bid_value = DELTA_Array[td_index];}
    }

    TIME_Array [td_index] = (datetime)index;
    VOLUME_Array[td_index] = ask_value;
    DELTA_Array [td_index] = bid_value;

    }
    valid=ArraySize(TIME_Array);

    if (valid>0)
    {
    SortDictionary(TIME_Array,VOLUME_Array,DELTA_Array );
    int lastindex = ArraySize(TIME_Array);
    last_loaded=TIME_Array[lastindex-1];
    if(last_loaded>Time[0])last_loaded=Time[0];
    VOLUMES_INIT = true;
    }
    else return(0);

    }
    return (1);
    }
    int VOLUMES_GetOnline() {

    static int prnt_v_0, prnt_d_0, prnt_t_0, prnt_v_1, prnt_d_1, prnt_t_1;

    string response="";
    int length=0;
    string key="";
    string mydata="";
    int block=0;
    //if(Period()>60) return 0;
    response = Online_Data(length, indicator_client);
    if(length == 0) { return 0; }
    if(ArraySize(TIME_Array)<4) { return 0; }
    int key_i=StringFind(response, ":");
    key = StringSubstr(response,0,key_i);
    mydata = StringSubstr(response,key_i+1);
    int compare_minutes = 0;



    string result[];
    string bardata[];
    if(key == indicator_client)
    {
    StringSplit(mydata,StringGetCharacter("!",0),resul t);

    /*
    if(!GMT_SET)
    {
    StringSplit(result[2],StringGetCharacter(";",0),bardata);
    if(VOLUME_Array[ArraySize(VOLUME_Array)-3] == StringToDouble(bardata[1])) // 3-rd bar in stream is 3rd in series
    {
    StringSplit(result[0],StringGetCharacter(";",0),bardata);
    compare_minutes = int( (double)(TIME_Array[ArraySize(TIME_Array)-1]) - StringToDouble(bardata[0]) );
    GMT = int(compare_minutes / 3600);
    GMT_SET=0;
    } else
    if(VOLUME_Array[ArraySize(VOLUME_Array)-2] == StringToDouble(bardata[1])) // 3-rd bar in stream is 3rd in series
    {
    compare_minutes = int( (double)(TIME_Array[ArraySize(TIME_Array)-2]) - StringToDouble(bardata[0]) );
    GMT = int(compare_minutes / 3600);
    GMT_SET=0;
    }
    } */

    StringSplit(result[0],StringGetCharacter(";",0),bardata);
    UpdateArray(TIME_Array, VOLUME_Array,DELTA_Array, StringToDouble(bardata[0])+3600*GMT, StringToDouble(bardata[1]),StringToDouble(bardata[2]));
    //if(prnt_t_0 != StrToInteger(bardata[0])+3600*GMT) {prnt_t_0 = StrToInteger(bardata[0])+3600*GMT; Print("Time_0 ",TimeToString(StrToInteger(bardata[0])+3600*GMT));}
    //if(prnt_v_0 != StrToInteger(bardata[1])) {prnt_v_0 = StrToInteger(bardata[1]); Print(" / Vol_0 ", bardata[1]);}
    //if(prnt_d_0 != StrToInteger(bardata[2])) {prnt_d_0 = StrToInteger(bardata[2]); Print(" / Delta_0 ", bardata[2]);}

    StringSplit(result[1],StringGetCharacter(";",0),bardata);
    UpdateArray(TIME_Array, VOLUME_Array,DELTA_Array, StringToDouble(bardata[0])+3600*GMT, StringToDouble(bardata[1]),StringToDouble(bardata[2]));
    //if(prnt_t_1 != StrToInteger(bardata[0])+3600*GMT) {prnt_t_1 = StrToInteger(bardata[0])+3600*GMT; Print("Time_1 ",TimeToString(StrToInteger(bardata[0])+3600*GMT));}
    //if(prnt_v_1 != StrToInteger(bardata[1])) {prnt_v_1 = StrToInteger(bardata[1]); Print(" / Vol_1 ", bardata[1]);}
    //if(prnt_d_1 != StrToInteger(bardata[2])) {prnt_d_1 = StrToInteger(bardata[2]); Print(" / Delta_1 ", bardata[2]);}
    }
    return 1;
    }
    int VOLUME_by_index(int ix, bool BrokehHour=true) {
    if(ArraySize(TIME_Array)<2) return 0;
    if(ArraySize(Time)<=ix) return 0;

    int iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] );

    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 1*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 2*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 3*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 4*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M15 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 5*60 ); } // 5 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_H1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 30*60 ); } // 35 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 35*60 ); } // 35 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 60*60 ); } // 60 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 60*60 ); } // 60 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 2*60*60 ); } // 120 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_W1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 24*60*60); } // 35 Min BrokenHour / ES


    if (iBase >= 0)
    {
    return (int)VOLUME_Array[iBase];
    }

    return 0;
    }
    int DELTA_by_index (int ix, bool BrokehHour=true) {
    if(ArraySize(TIME_Array)<2) return 0;
    if(ArraySize(Time)<=ix) return 0;

    int iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] );

    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 1*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 2*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 3*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M5 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 4*60 ); } // 1 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_M15 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 5*60 ); } // 5 Min BrokenHour
    if (iBase < 0 && Period() >= PERIOD_H1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 30*60 ); } // 35 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 35*60 ); } // 35 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] - 60*60 ); } // 60 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 60*60 ); } // 60 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_H4 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 2*60*60 ); } // 120 Min BrokenHour / ES
    if (iBase < 0 && Period() >= PERIOD_W1 && BrokehHour) { iBase = ArrayBsearchCorrect(TIME_Array, Time[ix] + 24*60*60); } // 35 Min BrokenHour / ES


    if (iBase >= 0)
    {
    return (int)DELTA_Array[iBase];
    }

    return 0;
    }
    void Testing_Write_file_Vol_Delta_by_Month() {

    if(!IsTesting()) return;
    int it, dt, vol, del;
    string f_name, f_handle, yyy, mmm, date;
    yyy = IntegerToString(Year());
    if(Month() < 10) mmm = "0"+ IntegerToString(Month()); else mmm = Month();
    f_name = Symbol() +"\\"+ Period() +"\\"+ yyy +"_"+ mmm +".csv"; if(FileIsExist(f_name)) return; // exit if file already exist

    f_handle = FileOpen(f_name, FILE_READ|FILE_WRITE|FILE_CSV);
    for(it = 0; it < ArraySize(TIME_Array); it ++)
    {
    dt = TIME_Array[it];
    date = TimeToString(dt);
    if(it < ArraySize(VOLUME_Array)) vol = VOLUME_Array[it];
    if(it < ArraySize(DELTA_Array)) del = DELTA_Array [it];
    if(f_handle > 0) FileWrite(f_handle, date, dt, vol, del);
    }
    FileClose(f_handle);
    }
    void Testing_Load_file_Vol_Delta_by_Month() {

    string f_name, yyy, mmm, date; int f_handle;
    yyy = IntegerToString(Year());
    if(Month() < 10) mmm = "0"+ IntegerToString(Month()); else mmm = Month();
    f_name = Symbol() +"\\"+ Period() +"\\"+ yyy +"_"+ mmm +".csv";

    f_handle = FileOpen(f_name, FILE_READ|FILE_WRITE|FILE_CSV);
    while(!FileIsEnding(f_handle))
    {
    ArrayResize(TIME_Array, ArraySize(TIME_Array) +1);
    ArrayResize(VOLUME_Array, ArraySize(VOLUME_Array) +1);
    ArrayResize(DELTA_Array, ArraySize(DELTA_Array) +1);

    date = FileReadString(f_handle);
    TIME_Array [ArraySize(TIME_Array) -1] = FileReadString(f_handle);
    VOLUME_Array[ArraySize(VOLUME_Array) -1] = FileReadString(f_handle);
    DELTA_Array [ArraySize(DELTA_Array) -1] = FileReadString(f_handle);
    }
    FileClose(f_handle);
    }

    void Testing_Write_ind_Vol_Del_Daily() {

    string yyy, mmm, ddd, hh, mm;
    string vol_f, del_f, time_f, date_f, datetime_f;
    string file_name;
    int ix, step, f_handle;
    datetime it;


    if(Month() < 10) mmm = "0"+ IntegerToString(Month()); else mmm = Month();
    if(Day() < 10) ddd = "0"+ IntegerToString(Day()); else ddd = Day();
    yyy = IntegerToString(Year());


    file_name = Symbol() +"\\"+ Period() +"\\"+ yyy +"\\"+ mmm +"\\"+ ddd + "_ID.csv";
    if(FileIsExist(file_name)) return;
    f_handle = FileOpen(file_name, FILE_READ|FILE_WRITE|FILE_CSV);

    if(Period() == 1) step = 60;
    if(Period() == 5) step = 300;
    if(Period() == 15) step = 900;
    if(Period() == 30) step = 1800;
    if(Period() == 60) step = 3600;
    if(Period() == 240) step = 14400;
    if(Period() > 240) {Print("D1 TimeFrame not allowed"); ExpertRemove();}
    for(it = iTime(NULL,PERIOD_D1,0); it > 0; it += step)
    {
    if(TimeDay(it) != Day()) return;
    ix = ArrayBsearchCorrect(TIME_Array,it);
    if(ix > 0)
    {
    if(TimeHour (it) <= 9) hh = "0" + IntegerToString(TimeHour(it));
    else hh = IntegerToString(TimeHour(it));
    if(TimeMinute (it) <= 9) mm = "0" + IntegerToString(TimeMinute(it));
    else mm = IntegerToString(TimeMinute(it));

    datetime_f = IntegerToString((int)TIME_Array[ix]);
    date_f = yyy +"."+ mmm +"."+ ddd;
    time_f = hh +":"+ mm;

    vol_f = IntegerToString(VOLUME_Array[ix]); del_f = IntegerToString(DELTA_Array[ix]);
    if(f_handle > 0) FileWrite(f_handle, datetime_f, date_f, time_f, vol_f, del_f);
    }
    }
    FileClose(f_handle);
    }

  6. #6
    aorekhov@rambler.ru
    Гость
    //+------------------------------------------------------------------+
    //| Tester Indicator Template.mq4 |
    //| |
    //| Alex 2020 |
    //+------------------------------------------------------------------+
    //#property copyright "Copyright © 2013, Fox.RM"


    //---- indicator settings
    #property strict
    #property indicator_separate_window
    #property indicator_buffers 1
    #property indicator_color1 Blue



    input string File_ID = "_ID.csv"; // file ID


    //--- CSV_data ---
    datetime Time_Arr [1440];
    int Vol_Arr [1440];
    int Del_Arr [1440];

    int Vol, Del;

    //---- indicator buffers
    double vol[];;

    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    int OnInit() {
    IndicatorShortName("");

    SetIndexBuffer(0,vol);
    SetIndexLabel(0,"Vol");
    SetIndexStyle(0,DRAW_LINE);




    //---- initialization done
    return(INIT_SUCCEEDED);
    }

    void OnDeinit(const int reason) {}
    //+------------------------------------------------------------------+
    //| Awesome Oscillator |
    //+------------------------------------------------------------------+
    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[]) {

    static int curr_ddd;
    int it, ix, ddd;

    for(it = rates_total -1; it > 0; it --)
    {
    ddd = TimeDay(Time[it]);
    if(curr_ddd != ddd) {curr_ddd = ddd; Data_to_Arr_from_File(Time[it], File_ID);}

    Volume_Delta(it); Indicator_Calc(it);
    }
    return(rates_total);
    }
    //+------------------------------------------------------------------+

    void Indicator_Calc(int ii) {

    vol[ii] = Vol;
    }
    void Volume_Delta(int ii) {

    int ix = ArrayBsearchCorrect(Time_Arr,Time[ii]);
    if(ix > 0) {Vol = Vol_Arr[ix]; Del = Del_Arr[ix];}
    }
    void Data_to_Arr_from_File(datetime dt, string id) {

    int yyy, mmm, ddd, it, f_handle;
    string f_yyy, f_mmm, f_ddd, file_name, nm_folder;

    ArrayInitialize(Time_Arr,0); ArrayInitialize(Del_Arr,0);

    yyy = TimeYear (dt); f_yyy = IntegerToString(yyy);
    mmm = TimeMonth(dt); f_mmm = IntegerToString(mmm); if(mmm <= 9) f_mmm = "0" + IntegerToString(mmm);
    ddd = TimeDay (dt); f_ddd = IntegerToString(ddd); if(ddd <= 9) f_ddd = "0" + IntegerToString(ddd);

    file_name = Symbol() +"\\"+ Period() +"\\"+ f_yyy +"\\"+ f_mmm +"\\"+ f_ddd + id;
    if(!FileIsExist(file_name)) {Print("Data file not found"); OnDeinit(0);}

    f_handle = FileOpen(file_name, FILE_READ|FILE_WRITE|FILE_CSV);
    if(f_handle < 0) {Print("Invalid file handle"); OnDeinit(0);}
    else
    {
    for(it = 0; it < 1440; it ++)
    {
    Time_Arr[it] = FileReadString(f_handle);
    FileReadString(f_handle); FileReadString(f_handle);
    Vol_Arr [it] = FileReadString(f_handle);
    Del_Arr [it] = FileReadString(f_handle);

    //if(FileIsEnding(f_handle)) {FileClose(f_handle); Print("File Read completed ",it," // file name - ",file_name); break;}
    }
    }
    FileClose(f_handle);
    Arrat_to_Sort(Time_Arr, Vol_Arr, Del_Arr);
    }
    void Arrat_to_Sort(datetime &keys[], int &vol[], int &del[], int sortDirection = MODE_ASCEND) {

    datetime keyCopy[];
    int vol_Copy[];
    int del_Copy[];
    int vol_av_Copy[];
    float HL_Copy[];
    float OC_Copy[];
    float HL_x_Copy[];
    float OL_x_Copy[];
    float OH_x_Copy[];

    ArrayCopy(keyCopy, keys);
    ArrayCopy(vol_Copy, vol);
    ArrayCopy(del_Copy, del);


    ArraySort(keys, WHOLE_ARRAY, 0, sortDirection);
    for (int i = 0; i < ArraySize(keys); i++)
    {
    vol [ArrayBsearch(keys, keyCopy[i])] = vol_Copy [i];
    del [ArrayBsearch(keys, keyCopy[i])] = del_Copy [i];
    }
    }

    int ArrayBsearchCorrect(datetime &array[], double value,
    int count = WHOLE_ARRAY, int start = 0,
    int direction = MODE_ASCEND) { //MODE_ASCEND, MODE_DESCEND) {
    if(ArraySize(array)==0) return(-1);
    int i = ArrayBsearch(array, (datetime)value, count, start, direction);
    if (value != array[i])
    {
    i = -1;
    }
    return (i);
    }

  7. #7
    aorekhov@rambler.ru
    Гость
    //+------------------------------------------------------------------+
    //| Tester Indicator - Volume (delta_clr).mq4 |
    //| |
    //| Alex 2020 |
    //+------------------------------------------------------------------+

    //---- indicator settings
    #property strict
    #property indicator_separate_window
    #property indicator_buffers 3
    #property indicator_color1 DarkGray
    #property indicator_color2 Lime
    #property indicator_color3 OrangeRed

    #property indicator_width1 1
    #property indicator_width2 2
    #property indicator_width3 2


    input string File_ID = "_ID.csv"; // file ID


    //--- CSV_data ---
    datetime Time_Arr [1440];
    int Vol_Arr [1440];
    int Del_Arr [1440];

    int Vol, Del;

    //---- indicator buffers
    double vol[], vol_up[], vol_dn[];

    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    int OnInit() {
    IndicatorShortName("");

    SetIndexBuffer(0,vol);
    SetIndexBuffer(1,vol_up);
    SetIndexBuffer(2,vol_dn);


    SetIndexStyle(0,DRAW_HISTOGRAM);
    SetIndexStyle(1,DRAW_HISTOGRAM);
    SetIndexStyle(2,DRAW_HISTOGRAM);




    //---- initialization done
    return(INIT_SUCCEEDED);
    }

    void OnDeinit(const int reason) {}
    //+------------------------------------------------------------------+
    //| Awesome Oscillator |
    //+------------------------------------------------------------------+
    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[]) {

    static int curr_ddd;
    int it, ix, ddd;

    for(it = rates_total -1; it > 0; it --)
    {
    ddd = TimeDay(Time[it]);
    if(curr_ddd != ddd) {curr_ddd = ddd; Data_to_Arr_from_File(Time[it], File_ID);}

    Volume_Delta(it); Indicator_Calc(it);
    }
    return(rates_total);
    }
    //+------------------------------------------------------------------+

    void Indicator_Calc(int ii) {

    if(Close[ii] > Open[ii] && Del < 0) {vol_up[ii] = Vol; return;}
    if(Close[ii] < Open[ii] && Del > 0) {vol_dn[ii] = Vol; return;}
    vol[ii] = Vol;
    }
    void Volume_Delta(int ii) {

    int ix = ArrayBsearchCorrect(Time_Arr,Time[ii]);
    if(ix > 0) {Vol = Vol_Arr[ix]; Del = Del_Arr[ix];}
    }
    void Data_to_Arr_from_File(datetime dt, string id) {

    int yyy, mmm, ddd, it, f_handle;
    string f_yyy, f_mmm, f_ddd, file_name, nm_folder;

    ArrayInitialize(Time_Arr,0); ArrayInitialize(Del_Arr,0);

    yyy = TimeYear (dt); f_yyy = IntegerToString(yyy);
    mmm = TimeMonth(dt); f_mmm = IntegerToString(mmm); if(mmm <= 9) f_mmm = "0" + IntegerToString(mmm);
    ddd = TimeDay (dt); f_ddd = IntegerToString(ddd); if(ddd <= 9) f_ddd = "0" + IntegerToString(ddd);

    file_name = Symbol() +"\\"+ Period() +"\\"+ f_yyy +"\\"+ f_mmm +"\\"+ f_ddd + id;
    if(!FileIsExist(file_name)) {Print("Data file not found"); OnDeinit(0);}

    f_handle = FileOpen(file_name, FILE_READ|FILE_WRITE|FILE_CSV);
    if(f_handle < 0) {Print("Invalid file handle"); OnDeinit(0);}
    else
    {
    for(it = 0; it < 1440; it ++)
    {
    Time_Arr[it] = FileReadString(f_handle);
    FileReadString(f_handle); FileReadString(f_handle);
    Vol_Arr [it] = FileReadString(f_handle);
    Del_Arr [it] = FileReadString(f_handle);

    //if(FileIsEnding(f_handle)) {FileClose(f_handle); Print("File Read completed ",it," // file name - ",file_name); break;}
    }
    }
    FileClose(f_handle);
    Arrat_to_Sort(Time_Arr, Vol_Arr, Del_Arr);
    }
    void Arrat_to_Sort(datetime &keys[], int &vol[], int &del[], int sortDirection = MODE_ASCEND) {

    datetime keyCopy[];
    int vol_Copy[];
    int del_Copy[];
    int vol_av_Copy[];
    float HL_Copy[];
    float OC_Copy[];
    float HL_x_Copy[];
    float OL_x_Copy[];
    float OH_x_Copy[];

    ArrayCopy(keyCopy, keys);
    ArrayCopy(vol_Copy, vol);
    ArrayCopy(del_Copy, del);


    ArraySort(keys, WHOLE_ARRAY, 0, sortDirection);
    for (int i = 0; i < ArraySize(keys); i++)
    {
    vol [ArrayBsearch(keys, keyCopy[i])] = vol_Copy [i];
    del [ArrayBsearch(keys, keyCopy[i])] = del_Copy [i];
    }
    }

    int ArrayBsearchCorrect(datetime &array[], double value,
    int count = WHOLE_ARRAY, int start = 0,
    int direction = MODE_ASCEND) { //MODE_ASCEND, MODE_DESCEND) {
    if(ArraySize(array)==0) return(-1);
    int i = ArrayBsearch(array, (datetime)value, count, start, direction);
    if (value != array[i])
    {
    i = -1;
    }
    return (i);
    }

  8. #8
    aorekhov@rambler.ru
    Гость
    Советник записывает дневные файлы только в режиме тестирования. Поэтому необходимо папку "Символа" скопировать из папки files Тестера в папку files MQL4. Каждый таймфрейм записывается в разные папки, поэтому можно создавать и хранить данные для разных таймфреймов одновременно.

  9. #9
    aorekhov@rambler.ru
    Гость

    Files

    Файлы советника и индикаторов прикреплены.
    Tester_Ind_Template.mq4
    Tester_Ind_ClusterDelta_Vol(delta_clr).mq4
    Volume & Delta template Expert.mq4

  10. Пользователь сказал cпасибо: zigoba
  11. #10
    aorekhov@rambler.ru
    Гость
    Замечен баги:
    1. на М1 и М5 на большом интервале истории перестают записываться ежемесячно файлы объемов/делты. Не понятно с чем это связано. Чобы получить файлы с 2018 пришлось делить весь интервал на 3 части. После загрызки всех файлов можно работать со всем интервалом целиком.
    2. на М1 и М5 не создаются по понедельникам дневные фаилы которые я использую для индикаторов в тестере.
    На М15, М30, Н1, Н4 проблем нет. Если есть толковые програмисты просьба подправить код.

  12. Пользователь сказал cпасибо: zigoba
+ Ответить в теме
Страница 1 из 3 1 2 3 ПоследняяПоследняя

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
           

 


(C) 2009-2023 ClusterDelta.com.