Tick_Forge/tools/TF_Probe.mq5
23 라인
1.3 KiB
MQL5
//| Developer probe: can an INDICATOR create a custom symbol and write ticks / bars? MIT. |
#property indicator_chart_window
#property indicator_plots 0
int OnInit()
{
string n = "TFPROBE";
bool c = CustomSymbolCreate(n, "Custom\Tick Forge", "GOLD.pro");
PrintFormat("PROBE create=%d err=%d", c, GetLastError());
MqlTick t[3];
datetime b = D'2026.10.05 10:00';
for(int i = 0; i < 3; i++) { t[i].time = b + i; t[i].time_msc = (long)(b + i) * 1000; t[i].bid = 100 + i; t[i].ask = 100.5 + i; t[i].flags = TICK_FLAG_BID | TICK_FLAG_ASK; }
int r = CustomTicksReplace(n, (long)b * 1000, (long)(b + 5) * 1000, t);
PrintFormat("PROBE ticksReplace=%d err=%d", r, GetLastError());
MqlRates m[1]; m[0].time = b; m[0].open = 100; m[0].high = 102; m[0].low = 100; m[0].close = 102; m[0].tick_volume = 3;
r = CustomRatesReplace(n, b, b + 60, m);
PrintFormat("PROBE ratesReplace=%d err=%d", r, GetLastError());
MqlTick g[]; int k = CopyTicksRange("GOLD.pro", g, COPY_TICKS_ALL, (ulong)D'2026.10.05 10:00' * 1000, (ulong)D'2026.10.05 10:01' * 1000);
PrintFormat("PROBE copyticks=%d err=%d", k, GetLastError());
Sleep(10);
Print("PROBE after sleep err=", GetLastError());
return INIT_SUCCEEDED;
}
int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { return rates_total; }