Adwizard/Experts/Stage3.mqh
159 行
14 KiB
MQL5
Yuriy Bykov
2025-04-11 13:28:40 +03:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| Stage3.mqh |
//| Copyright 2024-2025, Yuriy Bykov |
//| https://www.mql5.com/ru/users/antekov |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024-2025, Yuriy Bykov"
#property link "https://www.mql5.com/ru/articles/17328"
#property description "!>25B=8:, A>E@0=ONI89 AD>@<8@>20==CN =>@<8@>20==CN 3@C??C AB@0B5389 "
#property description "2 181;8>B5:C 3@C?? A 7040==K< 8<5=5<."
#property version "1.05"
#ifndef __NAME__
#define __NAME__ "EmptyStrategy"
#endif
#include "../Virtual/VirtualAdvisor.mqh"
//+------------------------------------------------------------------+
//| E>4=K5 ?0@0<5B@K |
//+------------------------------------------------------------------+
sinput int idTask_ = 38; // - 45=B8D8:0B>@ 7040G8 >?B8<870F88
sinput string fileName_ = "article.16373.db.sqlite"; // - $09; A >A=>2=>9 107>9 40==KE
input group "::: B1>@ 2 3@C??C"
input string passes_ = ""; // - 45=B8D8:0B>@K ?@>E>4>2 G5@57 70?OBCN
input group "::: !>E@0=5=85 2 181;8>B5:C"
input string groupName_ = "SimpleVolumes_v.1.20_2023.01.01"; // - 0720=85 25@A88 (5A;8 ?CAB>5 - =5 A>E@0=OBL)
input string advFileName_ = "SimpleVolumes-27183.test.db.sqlite"; // - 0720=85 107K 40==KE M:A?5@B0
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double expectedDrawdown_ = 10; // - 0:A8<0;L=K9 @8A: (%)
double fixedBalance_ = 10000; // - A?>;L7C5<K9 45?>78B (0 - 8A?>;L7>20BL 25AL) 2 20;NB5 AG5B0
double scale_ = 1.00; // - 0AHB018@CNI89 <=>68B5;L 4;O 3@C??K
ulong magic_ = 27183; // - Magic
CVirtualAdvisor *expert; // 1J5:B M:A?5@B0
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit() {
// #AB0=02;8205< ?0@0<5B@K 2 :;0AA5 C?@02;5=8O :0?8B0;><
CMoney::DepoPart(expectedDrawdown_ / 10.0);
CMoney::FixedBalance(fixedBalance_);
CVirtualAdvisor::TesterInit(idTask_, fileName_);
// !B@>:0 8=8F80;870F88 A =01>@0<8 ?0@0<5B@>2 AB@0B5389
string strategiesParams = NULL;
// A;8 A>548=5=85 A >A=>2=>9 107>9 40==KE CAB0=>2;5=>, B>
if(DB::Connect(fileName_)) {
// $>@<8@C5< 70?@>A =0 ?>;CG5=85 ?@>E>4>2 A C:070==K<8 845B8D8:0B>@0<8
string query = (passes_ == "" ?
StringFormat("SELECT DISTINCT FIRST_VALUE(p.params) OVER (PARTITION BY p.id_task ORDER BY custom_ontester DESC) AS params "
" FROM passes p "
" WHERE p.id_task IN ("
" SELECT pt.id_task "
" FROM tasks t "
" JOIN "
" jobs j ON j.id_job = t.id_job "
" JOIN "
" stages s ON s.id_stage = j.id_stage "
" JOIN "
" jobs pj ON pj.id_stage = s.id_parent_stage "
" JOIN "
" tasks pt ON pt.id_job = pj.id_job "
" WHERE t.id_task = %d "
" ) ", idTask_)
: StringFormat("SELECT params"
" FROM passes "
" WHERE id_pass IN (%s);", passes_)
);
Print(query);
int request = DatabasePrepare(DB::Id(), query);