beast-agent 2.38.4 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agent/bots.js +66 -0
- package/src/agent/customtools.js +52 -2
- package/src/agent/defaulttools/mt5_barlar2/run.js +188 -0
- package/src/agent/defaulttools/mt5_barlar2/tool.json +23 -0
- package/src/agent/defaulttools/mt5_bekleyen/run.js +100 -0
- package/src/agent/defaulttools/mt5_bekleyen/tool.json +17 -0
- package/src/agent/defaulttools/mt5_durum/run.js +93 -0
- package/src/agent/defaulttools/mt5_durum/tool.json +10 -0
- package/src/agent/defaulttools/mt5_emir/run.js +98 -0
- package/src/agent/defaulttools/mt5_emir/tool.json +17 -0
- package/src/agent/defaulttools/mt5_emir_iptal/run.js +90 -0
- package/src/agent/defaulttools/mt5_emir_iptal/tool.json +12 -0
- package/src/agent/defaulttools/mt5_fiyat/run.js +87 -0
- package/src/agent/defaulttools/mt5_fiyat/tool.json +16 -0
- package/src/agent/defaulttools/mt5_gecmis/run.js +87 -0
- package/src/agent/defaulttools/mt5_gecmis/tool.json +12 -0
- package/src/agent/defaulttools/mt5_kapat/run.js +92 -0
- package/src/agent/defaulttools/mt5_kapat/tool.json +13 -0
- package/src/agent/defaulttools/mt5_m15_m5/m15m5.py +60 -0
- package/src/agent/defaulttools/mt5_m15_m5/run.js +73 -0
- package/src/agent/defaulttools/mt5_m15_m5/tool.json +10 -0
- package/src/agent/defaulttools/mt5_pozisyon_gecmis/run.js +144 -0
- package/src/agent/defaulttools/mt5_pozisyon_gecmis/tool.json +12 -0
- package/src/agent/defaulttools/mt5_shot/run.js +428 -0
- package/src/agent/defaulttools/mt5_shot/tool.json +20 -0
- package/src/agent/defaulttools/mt5_sltp/run.js +92 -0
- package/src/agent/defaulttools/mt5_sltp/tool.json +14 -0
- package/src/agent/engine.js +259 -47
- package/src/agent/financetools.js +52 -0
- package/src/agent/mt5/BeastFinance.mq5 +427 -0
- package/src/agent/mt5/BeastShot.tpl +0 -0
- package/src/agent/mt5setup.js +542 -0
- package/src/agent/scripts/mt5_bridge.py +112 -0
- package/src/agent/seeds/mql5/SKILL.md +27 -2
- package/src/agent/seeds/tool-yazma/SKILL.md +6 -4
- package/src/main.js +233 -13
- package/src/preload.js +1 -0
- package/src/renderer/index.html +18 -5
- package/src/renderer/renderer.js +170 -37
- package/src/renderer/style.css +45 -17
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
//+------------------------------------------------------------------+
|
|
2
|
+
//| BeastFinance.mq5 — Beast Finance köprü EA'sı (v1.20) |
|
|
3
|
+
//| - Heartbeat: MQL5\Files\beast_ea.json (durum + izinler + equity) |
|
|
4
|
+
//| - Komut köprüsü: beast_cmd.json (Beast yazar) → beast_cmd_ack.json|
|
|
5
|
+
//| - Entegrasyon/Screenshot: grafik üstü pano (Comment) + seviye |
|
|
6
|
+
//| çizgileri — Beast beast_note.json ile besler; görsel ajan |
|
|
7
|
+
//| computer_look ile chart screenshot'ında bu panoyu görür. |
|
|
8
|
+
//+------------------------------------------------------------------+
|
|
9
|
+
#property copyright "Beast Agent"
|
|
10
|
+
#property link "https://github.com/algokodcom/beast-agent"
|
|
11
|
+
#property version "1.20"
|
|
12
|
+
#property description "Beast Finance köprü EA'sı — heartbeat + komut köprüsü + grafik panosu."
|
|
13
|
+
|
|
14
|
+
#include <Trade\Trade.mqh>
|
|
15
|
+
|
|
16
|
+
input string InpTag = "BeastFinance"; // Etiket
|
|
17
|
+
input int InpHeartbeat = 5; // Kalp atışı (sn)
|
|
18
|
+
input bool InpVerbose = true; // Grafik panosunu yaz
|
|
19
|
+
input long InpMagic = 20260910; // Magic number
|
|
20
|
+
|
|
21
|
+
CTrade gTrade;
|
|
22
|
+
|
|
23
|
+
string BeatFile = "beast_ea.json";
|
|
24
|
+
string CmdFile = "beast_cmd.json";
|
|
25
|
+
string AckFile = "beast_cmd_ack.json";
|
|
26
|
+
string NoteFile = "beast_note.json";
|
|
27
|
+
string LvlPrefix = "BeastLvl_";
|
|
28
|
+
|
|
29
|
+
string gNoteText = "";
|
|
30
|
+
string gNoteSymbol = "";
|
|
31
|
+
|
|
32
|
+
int OnInit()
|
|
33
|
+
{
|
|
34
|
+
gTrade.SetExpertMagicNumber(InpMagic);
|
|
35
|
+
gTrade.SetTypeFillingBySymbol(_Symbol);
|
|
36
|
+
EventSetTimer(MathMax(1, InpHeartbeat));
|
|
37
|
+
WriteBeat("init");
|
|
38
|
+
RefreshPanel();
|
|
39
|
+
Print("BeastFinance EA başlatıldı: ", _Symbol, " period=", (int)Period());
|
|
40
|
+
return(INIT_SUCCEEDED);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void OnDeinit(const int reason)
|
|
44
|
+
{
|
|
45
|
+
EventKillTimer();
|
|
46
|
+
WriteBeat("deinit");
|
|
47
|
+
ClearLevels();
|
|
48
|
+
Comment("");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void OnTimer()
|
|
52
|
+
{
|
|
53
|
+
ReadNote();
|
|
54
|
+
WriteBeat("beat");
|
|
55
|
+
ProcessCommands();
|
|
56
|
+
RefreshPanel();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void OnTick()
|
|
60
|
+
{
|
|
61
|
+
// Fiyat bazlı ek işler ileride buraya eklenecek (sinyal/uyarı üretimi).
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
string JStr(string s)
|
|
65
|
+
{
|
|
66
|
+
StringReplace(s, "\\", "\\\\");
|
|
67
|
+
StringReplace(s, "\"", "\\\"");
|
|
68
|
+
return s;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void WriteBeat(const string stage)
|
|
72
|
+
{
|
|
73
|
+
int h = FileOpen(BeatFile, FILE_WRITE|FILE_TXT|FILE_UNICODE);
|
|
74
|
+
if(h == INVALID_HANDLE) return;
|
|
75
|
+
string js = StringFormat("{\"ok\":true,\"ea\":\"BeastFinance\",\"version\":\"1.20\",\"tag\":\"%s\",\"stage\":\"%s\",\"time\":%d,\"server_time\":\"%s\",\"symbol\":\"%s\",\"period\":%d,\"equity\":%.2f,\"balance\":%.2f,\"terminal_trade_allowed\":%s,\"mql_trade_allowed\":%s,\"positions\":%d,\"note\":\"%s\"}",
|
|
76
|
+
JStr(InpTag), stage, (int)TimeCurrent(), TimeToString(TimeCurrent(), TIME_DATE|TIME_SECONDS),
|
|
77
|
+
_Symbol, (int)Period(),
|
|
78
|
+
AccountInfoDouble(ACCOUNT_EQUITY), AccountInfoDouble(ACCOUNT_BALANCE),
|
|
79
|
+
(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) ? "true" : "false"),
|
|
80
|
+
(MQLInfoInteger(MQL_TRADE_ALLOWED) ? "true" : "false"),
|
|
81
|
+
PositionsTotal(),
|
|
82
|
+
JStr(StringSubstr(gNoteText, 0, 120)));
|
|
83
|
+
FileWriteString(h, js);
|
|
84
|
+
FileClose(h);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* ---------- grafik panosu (screenshot'larda görünür) ---------- */
|
|
88
|
+
|
|
89
|
+
void RefreshPanel()
|
|
90
|
+
{
|
|
91
|
+
if(!InpVerbose)
|
|
92
|
+
{
|
|
93
|
+
Comment("");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
string lines = "Beast Finance — BeastFinance v1.20\n";
|
|
97
|
+
lines += _Symbol + " · " + EnumToString((ENUM_TIMEFRAMES)Period()) + " · " + TimeToString(TimeCurrent(), TIME_DATE|TIME_SECONDS) + "\n";
|
|
98
|
+
lines += StringFormat("Equity: %.2f · Balance: %.2f · Acik pozisyon: %d\n",
|
|
99
|
+
AccountInfoDouble(ACCOUNT_EQUITY), AccountInfoDouble(ACCOUNT_BALANCE), PositionsTotal());
|
|
100
|
+
lines += "AutoTrading: " + (TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) ? "ACIK" : "KAPALI");
|
|
101
|
+
lines += " · EA izni: " + (MQLInfoInteger(MQL_TRADE_ALLOWED) ? "ACIK" : "KAPALI") + "\n";
|
|
102
|
+
if(StringLen(gNoteText) > 0)
|
|
103
|
+
{
|
|
104
|
+
lines += "------ BEAST NOTU ------\n";
|
|
105
|
+
lines += gNoteText;
|
|
106
|
+
}
|
|
107
|
+
Comment(lines);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Beast tarafından yazılan beast_note.json:
|
|
111
|
+
{"symbol":"XAUUSD","text":"...","levels":[{"price":2400,"label":"Direnc"}]}
|
|
112
|
+
symbol boş ya da bu grafiğin sembolüyse uygulanır. */
|
|
113
|
+
void ReadNote()
|
|
114
|
+
{
|
|
115
|
+
if(!FileIsExist(NoteFile)) return;
|
|
116
|
+
int h = FileOpen(NoteFile, FILE_READ|FILE_TXT|FILE_UNICODE);
|
|
117
|
+
if(h == INVALID_HANDLE) return;
|
|
118
|
+
string raw = "";
|
|
119
|
+
while(!FileIsEnding(h)) raw += FileReadString(h);
|
|
120
|
+
FileClose(h);
|
|
121
|
+
if(StringLen(raw) == 0) return;
|
|
122
|
+
|
|
123
|
+
string sym = JsonGet(raw, "symbol");
|
|
124
|
+
if(StringLen(sym) > 0 && StringCompare(sym, _Symbol) != 0) return;
|
|
125
|
+
gNoteSymbol = sym;
|
|
126
|
+
gNoteText = JsonUnescape(JsonGet(raw, "text"));
|
|
127
|
+
ApplyLevels(raw);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
string JsonGet(const string js, const string key)
|
|
131
|
+
{
|
|
132
|
+
string pat = "\"" + key + "\"";
|
|
133
|
+
int i = StringFind(js, pat);
|
|
134
|
+
if(i < 0) return "";
|
|
135
|
+
i = StringFind(js, ":", i + StringLen(pat));
|
|
136
|
+
if(i < 0) return "";
|
|
137
|
+
i++;
|
|
138
|
+
while(i < StringLen(js) && (StringGetCharacter(js, i) == ' ' || StringGetCharacter(js, i) == '\t')) i++;
|
|
139
|
+
if(i >= StringLen(js)) return "";
|
|
140
|
+
if(StringGetCharacter(js, i) == '"')
|
|
141
|
+
{
|
|
142
|
+
int j = StringFind(js, "\"", i + 1);
|
|
143
|
+
if(j < 0) return "";
|
|
144
|
+
return StringSubstr(js, i + 1, j - i - 1);
|
|
145
|
+
}
|
|
146
|
+
int e = i;
|
|
147
|
+
while(e < StringLen(js) && StringGetCharacter(js, e) != ',' && StringGetCharacter(js, e) != '}') e++;
|
|
148
|
+
string v = StringSubstr(js, i, e - i);
|
|
149
|
+
StringTrimLeft(v);
|
|
150
|
+
StringTrimRight(v);
|
|
151
|
+
return v;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
string JsonUnescape(string s)
|
|
155
|
+
{
|
|
156
|
+
StringReplace(s, "\\n", "\n");
|
|
157
|
+
StringReplace(s, "\\\"", "\"");
|
|
158
|
+
StringReplace(s, "\\\\", "\\");
|
|
159
|
+
return s;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* levels dizisindeki her {price,label} için yatay çizgi çizer; eskileri siler */
|
|
163
|
+
void ApplyLevels(const string raw)
|
|
164
|
+
{
|
|
165
|
+
int li = StringFind(raw, "\"levels\"");
|
|
166
|
+
if(li < 0) return;
|
|
167
|
+
int arr = StringFind(raw, "[", li);
|
|
168
|
+
if(arr < 0) return;
|
|
169
|
+
int end = StringFind(raw, "]", arr);
|
|
170
|
+
if(end < 0) return;
|
|
171
|
+
string body = StringSubstr(raw, arr + 1, end - arr - 1);
|
|
172
|
+
|
|
173
|
+
string names[];
|
|
174
|
+
ArrayResize(names, 64); /* FIX: dizi boyutlandirilmadan atama EA'yi dusuruyordu */
|
|
175
|
+
int n = 0;
|
|
176
|
+
int pos = 0;
|
|
177
|
+
while(pos < StringLen(body))
|
|
178
|
+
{
|
|
179
|
+
int p = StringFind(body, "\"price\"", pos);
|
|
180
|
+
if(p < 0) break;
|
|
181
|
+
int c = StringFind(body, ":", p);
|
|
182
|
+
if(c < 0) break;
|
|
183
|
+
int pe = c + 1;
|
|
184
|
+
while(pe < StringLen(body) && StringGetCharacter(body, pe) != ',' && StringGetCharacter(body, pe) != '}') pe++;
|
|
185
|
+
string priceStr = StringSubstr(body, c + 1, pe - (c + 1));
|
|
186
|
+
StringTrimLeft(priceStr);
|
|
187
|
+
StringTrimRight(priceStr);
|
|
188
|
+
double price = StringToDouble(priceStr);
|
|
189
|
+
string label = "";
|
|
190
|
+
int lq = StringFind(body, "\"label\"", pe);
|
|
191
|
+
int nq = StringFind(body, "\"price\"", pe);
|
|
192
|
+
if(lq >= 0 && (nq < 0 || lq < nq))
|
|
193
|
+
{
|
|
194
|
+
int lc = StringFind(body, ":", lq);
|
|
195
|
+
int q1 = StringFind(body, "\"", lc + 1);
|
|
196
|
+
int q2 = q1 >= 0 ? StringFind(body, "\"", q1 + 1) : -1;
|
|
197
|
+
if(q1 >= 0 && q2 > q1) label = StringSubstr(body, q1 + 1, q2 - q1 - 1);
|
|
198
|
+
}
|
|
199
|
+
if(price > 0)
|
|
200
|
+
{
|
|
201
|
+
string name = LvlPrefix + IntegerToString(n);
|
|
202
|
+
names[n] = name;
|
|
203
|
+
if(ObjectFind(0, name) < 0) ObjectCreate(0, name, OBJ_HLINE, 0, 0, price);
|
|
204
|
+
ObjectSetDouble(0, name, OBJPROP_PRICE, price);
|
|
205
|
+
ObjectSetInteger(0, name, OBJPROP_COLOR, clrDodgerBlue);
|
|
206
|
+
ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_DOT);
|
|
207
|
+
ObjectSetString(0, name, OBJPROP_TEXT, StringLen(label) > 0 ? label : "Beast");
|
|
208
|
+
n++;
|
|
209
|
+
}
|
|
210
|
+
pos = pe;
|
|
211
|
+
}
|
|
212
|
+
/* bu turda üretilmeyen eski Beast çizgilerini sil */
|
|
213
|
+
for(int i = n; i < n + 20; i++)
|
|
214
|
+
{
|
|
215
|
+
string old = LvlPrefix + IntegerToString(i);
|
|
216
|
+
if(ObjectFind(0, old) >= 0) ObjectDelete(0, old);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
void ClearLevels()
|
|
221
|
+
{
|
|
222
|
+
for(int i = 0; i < 40; i++)
|
|
223
|
+
{
|
|
224
|
+
string old = LvlPrefix + IntegerToString(i);
|
|
225
|
+
if(ObjectFind(0, old) >= 0) ObjectDelete(0, old);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* ---------- komut köprüsü ---------- */
|
|
230
|
+
|
|
231
|
+
void WriteAck(const string id, const string cmd, const bool ok, const string err, const string result)
|
|
232
|
+
{
|
|
233
|
+
int h = FileOpen(AckFile, FILE_WRITE|FILE_TXT|FILE_UNICODE);
|
|
234
|
+
if(h == INVALID_HANDLE) return;
|
|
235
|
+
string js = "{\"ok\":" + (ok ? "true" : "false") + ",\"id\":\"" + JStr(id) + "\",\"cmd\":\"" + JStr(cmd) + "\",\"at\":" + (string)(int)TimeCurrent();
|
|
236
|
+
if(!ok) js += ",\"error\":\"" + JStr(err) + "\"";
|
|
237
|
+
if(StringLen(result) > 0) js += ",\"result\":" + result;
|
|
238
|
+
js += "}";
|
|
239
|
+
FileWriteString(h, js);
|
|
240
|
+
FileClose(h);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
void ProcessCommands()
|
|
244
|
+
{
|
|
245
|
+
if(!FileIsExist(CmdFile)) return;
|
|
246
|
+
int h = FileOpen(CmdFile, FILE_READ|FILE_TXT|FILE_UNICODE);
|
|
247
|
+
if(h == INVALID_HANDLE) return;
|
|
248
|
+
string raw = "";
|
|
249
|
+
while(!FileIsEnding(h)) raw += FileReadString(h);
|
|
250
|
+
FileClose(h);
|
|
251
|
+
if(StringLen(raw) == 0) return;
|
|
252
|
+
|
|
253
|
+
string id = JsonGet(raw, "id");
|
|
254
|
+
string cmd = JsonGet(raw, "cmd");
|
|
255
|
+
bool ok = true;
|
|
256
|
+
string err = "";
|
|
257
|
+
string result = "";
|
|
258
|
+
if(cmd == "ping")
|
|
259
|
+
{
|
|
260
|
+
result = "{\"pong\":true}";
|
|
261
|
+
}
|
|
262
|
+
else if(cmd == "chart")
|
|
263
|
+
{
|
|
264
|
+
result = StringFormat("{\"symbol\":\"%s\",\"period\":%d,\"bid\":%.5f,\"ask\":%.5f,\"spread\":%d}",
|
|
265
|
+
_Symbol, (int)Period(),
|
|
266
|
+
SymbolInfoDouble(_Symbol, SYMBOL_BID), SymbolInfoDouble(_Symbol, SYMBOL_ASK),
|
|
267
|
+
(int)SymbolInfoInteger(_Symbol, SYMBOL_SPREAD));
|
|
268
|
+
}
|
|
269
|
+
else if(cmd == "status")
|
|
270
|
+
{
|
|
271
|
+
result = StringFormat("{\"equity\":%.2f,\"balance\":%.2f,\"positions\":%d,\"terminal_trade_allowed\":%s,\"mql_trade_allowed\":%s}",
|
|
272
|
+
AccountInfoDouble(ACCOUNT_EQUITY), AccountInfoDouble(ACCOUNT_BALANCE), PositionsTotal(),
|
|
273
|
+
(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) ? "true" : "false"),
|
|
274
|
+
(MQLInfoInteger(MQL_TRADE_ALLOWED) ? "true" : "false"));
|
|
275
|
+
}
|
|
276
|
+
else if(cmd == "note")
|
|
277
|
+
{
|
|
278
|
+
/* gövde zaten beast_note.json'dan okunur; sadece yenileme tetikle */
|
|
279
|
+
ReadNote();
|
|
280
|
+
RefreshPanel();
|
|
281
|
+
result = "{\"note\":true}";
|
|
282
|
+
}
|
|
283
|
+
else if(cmd == "shot")
|
|
284
|
+
{
|
|
285
|
+
/* ChartScreenShot -> MQL5\Files\<file> (png/gif/bmp). params:
|
|
286
|
+
file, width, height, timeframe (M15/H1/...), symbol (bos=aktif grafik)
|
|
287
|
+
Aktif grafik zaten istenen sembol+periyot ise ondan cekilir
|
|
288
|
+
(Beast panosu + seviye cizgileri gorunur); degilse gecici grafik acilir. */
|
|
289
|
+
string file = JsonGet(raw, "file");
|
|
290
|
+
if(StringLen(file) == 0) file = "beast_shot.png";
|
|
291
|
+
int w = (int)StringToInteger(JsonGet(raw, "width"));
|
|
292
|
+
int hh = (int)StringToInteger(JsonGet(raw, "height"));
|
|
293
|
+
if(w <= 0) w = 1600;
|
|
294
|
+
if(hh <= 0) hh = 900;
|
|
295
|
+
|
|
296
|
+
string symTxt = JsonGet(raw, "symbol");
|
|
297
|
+
string tfTxt = JsonGet(raw, "timeframe");
|
|
298
|
+
|
|
299
|
+
long cid = ChartID();
|
|
300
|
+
string symNow = ChartSymbol(cid);
|
|
301
|
+
ENUM_TIMEFRAMES tfNow = (ENUM_TIMEFRAMES)ChartPeriod(cid);
|
|
302
|
+
|
|
303
|
+
string symWant = symNow;
|
|
304
|
+
if(StringLen(symTxt) > 0 && StringCompare(symTxt, symNow) != 0)
|
|
305
|
+
{
|
|
306
|
+
if(SymbolSelect(symTxt, true)) symWant = symTxt;
|
|
307
|
+
}
|
|
308
|
+
if(SymbolSelect(symWant, true) == false)
|
|
309
|
+
{
|
|
310
|
+
ok = false;
|
|
311
|
+
err = "sembol bulunamadi: " + symWant;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
ENUM_TIMEFRAMES tfWant = TfFromText(tfTxt);
|
|
315
|
+
ENUM_TIMEFRAMES tfUse = (tfWant == PERIOD_CURRENT) ? tfNow : tfWant;
|
|
316
|
+
bool tempChart = false;
|
|
317
|
+
bool tplApplied = false;
|
|
318
|
+
bool themeOk = false;
|
|
319
|
+
int bgNow = -1;
|
|
320
|
+
|
|
321
|
+
if(ok && (symWant != symNow || tfUse != tfNow))
|
|
322
|
+
{
|
|
323
|
+
long newId = ChartOpen(symWant, tfUse);
|
|
324
|
+
if(newId == 0)
|
|
325
|
+
{
|
|
326
|
+
ok = false;
|
|
327
|
+
err = "gecici grafik acilamadi: " + symWant;
|
|
328
|
+
}
|
|
329
|
+
else
|
|
330
|
+
{
|
|
331
|
+
cid = newId;
|
|
332
|
+
tempChart = true;
|
|
333
|
+
/* temiz gorunum: BeastFinance.tpl temasi (EA blogu cikarilmis BeastShot.tpl) */
|
|
334
|
+
string tpl = JsonGet(raw, "template");
|
|
335
|
+
if(StringLen(tpl) == 0) tpl = "BeastShot";
|
|
336
|
+
if(StringFind(tpl, ".") < 0) tpl = tpl + ".tpl";
|
|
337
|
+
bool tplOk = false;
|
|
338
|
+
if(StringCompare(tpl, "none.tpl") != 0)
|
|
339
|
+
{
|
|
340
|
+
tplOk = ChartApplyTemplate(cid, tpl);
|
|
341
|
+
ChartRedraw(cid);
|
|
342
|
+
Sleep(700);
|
|
343
|
+
}
|
|
344
|
+
/* sablon sembol/periyot degistirdiyse geri al */
|
|
345
|
+
if(StringCompare(ChartSymbol(cid), symWant) != 0 || (ENUM_TIMEFRAMES)ChartPeriod(cid) != tfUse)
|
|
346
|
+
ChartSetSymbolPeriod(cid, symWant, tfUse);
|
|
347
|
+
/* sablon bulunamasa da gorunum ayni olsun -> acik tema renklerini zorla */
|
|
348
|
+
themeOk = ApplyLightTheme(cid);
|
|
349
|
+
bgNow = (int)ChartGetInteger(cid, CHART_COLOR_BACKGROUND);
|
|
350
|
+
tplApplied = tplOk;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if(ok)
|
|
355
|
+
{
|
|
356
|
+
ChartRedraw(cid);
|
|
357
|
+
Sleep(1200); /* mumlar/olcek otursun */
|
|
358
|
+
ChartRedraw(cid);
|
|
359
|
+
Sleep(200);
|
|
360
|
+
if(!ChartScreenShot(cid, file, w, hh, ALIGN_RIGHT))
|
|
361
|
+
{
|
|
362
|
+
ok = false;
|
|
363
|
+
err = "screenshot basarisiz, hata=" + IntegerToString(GetLastError());
|
|
364
|
+
}
|
|
365
|
+
else
|
|
366
|
+
{
|
|
367
|
+
result = StringFormat("{\"file\":\"%s\",\"width\":%d,\"height\":%d,\"symbol\":\"%s\",\"period\":%d,\"temp_chart\":%s,\"template_applied\":%s,\"theme_ok\":%s,\"bg\":%d}",
|
|
368
|
+
JStr(file), w, hh, symWant, (int)tfUse, (tempChart ? "true" : "false"), (tplApplied ? "true" : "false"), (themeOk ? "true" : "false"), bgNow);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if(tempChart) ChartClose(cid);
|
|
372
|
+
}
|
|
373
|
+
else
|
|
374
|
+
{
|
|
375
|
+
ok = false;
|
|
376
|
+
err = "bilinmeyen komut: " + cmd;
|
|
377
|
+
}
|
|
378
|
+
WriteAck(id, cmd, ok, err, result);
|
|
379
|
+
FileDelete(CmdFile);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/* BeastFinance.tpl acik tema renklerini grafige uygular (sablon bulunamazsa da garanti) */
|
|
383
|
+
bool ApplyLightTheme(const long cid)
|
|
384
|
+
{
|
|
385
|
+
bool okAll = true;
|
|
386
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_BACKGROUND, (long)16449525) && okAll;
|
|
387
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_FOREGROUND, (long)0) && okAll;
|
|
388
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_GRID, (long)12632256) && okAll;
|
|
389
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_CHART_UP, (long)13434880) && okAll;
|
|
390
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_CHART_DOWN, (long)0) && okAll;
|
|
391
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_CHART_LINE, (long)0) && okAll;
|
|
392
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_CANDLE_BULL, (long)13434880) && okAll;
|
|
393
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_CANDLE_BEAR, (long)0) && okAll;
|
|
394
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_VOLUME, (long)32768) && okAll;
|
|
395
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_BID, (long)12632256) && okAll;
|
|
396
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_ASK, (long)12632256) && okAll;
|
|
397
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_LAST, (long)12632256) && okAll;
|
|
398
|
+
okAll = ChartSetInteger(cid, CHART_COLOR_STOP_LEVEL, (long)17919) && okAll;
|
|
399
|
+
okAll = ChartSetInteger(cid, CHART_MODE, CHART_CANDLES) && okAll;
|
|
400
|
+
okAll = ChartSetInteger(cid, CHART_SHOW_GRID, false) && okAll;
|
|
401
|
+
okAll = ChartSetInteger(cid, CHART_SHOW_OHLC, true) && okAll;
|
|
402
|
+
okAll = ChartSetInteger(cid, CHART_SHOW_BID_LINE, false) && okAll;
|
|
403
|
+
okAll = ChartSetInteger(cid, CHART_SHOW_ASK_LINE, false) && okAll;
|
|
404
|
+
okAll = ChartSetInteger(cid, CHART_SHOW_LAST_LINE, true) && okAll;
|
|
405
|
+
ChartRedraw(cid);
|
|
406
|
+
return okAll;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/* "M15"/"H1"/"15"/"60" gibi metni ENUM_TIMEFRAMES'e cevirir */
|
|
410
|
+
ENUM_TIMEFRAMES TfFromText(const string t)
|
|
411
|
+
{
|
|
412
|
+
string s = t;
|
|
413
|
+
StringTrimLeft(s);
|
|
414
|
+
StringTrimRight(s);
|
|
415
|
+
StringToUpper(s);
|
|
416
|
+
if(s == "M1" || s == "1") return PERIOD_M1;
|
|
417
|
+
if(s == "M5" || s == "5") return PERIOD_M5;
|
|
418
|
+
if(s == "M15" || s == "15") return PERIOD_M15;
|
|
419
|
+
if(s == "M30" || s == "30") return PERIOD_M30;
|
|
420
|
+
if(s == "H1" || s == "60") return PERIOD_H1;
|
|
421
|
+
if(s == "H4" || s == "240") return PERIOD_H4;
|
|
422
|
+
if(s == "D1" || s == "1440") return PERIOD_D1;
|
|
423
|
+
if(s == "W1") return PERIOD_W1;
|
|
424
|
+
if(s == "MN1") return PERIOD_MN1;
|
|
425
|
+
return PERIOD_CURRENT;
|
|
426
|
+
}
|
|
427
|
+
//+------------------------------------------------------------------+
|
|
Binary file
|