Custom symbols. Errors, bugs, questions, suggestions. - page 31

 

Is there some mechanism to be able to share a hundred custom characters with someone else?

History is easy to transfer - just copying the Custom folder. But the character specifications are unclear.

 
fxsaber:

Is there some mechanism to be able to share a hundred custom characters with someone else?

History is easy to transfer - just copy the Custom folder. But the character specs are unclear.

I have to write custom script to upload/download them. I wouldn't wait for regular export/import.

 
Andrey Khatimlianskii:

A self-written upload/download script is called for. I wouldn't wait for a regular export/import script.

It takes a lot of effort, even though it seems simple at first glance. You need to know the correct sequence of setting symbol properties. Plus, there are troubles with quoting/trading sessions.

I.e. it takes a lot of work to debug and debug.

 

I'm having problems filling in the custom marks on the new chart. I am trying to create a new symbol chart with a different time.

But I always have problems filling in the marks in the currency symbol.

Here is the code:

//+------------------------------------------------------------------+
//|                                         Forward_Ticks_Sample.mq5 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 0

#include "Includes//Symbol.mqh"

string   g[];
int      total_len_history = 0,
         initialization_flag,
         symbol_history_wiped_clean,
         len_sym = StringSplit(Symbol(),'_',g);
string   Orig_Symbol_Name = g[0],
         symbol_custom=StringFormat("%s_frd",Orig_Symbol_Name);
datetime Let_start = 0;
bool     alert_once,
         commentplaced;
long     time_msc = long(Let_start)*1000,
         tick_chart_id;
ulong    LastTime_Added;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   ResetLastError();
   string name = MQLInfoString(MQL_PROGRAM_NAME);
   IndicatorSetString(INDICATOR_SHORTNAME, name);
   ResetLastError();

   Close_All_Symbols_Charts(symbol_custom);

   MqlTick tick;

   while(SymbolInfoTick(Orig_Symbol_Name, tick) == false)
     {
      Sleep(1000);
     }

   alert_once = false;

   tick_chart_id = 0;

   symbol_history_wiped_clean = Remove_Symbol_From_MarketWatch_Delete_History(symbol_custom);

   alert_once = true;
   initialization_flag = INIT_FAILED;

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
   ResetLastError();
   MqlTick tick, ticks[];

   if(symbol_history_wiped_clean == false)
     {
      Close_All_Symbols_Charts(symbol_custom);

      symbol_history_wiped_clean = Remove_Symbol_From_MarketWatch_Delete_History(symbol_custom);

      if(symbol_history_wiped_clean == false)
         return 0;
     }

   if(symbol_history_wiped_clean == true &&
      initialization_flag == INIT_FAILED
     )
     {
      Alert_me();
      if(Fill_ReFill_Custom_Symbol(symbol_custom) == -1)
         return 0;
      initialization_flag = INIT_SUCCEEDED;
      Print("History Filled Successfully.");
      Comment("");
      return rates_total;
     }

   SymbolInfoTick(Orig_Symbol_Name, tick);

//if(tick.time_msc != LastTime_Added)
     {
      ulong tick_count = tick.time_msc - LastTime_Added;
      uint get_count = uint(MathAbs(double(tick_count)));

      int len = CopyTicks(Orig_Symbol_Name, ticks, COPY_TICKS_ALL, LastTime_Added, get_count);

      if(len <= 2)
         return rates_total;

      ulong last_time = ticks[len - 1].time_msc;

      if(len > 5)
        {
         commentplaced = true;
         ChartSetString(tick_chart_id, CHART_COMMENT, "Please wait while we retrieve ticks........");
        }

      int filled = Tick_Filling_Logic(ticks, len);

      if(commentplaced == true && filled > 0)
        {
         if(last_time + 60 > ulong(TimeCurrent()))
           {
            ChartSetString(tick_chart_id, CHART_COMMENT, "");
            Comment("");
            commentplaced = false;
           }
        }

      if(tick_chart_id <= 0)
        {
         tick_chart_id = ChartOpen(symbol_custom, PERIOD_M1);
        }
     }

   return rates_total;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Close_All_Symbols_Charts(string local_symbol)
  {
   tick_chart_id = 0;
   ResetLastError();
   for(long chartid = ChartFirst(); chartid != -1 && !IsStopped(); chartid = ChartNext(chartid))
     {
      string name = ChartSymbol(chartid);

      if(StringFind(name, local_symbol) < 0)
         continue;

      if(!ChartClose(chartid))
         Print("Cannot close Chart Symbol: ", name, " Period: ", EnumToString(ChartPeriod(chartid)));
     }
   Sleep(1000);
  }
//+------------------------------------------------------------------+
bool Remove_Symbol_From_MarketWatch_Delete_History(string local_symbol)
  {
   ResetLastError();

   Sleep(10);
   const SYMBOL SYMB(local_symbol);

   bool custom = true;
   bool status = SYMB.IsExist();//SymbolExist(local_symbol, custom);

   if(status == false)
      return true;

   if(SYMB.Off() == false)
     {
      Print("Cannot UnSelect the Symbol ", local_symbol, " because: ", GetLastError());
      Sleep(5000);
     }

   Print(__FUNCTION__, " : Error = ", GetLastError());

   if(CustomTicksDelete(local_symbol, 0, LONG_MAX) <= 0)
      Print("Cannot Delete Custom Ticks: ", GetLastError());

   return true;
  }
//+------------------------------------------------------------------+
int Fill_ReFill_Custom_Symbol(string local_symbol)
  {
   ResetLastError();
   total_len_history = 0;
   alert_once = false;
   commentplaced  = false;
   LastTime_Added = 0;

   Comment("Refreshing the Tick Chart. Please Wait.");

   MqlDateTime str;
   TimeToStruct(iTime(Orig_Symbol_Name, 0, 0) - 30 * 86400, str);
   Comment("");
   datetime start_date = datetime(StringFormat("%d.%d.01 00:00:00",str.year,str.mon));
   const SYMBOL SYMB(local_symbol);
   SYMB.CloneProperties(Orig_Symbol_Name);


   MqlTick ticks_add[];

   ulong time_start = GetMicrosecondCount();

   ResetLastError();

   if(LastTime_Added == 0)
      LastTime_Added = ulong(start_date) * 1000;

   int len = CopyTicksRange(Orig_Symbol_Name,
                            ticks_add,
                            COPY_TICKS_ALL,
                            LastTime_Added,
                            ulong(TimeCurrent()) * 1000
                           );

   if(len<=0)
     {
      string error;
      if(GetLastError() == 4401)
         error = "ERR_HISTORY_NOT_FOUND";
      else
         error = string(GetLastError());
      Print("------------------------------------------------------------------");
      Print("History Tick Length: ", len, " Error: ", error);
      Print("------------------------------------------------------------------");
      Sleep(5000);
      // Print("Waited for 10000 milliseconds. Still no history found.");
      return -1;
     }

   Let_start = 0;
   time_msc = long(Let_start)*1000;

   int total = Tick_Filling_Logic(ticks_add, len);

   if(total <= 0)
     {
      SYMB.Off();
      CustomSymbolDelete(local_symbol);
      return -1;
     }

   if(GetLastError() == 4403)
     {
      Sleep(2000);
      Print("History Failed to Retrieve.");
      len = -1;
      return len;
     }

   Print("Gathering Ticks from : ", iTime(Orig_Symbol_Name, 0, 0) - 30 * 86400, " To: ", TimeCurrent());
   Print("Symbol Working :",SYMB.On());
   Print("Ticks: ",len);
   Print("Started : ",ticks_add[0].time,"  Ended : ",ticks_add[len-1].time);
   Print("Error Found: ",GetLastError());
   Print("Ticks Filled: ", total);

   Print("Time Required for completion: ",(GetMicrosecondCount()-time_start)/1000000);
   Print("Started : ",ticks_add[0].time,"  Ended : ",ticks_add[len-1].time);
   Print("History Loaded!!!!");
   Print(Let_start);

   Comment("");
   ChartSetString(tick_chart_id, CHART_COMMENT, "");

   return len;
  }
//+------------------------------------------------------------------+
void OnDeinit(const int r)
  {
   EventKillTimer();
  }
//+------------------------------------------------------------------+
void Alert_me()
  {
   if(alert_once == false)
      return;
   Alert(symbol_custom, " : Please Wait for Chart Refresh");
  }
//+------------------------------------------------------------------+
int Tick_Filling_Logic(MqlTick& ticks_add[],
                       int len)
  {
   ResetLastError();

   long last = ticks_add[len - 2].time_msc,
        time_msc_local = time_msc;
   datetime Let_start_local = Let_start;
   int total_len_history_local = total_len_history;

   for(int i=0; i < len - 1 && !IsStopped(); i++)
     {
      if(i == 0 || (i > 0 && iBarShift(Orig_Symbol_Name, PERIOD_M1, ticks_add[i].time) > iBarShift(Orig_Symbol_Name, PERIOD_M1, ticks_add[i + 1].time)))
        {
         Let_start_local = datetime(TimeToString(Let_start_local, TIME_DATE|TIME_MINUTES))
                           + 60;
         MqlDateTime tt1;
         TimeToStruct(Let_start_local, tt1);
         if(tt1.day_of_week == 0)
           {
            Let_start_local = Let_start_local + 86400;
           }
         else
            if(tt1.day_of_week == 6)
              {
               Let_start_local = Let_start_local + 86400*2;
              }
         time_msc_local = long(Let_start_local)*1000;
        }
      else
        {
         if(ticks_add[i].time == ticks_add[i + 1].time)
            time_msc_local = time_msc_local + 1;
         else
           {
            Let_start_local = Let_start_local + 1;
            time_msc_local = long(Let_start_local)*1000;
           }
        }
      ticks_add[i].time       = Let_start_local;
      ticks_add[i].time_msc   = time_msc_local;
      total_len_history_local = total_len_history_local + 1;
     }
   int total = CustomTicksAdd(symbol_custom, ticks_add);

   if(total <= 0)
     {
      Print("Tick Not added : ", GetLastError());
      total = CustomTicksReplace(symbol_custom, ticks_add[0].time_msc, ticks_add[len - 1].time_msc, ticks_add, len);
     }

   if(total == len)
     {
      LastTime_Added    = last;
      Let_start         = Let_start_local;
      time_msc          = time_msc_local;
      total_len_history = total_len_history_local;
     }
   else
     {
      Print("Tick not replaced : ", GetLastError(), " ", len, " = len but filled = ", total, " in ", symbol_custom);
     }
   return total;
  }
//+------------------------------------------------------------------+

I have attached the dependency file.

I am getting this error:

Please help me find the problem and what exactly I need to do to make it work properly.

The error means that I am not filling in the checkboxes on the structure. But if this is the case, how did the previous candles look perfect?

п

Files:
Symbol.mqh  7 kb
 
jaffer wilson :

I'm having problems filling in the custom marks on the new chart. I am trying to create a new symbol chart with a different time.

But I always have problems filling in the marks in the currency symbol.

Here is the code:

I have attached the dependency file.

I am getting this error:

Please help me find the problem and what exactly I need to do to make it work properly.

The error means that I am not filling in the checkboxes on the structure. But if this is the case, how did the previous candles look perfect?

п

Please help me with my custom symbol code. I'm stuck on this and my client is getting angry.

 
Имеется проблема обновления OHLC в CustomSymbol
Имеется проблема обновления OHLC в CustomSymbol
  • 2021.07.01
  • www.mql5.com
Я пробовал следующий код: Но всегда есть обновление, написанное на диаграмме. Плюс название символа другое в окне спецификации...
 

Opened the terminal today, downloaded update 2994, MT5 rebooted. I see all the symbols are gone, including many custom symbols.

In the bases\Custom folder I still have history and ticks folders with .hc, .hcc, .tkc data files for custom symbols, how can I use them now?

Warning! Do I really need to re-create custom symbols, import history etc.??

 
Sunriser:

Opened the terminal today, downloaded update 2994, MT5 rebooted. I see all the symbols are gone, including many custom symbols.

In the bases\Custom folder I still have history and ticks folders with .hc, .hcc, .tkc data files for custom symbols, how can I use them now?

Warning! Do I really need to re-create custom symbols, import history etc.?

You could try moving the Custom folder to another location and re-creating the symbols - specs, no history. Then quit the Terminal, copy back the Custom folder and start the Terminal. History should pick up.


Backup of json-character settings on Terminal side is called for. Accidental deletion or other nastiness - restore from backup.

 
fxsaber:

You can try to move the Custom folder to another location and re-create the symbols - specs, no history. Then quit the Terminal, copy back the Custom folder and start the Terminal. History should pick up.


Backup of json-character settings on Terminal side is called for. Accidentally deleted or other nasty thing - restore from backup.

It worked. Thanks for the time saved!

 

Forum on trading, automated trading systems and testing trading strategies

Custom Sybmol: ERROR 5308

Dark Ride3r, 2021.06.24 09:55

I am trying to set SYMBOL_VOLUME_MIN for a custom symbol but it returns ERROR 5308

I completely checked that the other parameters work fine, but only SYMBOL_VOLUME_MIN, for which I set it as double, returning

ERR_CUSTOM_SYMBOL_PARAMETER_ERROR 5308

so I think this is an error in the system and needs to be reported so it can be fixed

This is the method I use to create the symbol and set the property: SYMBOL_VOLUME_MIN for the custom symbol.

(SetProperty(SName, SYMBOL_VOLUME_MIN , 0.001 , "" )