Vigiar
1
0
Derivar
Você já tinha feito uma derivação do repositório okWarrior_EA, anteriormente
0
okWarrior_EA/references/MQL5/Experts/DIAYN/Test.mq5

281 linhas
21 KiB
MQL5

<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| Research.mq5 |
//| Copyright DNG<EFBFBD> |
//| https://www.mql5.com/en/users/dng |
//+------------------------------------------------------------------+
#property copyright "Copyright DNG<00>"
#property link "https://www.mql5.com/en/users/dng"
#property version "1.00"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "Trajectory.mqh"
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Indicators\Oscilators.mqh>
//+------------------------------------------------------------------+
//| Input parameters |
//+------------------------------------------------------------------+
input ENUM_TIMEFRAMES TimeFrame = PERIOD_H1;
//---
input group "---- RSI ----"
input int RSIPeriod = 14; //Period
input ENUM_APPLIED_PRICE RSIPrice = PRICE_CLOSE; //Applied price
//---
input group "---- CCI ----"
input int CCIPeriod = 14; //Period
input ENUM_APPLIED_PRICE CCIPrice = PRICE_TYPICAL; //Applied price
//---
input group "---- ATR ----"
input int ATRPeriod = 14; //Period
//---
input group "---- MACD ----"
input int FastPeriod = 12; //Fast
input int SlowPeriod = 26; //Slow
input int SignalPeriod = 9; //Signal
input ENUM_APPLIED_PRICE MACDPrice = PRICE_CLOSE; //Applied price
input int Agent = 1;
bool TrainMode = true;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
SState sState;
STrajectory Base;
STrajectory Buffer[];
STrajectory Frame[1];
CFQF Actor;
CFQF Scheduler;
//---
float dError;
datetime dtStudied;
bool bEventStudy;
//---
CBufferFloat State1;
CBufferFloat *Result;
//---
CSymbolInfo Symb;
CTrade Trade;
//---
MqlRates Rates[];
CiRSI RSI;
CiCCI CCI;
CiATR ATR;
CiMACD MACD;
vector<float> prev_scheduler;
vector<float> prev_actor;
vector<float> skills_count;
float prev_balance;
float prev_equity;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
if(!Symb.Name(_Symbol))
return INIT_FAILED;
Symb.Refresh();
//---
if(!RSI.Create(Symb.Name(), TimeFrame, RSIPeriod, RSIPrice))
return INIT_FAILED;
//---
if(!CCI.Create(Symb.Name(), TimeFrame, CCIPeriod, CCIPrice))
return INIT_FAILED;
//---
if(!ATR.Create(Symb.Name(), TimeFrame, ATRPeriod))
return INIT_FAILED;
//---
if(!MACD.Create(Symb.Name(), TimeFrame, FastPeriod, SlowPeriod, SignalPeriod, MACDPrice))
return INIT_FAILED;
if(!RSI.BufferResize(HistoryBars) || !CCI.BufferResize(HistoryBars) ||
!ATR.BufferResize(HistoryBars) || !MACD.BufferResize(HistoryBars))
{
PrintFormat("%s -> %d", __FUNCTION__, __LINE__);
return INIT_FAILED;
}
//---
if(!Trade.SetTypeFillingBySymbol(Symb.Name()))
return INIT_FAILED;
//--- load models
ResetLastError();
if(!Actor.Load(FileName + "Act.nnw", dtStudied, true))
{
PrintFormat("Error of load Actor: %5d", GetLastError());
return INIT_FAILED;
}
if(!Scheduler.Load(FileName + "Sch.nnw", dtStudied, true))
{
PrintFormat("Error of load Scheduler: %5d", GetLastError());
return INIT_FAILED;
}
Scheduler.getResults(Result);
if(Result.Total() != NSkills)
{
PrintFormat("The scope of the scheduler does not match the skills count (%d <> %d)", NSkills, Result.Total());
return INIT_FAILED;
}
Actor.getResults(Result);
if(Result.Total() != NActions)
{
PrintFormat("The scope of the actor does not match the actions count (%d <> %d)", NActions, Result.Total());
return INIT_FAILED;
}
//---
prev_scheduler.Init(NSkills);
prev_actor.Init(NActions);
skills_count=vector<float>::Zeros(NSkills);
prev_balance = (float)AccountInfoDouble(ACCOUNT_BALANCE);
prev_equity = (float)AccountInfoDouble(ACCOUNT_EQUITY);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
delete Result;
Print(skills_count);
}
//+------------------------------------------------------------------+