Suivre
1
0
Forker
Vous avez déjà forké Adwizard
0
forké depuis antekov/Adwizard
Adwizard/Experts/Expert.mqh
216 lignes
20 Kio
MQL5
BrutLien permanentVue normaleHistorique
Yuriy Bykov
2025-04-11 13:28:40 +03:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| Expert.mq5 |
//| Copyright 2024, Yuriy Bykov |
//| https://www.mql5.com/ru/users/antekov |
Yuriy Bykov
2025-04-11 13:28:40 +03:00
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, Yuriy Bykov"
Yuriy Bykov
2025-04-11 13:28:40 +03:00
#property link "https://www.mql5.com/ru/articles/17608"
#property version "1.24"
#include "../Virtual/VirtualAdvisor.mqh"
#include "../Utils/ExpertHistory.mqh"
#include "../Utils/ConsoleDialog.mqh"
// A;8 =5 7040=0 :>=AB0=B0 A 8<5=5< 8B>3>2>3> A>25B=8:0, B>
#ifndef __NAME__
// 040Q< 5Q @02=>9 =0720=8N D09;0 A>25B=8:0
#define __NAME__ MQLInfoString(MQL_PROGRAM_NAME)
//+------------------------------------------------------------------+
//| $C=:F8O D>@<8@>20=8O AB@>:8 8=8F80;870F88 AB@0B5388 |
//| 87 2E>4=KE ?0@0<5B@>2 ?> C<>;G0=8N (5A;8 =5 1K;> 7040=> 8<O). |
//| <?>@B8@C5B AB@>:C 8=8F80;870F88 87 107K 40==KE A>25B=8:0 |
//| ?> 845=B8D8:0B>@C 3@C??K AB@0B5389 |
//+------------------------------------------------------------------+
string GetStrategyParams() {
// 5@Q< AB@>:C 8=8F80;870F88 87 =>2>9 181;8>B5:8 4;O 2K1@0==>9 3@C??K
// (87 107K 40==KE M:A?5@B0)
Yuriy Bykov
2025-06-14 14:28:04 +03:00
Yuriy Bykov
2025-07-06 21:05:25 +03:00
string strategiesParams = CVirtualAdvisor::Import(
Yuriy Bykov
2025-06-20 22:14:57 +03:00
CVirtualAdvisor::FileName(__NAME__, magic_),
Yuriy Bykov
2025-07-06 21:05:25 +03:00
groupId_
Yuriy Bykov
2025-06-20 22:14:57 +03:00
);
Yuriy Bykov
2025-07-06 21:05:25 +03:00
Yuriy Bykov
2025-06-14 14:28:04 +03:00
Yuriy Bykov
2025-04-11 13:28:40 +03:00
// A;8 3@C??0 AB@0B5389 87 181;8>B5:8 =5 7040=0, B> ?@5@K205< @01>BC
if(strategiesParams == NULL && useAutoUpdate_) {
strategiesParams = "";
}
return strategiesParams;
}
Yuriy Bykov
2025-06-14 14:28:04 +03:00
Yuriy Bykov
2025-04-11 13:28:40 +03:00
#endif
//+------------------------------------------------------------------+
//| E>4=K5 ?0@0<5B@K |
//+------------------------------------------------------------------+
input group "::: A?>;L7>20BL 3@C??C AB@0B5389"
sinput int groupId_ = 0; // - ID 3@C??K 87 =>2>9 181;8>B5:8 (0 - ?>A;54=OO)
sinput bool useAutoUpdate_ = true; // - A?>;L7>20BL 02B>>1=>2;5=85?
Yuriy Bykov
2025-04-11 13:28:40 +03:00
input group "::: #?@02;5=85 :0?8B0;><"
sinput double expectedDrawdown_ = 10; // - 0:A8<0;L=K9 @8A: (%)
sinput double fixedBalance_ = 10000; // - A?>;L7C5<K9 45?>78B (0 - 8A?>;L7>20BL 25AL) 2 20;NB5 AG5B0
input double scale_ = 1.00; // - 0AHB018@CNI89 <=>68B5;L 4;O 3@C??K
input group "::: 5=5465@ 70:@KB8O"
input bool cmIsActive_ = true; // - :B825=?
input double cmStartBaseBalance_ = 0; // - 07>2K9 10;0=A
input ENUM_CM_CALC_LOSS
cmCalcLossLimit_ = CM_CALC_LOSS_MONEY_BB; // - !?>A>1 @0AGQB0 C1KB:0
input double cmLossLimit_ = 100; // - =0G5=85 C1KB:0 4;O D8:A0F88
input ENUM_CM_CALC_PROFIT
cmCalcProfitLimit_ = CM_CALC_PROFIT_MONEY_BB; // - !?>A>1 @0AGQB0 >1I59 ?@81K;8
input double cmProfitLimit_ = 1000000; // - =0G5=85 >1I59 ?@81K;8 4;O D8:A0F88
Yuriy Bykov
2025-06-20 22:14:57 +03:00
Yuriy Bykov
2025-04-11 13:28:40 +03:00
input group "::: 8A:-<5=5465@"
input bool rmIsActive_ = true; // - :B825=?
Yuriy Bykov
2025-06-20 22:14:57 +03:00
input double rmStartBaseBalance_ = 10000; // - 07>2K9 10;0=A
Yuriy Bykov
2025-04-11 13:28:40 +03:00
input ENUM_RM_CALC_DAILY_LOSS
rmCalcDailyLossLimit_ = RM_CALC_DAILY_LOSS_MONEY_BB; // - !?>A>1 @0AGQB0 4=52=>3> C1KB:0
Yuriy Bykov
2025-06-20 22:14:57 +03:00
input double rmMaxDailyLossLimit_ = 500; // - =0G5=85 4=52=>3> C1KB:0
Yuriy Bykov
2025-06-14 14:28:04 +03:00
Yuriy Bykov
2025-06-20 22:14:57 +03:00
input double rmCloseDailyPart_ = 1.0; // - =0G5=85 ?>@>3>2>9 G0AB8 4=52=>3> C1KB:0
input ENUM_RM_CALC_OVERALL_LOSS
Yuriy Bykov
2025-04-11 13:28:40 +03:00
rmCalcOverallLossLimit_ = RM_CALC_OVERALL_LOSS_MONEY_BB; // - !?>A>1 @0AGQB0 >1I53> C1KB:0
input double rmMaxOverallLossLimit_ = 1000; // - =0G5=85 >1I53> C1KB:0
input double rmCloseOverallPart_ = 1.0; // - =0G5=85 ?>@>3>2>9 G0AB8 >1I53> C1KB:0
input ENUM_RM_CALC_OVERALL_PROFIT
rmCalcOverallProfitLimit_ = RM_CALC_OVERALL_PROFIT_MONEY_BB; // - !?>A>1 @0AGQB0 >1I59 ?@81K;8
input double rmMaxOverallProfitLimit_ = 1000000; // - =0G5=85 >1I59 ?@81K;8
input int rmMaxOverallProfitDate_ = 0; // - @545;L=>5 2@5<O >6840=8O >1I59 ?@81K;8 (4=59)
input double rmMaxRestoreTime_ = 0; // - @5<O >6840=8O ;CGH53> 2E>40 =0 ?@>A04:5
input double rmLastVirtualProfitFactor_ = 1; // - =>68B5;L =0G0;L=>9 ;CGH59 ?@>A04:8
input group "::: @>G85 ?0@0<5B@K"
input ulong magic_ = 27183; // - Magic
Yuriy Bykov
2025-04-11 13:28:40 +03:00
input bool useOnlyNewBars_ = true; // - 01>B0BL B>;L:> =0 >B:@KB88 10@0
input bool usePrevState_ = true; // - 03@C60BL ?@54K4CI55 A>AB>O=85
input string symbolsReplace_ = ""; // - @028;0 70<5=K A8<2>;>2
CVirtualAdvisor *expert; // 1J5:B M:A?5@B0
CConsoleDialog *dialog; // 80;>3 4;O 2K2>40 B5:AB0 A @57C;LB0B0<8
//+------------------------------------------------------------------+
//| 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);
Yuriy Bykov
2025-04-11 13:28:40 +03:00
CMoney::FixedBalance(fixedBalance_);
// !B@>:0 8=8F80;870F88 A =01>@0<8 ?0@0<5B@>2 AB@0B5389
string strategiesParams = NULL;
// 5@Q< AB@>:C 8=8F80;870F88 87 =>2>9 181;8>B5:8 4;O 2K1@0==>9 3@C??K
// (87 107K 40==KE M:A?5@B0)
strategiesParams = GetStrategyParams();