Professional Documents
Culture Documents
Smith ProEA v2.1
Smith ProEA v2.1
Smith ProEA v2.1
//| Smith_ProEA.mq4 |
//| AKITA_TAKOYAKI |
//| www.fiverr.com/akita_takoyaki |
//+------------------------------------------------------------------+
#property copyright "AKITA_TAKOYAKI"
#property link "www.fiverr.com/akita_takoyaki"
#property version "1.00"
#property strict
//----------------
double close;
double minsltp;
double TP,SL;
double point;
int digits,Q;
int ThisBarTrade=0;
bool NewBar;
//WRITE EXPIRY DATE BELOW(DD.MM.YYYY)
datetime expirydate=D'11.09.2019';
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
if(Digits==5 || Digits==3)Q=10;
else Q=1;
if(Digits<4)
{
point=0.01;
digits=2;
}
else
{
point=0.0001;
digits=4;
}
minsltp=(MarketInfo(Symbol(),MODE_SPREAD)+MarketInfo(Symbol(),MODE_STOPLEVEL)
+1)/Q;
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
if(TimeCurrent()>expirydate){
Alert("Expired. Please contact owner at https://telegram.me/ea_riskaverse");
ExpertRemove();
return;
}
{
PrintInfoToChart();
}
if (iBars(Symbol(),0) != ThisBarTrade ) {
NewBar=true;
ThisBarTrade = iBars(Symbol(),0);
NewBar=true;
}
{
if(TrailingStop>0)MoveTrailingStop();
}
double buysignal=iCustom(NULL,0,"SixtySecondTrades_Alerts2",0,1);
double selsignal=iCustom(NULL,0,"SixtySecondTrades_Alerts2",1,1);
double
Stoch=iStochastic(NULL,0,Kperiod,Dperiod,Slowing,MODE_SMA,0,MODE_MAIN,1);
double
Stoch2=iStochastic(NULL,0,Kperiod,Dperiod,Slowing,MODE_SMA,0,MODE_MAIN,2);
}
//+------------------------------------------------------------------+
//-------------------------------------------------------------------+
void CloseOrders(int tip) {
int cnt=OrdersTotal();
for(int i=cnt-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
if(OrderSymbol()==Symbol()&&
OrderMagicNumber()==MagicNumber&&OrderType()==tip)
{
close=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),50,clrGreen);
}
}
}
//------------------------------------------
//------------------------------------------
void PrintInfoToChart()
{
string temp="Programmed by AKITA_TAKOYAKI\nCopyright ©2018\n"
+ "------------------------------------------------\n"
+ "ACCOUNT INFORMATION:\n"
+ "------------------------------------------------\n"
+ "Company: " + AccountCompany()+ "\n"
+ "Account Currency: " + AccountCurrency()+ "\n"
+ "Free Margin: " + DoubleToStr(AccountFreeMargin(), 2)+ "\n"
+ "Used Margin: " + DoubleToStr(AccountMargin(), 2)+ "\n"
+ "Equity: " + DoubleToStr(AccountEquity(), 2)+ "\n"
+ "Balance: " + DoubleToStr(AccountBalance(), 2)+ "\n"
+ "Leverage: " + DoubleToStr(AccountLeverage(), 2)+ "\n"
+"------------------------------------------------\n";
Comment(temp);
}
//-------------------------------------------------------------+
void MoveTrailingStop()
{
bool s,mod;
for(int cnt=0;cnt<OrdersTotal();cnt++)
{
s=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
string sy=OrderSymbol();
int tk=OrderTicket(),
ot=OrderType(),
mn=OrderMagicNumber();
double op=OrderOpenPrice(),
sl=OrderStopLoss(),
tp=OrderTakeProfit();
if(sy==Symbol()&&mn==MagicNumber&&ot<=OP_SELL)
{
if(ot==OP_BUY)
{
if(TrailingStop>0&&NormalizeDouble(Ask-
(TrailingStep*point),Digits)>NormalizeDouble((op+(TrailingStop*point)),Digits))
{
if((NormalizeDouble(sl,Digits)<NormalizeDouble(Bid-
(TrailingStop*point),Digits))||(sl==0))
{
mod=OrderModify(tk,op,NormalizeDouble(Bid-
(TrailingStop*point),Digits),tp,0,Blue);
}
}
}
else
{
if(TrailingStop>0&&NormalizeDouble(Bid+
(TrailingStep*point),Digits)<NormalizeDouble((op-(TrailingStop*point)),Digits))
{
if((NormalizeDouble(sl,Digits)>(NormalizeDouble(Ask+
(TrailingStop*point),Digits)))||(sl==0))
{
mod=OrderModify(tk,op,NormalizeDouble(Ask+
(TrailingStop*point),Digits),tp,0,Red);
}
}
}
}
}
}
//------------------------------------------