Smith ProEA v2.1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

//+------------------------------------------------------------------+

//| 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

extern int StopLoss=20; // Stop Loss


extern int TakeProfite = 20; // Take profit
extern double LotSize=0.1; // Lot size
extern int MagicNumber=22082018; // Magic Number

//--- Stochastich Parameters


extern string Var2= "___________Stochastic Parameters ";

extern int Kperiod=5; // K%


extern int Dperiod=3; // D%
extern int Slowing=3; // Slowing
extern int Os=80; // Stoch Oversold
extern int Ob=20; // Stoch Overbought
//-----------------

extern bool Email=true;//Email Notification ?


extern bool PopUp=true;//MT4 Alert ?
extern bool Mobile=true;//Push Notification ?

input double TrailingStop=15,


TrailingStep=0;

//----------------

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);

if( selsignal !=EMPTY_VALUE && Stoch2 < Os &&Stoch>=Os && NewBar ){


if(TakeProfite!=0){TP=Bid-TakeProfite*point;}else TP=0;
if(StopLoss!=0){SL=Bid+StopLoss*point;}else SL=0;
double sell=
OrderSend(NULL,OP_SELL,LotSize,Bid,5*Q,SL,TP,NULL,MagicNumber,0,clrRed);
if(Email)SendMail(Symbol(),"New Sell Order @ "+(string)Ask);
if(PopUp)Alert(Symbol()+" New Sell Order @ "+(string)Ask);
if(Mobile)SendNotification(Symbol()+" New Sell Order @ "+(string)Ask);
NewBar=false;
}

if( buysignal !=EMPTY_VALUE && Stoch2 > Ob &&Stoch<=Ob&& NewBar ){


if(TakeProfite!=0){TP=Ask+TakeProfite*point;}else TP=0;
if(StopLoss!=0){SL=Ask-StopLoss*point;}else SL=0;
double
buy=OrderSend(NULL,OP_BUY,LotSize,Ask,5*Q,SL,TP,NULL,MagicNumber,0,clrBlue);
if(Email)SendMail(Symbol(),"New Buy Order @ "+(string)Ask);
if(PopUp)Alert(Symbol()+" New Buy Order @ "+(string)Ask);
if(Mobile)SendNotification(Symbol()+" New Buy Order @ "+(string)Ask);
NewBar=false;
}

}
//+------------------------------------------------------------------+

int orderscnt(int tip)


{
int cnt=0;
for(int i=0;i<OrdersTotal();i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if(OrderSymbol()==Symbol() &&
MagicNumber==OrderMagicNumber()&&OrderType()==tip)
{
cnt++;
}
}
return(cnt);
}

//-------------------------------------------------------------------+
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);
}
}
}
}
}
}
//------------------------------------------

You might also like