Files
All-MQL5-code/Include/Strategy/StrategyFactory.mqh
T
Pierre8rTeam d2a192666b Commit
2018-06-23 11:25:42 +02:00

33 lines
3.0 KiB
Plaintext

//+------------------------------------------------------------------+
//| StrategyFactory.mqh |
//| Copyright 2015, Vasiliy Sokolov. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Vasiliy Sokolov."
#property link "http://www.mql5.com"
/*
GetStrategy is a factory of strategies. It creates a strategy object corresponding to a certain name.
The method is included in a separate file for automation purposes.
*/
#include <Strategy\Strategy.mqh>
#include <Strategy\Samples\MovingAverage.mqh>
#include <Strategy\Samples\ChannelSample.mqh>
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
CStrategy *CStrategy::GetStrategy(string name)
{
if(name=="MovingAverage")
return new CMovingAverage();
if(name=="BollingerBands")
return new CChannel();
CLog *mlog=CLog::GetLog();
string text="Strategy with name "+name+" not defined in GetStrategy method. Please define strategy in 'StrategyFactory.mqh'";
CMessage *msg=new CMessage(MESSAGE_ERROR,__FUNCTION__,text);
mlog.AddMessage(msg);
return NULL;
}
//+------------------------------------------------------------------+