61 lines
2.1 KiB
MQL5
61 lines
2.1 KiB
MQL5
|
//+------------------------------------------------------------------+
|
||
|
//| ProjectName |
|
||
|
//| Copyright 2020, CompanyName |
|
||
|
//| http://www.companyname.net |
|
||
|
//+------------------------------------------------------------------+
|
||
|
|
||
|
#property version "0.5.0"
|
||
|
|
||
|
input group "Evaluator"
|
||
|
input int TakeProfit = 150;; /*TakeProfit Per Open Positions (Static)*/
|
||
|
input int StopLoss = 400;; /* StopLoss per Open Position (Static) */
|
||
|
input int VolumeMult = 1;; /* Volum is the default 0.1 used from the 'place_a_long' or 'place_a_short' as defined in the MTLibrary*/
|
||
|
//input int Timer = 1800;; /* Seconds to the next Analysis */
|
||
|
//input double RiskPerTrade=0.02;; /* Amount of risk against the balance trader will undertake per trade */
|
||
|
|
||
|
|
||
|
#include "JMLibrary\JMUtils.mqh"
|
||
|
Evaluator eval;
|
||
|
double init_equity;
|
||
|
//+------------------------------------------------------------------+
|
||
|
//| |
|
||
|
//+------------------------------------------------------------------+
|
||
|
void OnInit()
|
||
|
{
|
||
|
eval.Init();
|
||
|
init_equity = AccountInfoDouble(ACCOUNT_EQUITY);
|
||
|
}
|
||
|
//+------------------------------------------------------------------+
|
||
|
//| Expert tick function |
|
||
|
//+------------------------------------------------------------------+
|
||
|
void OnTick()
|
||
|
{
|
||
|
eval.loadIndicators();
|
||
|
|
||
|
if(eval.shouldPlaceLong())
|
||
|
{
|
||
|
place_a_long(ASK, TakeProfit, VolumeMult, StopLoss);
|
||
|
//PlaceLongPosition(TakeProfit, StopLoss, RiskPerTrade);
|
||
|
}
|
||
|
|
||
|
if(eval.shouldPlaceShort())
|
||
|
{
|
||
|
place_a_short(BID, TakeProfit, VolumeMult, StopLoss);
|
||
|
//PlaceShortPosition(TakeProfit, StopLoss, RiskPerTrade);
|
||
|
|
||
|
}
|
||
|
|
||
|
eval.FollowTheSMA();
|
||
|
eval.flushSignal();
|
||
|
|
||
|
double current_equity = AccountInfoDouble(ACCOUNT_EQUITY);
|
||
|
if(current_equity >= init_equity + 1000)
|
||
|
{
|
||
|
close_all_positions();
|
||
|
init_equity = current_equity;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
//+------------------------------------------------------------------+
|