41 righe
1,3 KiB
MQL5
41 righe
1,3 KiB
MQL5
#property link "https://twits.pl/"
|
|
#property copyright "© 2026 Tomasz Wyrzykiewicz, Twits. All rights reserved."
|
|
#property version "1.00"
|
|
#property description "Free version"
|
|
|
|
#include "price_speedometer.mqh"
|
|
|
|
const int ticks_capacity = 1048576;
|
|
input int period_in_ticks = 10000; // Period in ticks
|
|
input long period_in_milliseconds = 60000l; // Period in milliseconds
|
|
Price_speedometer price_speedometer(ticks_capacity, period_in_ticks,
|
|
period_in_milliseconds);
|
|
|
|
int OnInit() {
|
|
if (period_in_ticks < 10 || period_in_ticks > 10000) {
|
|
Alert("Invalid value of period in ticks!");
|
|
ExpertRemove();
|
|
}
|
|
if (period_in_milliseconds < 1000l || period_in_milliseconds > 100000l) {
|
|
Alert("Invalid value of period in milliseconds!");
|
|
ExpertRemove();
|
|
}
|
|
return INIT_SUCCEEDED;
|
|
}
|
|
|
|
void OnDeinit(const int reason) { return; }
|
|
|
|
void OnTick() {
|
|
const string symbol = _Symbol;
|
|
MqlTick tick;
|
|
if (!SymbolInfoTick(symbol, tick)) {
|
|
Print("Cannot get tick (last error: ", GetLastError(), ")!");
|
|
return;
|
|
}
|
|
price_speedometer.add_tick(tick);
|
|
price_speedometer.calculate_price_speeds();
|
|
price_speedometer.calculate_percents();
|
|
const string comment = price_speedometer.get_comment();
|
|
Comment(comment);
|
|
return;
|
|
}
|