60 – X – reversal

A semi automated trading routine

semi_auto

_60_X_Reversal_3x 26-50

#property copyright “Copyright © 2017, Macdulio”
#property description “V1.0”
#property description “60 -X- reversal by Macdulio”
#property description “puts out 3, limit orders exipring in 3 hours”
#property description “with 26 pips stops and 50 pips targets”
#property description “with equity adjusted size, 1.5 then 3 pips apart”
#property description “program it on ALT + X”
#property description “don’t forget to remove the EA”
#property description “once the orders are placed”
#property link “http://forexfore.blog”

#include <stdlib.mqh>
#include <WinUser32.mqh>

extern int magic_number = 47;
int counter = 0;
extern double Leverage = 3.0;
extern int OrdersNow = 5;
extern int Slippage = 3;
extern int Stop_Loss = 26;
extern int Take_Profit = 50;
extern double AF=1.3;
extern double LT=17;
double pivot[];
double PriceL ;
double PriceH;
extern int maxlines = 15;
extern int displaylength = 55;
double lines[];
double mid[];
extern int pipApart2 = 1;
int i,pos,c_b=Bars;
int init()
{
ArrayResize(lines, maxlines);
ArrayResize(mid, c_b);

ArrayInitialize(lines, 0);
ArrayInitialize(mid, EMPTY_VALUE);
return(0);
}

int start()
{
int expiration;
double Price = WindowPriceOnDropped();
int slippage;

mid[0]=EMPTY_VALUE;

pos=0;
for (i=0; i<=c_b-1; i++)
{

if (iATR(NULL,60,3,i)>iATR(NULL,60,3,i-1) && iATR(NULL,60,3,i)> iATR(NULL,60,3,i+1) && iATR(NULL,60,3,i)>0.0010 && iATR(NULL,60,3,i)>(iATR(NULL,60,3,i+1)+iATR(NULL,60,3,i+2)+iATR(NULL,60,3,i+3))/3*1.25) mid[pos]=iHigh(NULL,60,i)-(iHigh(NULL,60,i)-iLow(NULL,60,i))/2;
if (iATR(NULL,60,3,i)> iATR(NULL,60,3,i+1) && iATR(NULL,60,3,i)>0.0010 && iATR(NULL,60,3,i+1)>iATR(NULL,60,3,i+2) && iATR(NULL,60,3,i+2)>iATR(NULL,60,3,i+3) && iATR(NULL,60,3,i+3)>0.0010) mid[pos]=iHigh(NULL,60,i)-(iHigh(NULL,60,i)-iLow(NULL,60,i))/2;
if (High[i+2]<High[i+1] && Low[i+2]>Low[i+1] && High[i+1]-Low[i+1]>(High[i+2]-Low[i+2])*2 && iATR(NULL,60,3,i+2)>0.0010) mid[pos]=iHigh(NULL,60,i)-(iHigh(NULL,60,i)-iLow(NULL,60,i))/2;

if (mid[pos]!=EMPTY_VALUE) pos=pos+1;

}

 

i=0;
while(i<2 && pos>0)
{
if (i==pos) break;
if (mid[i]!=EMPTY_VALUE) lines[i]=NormalizeDouble(mid[i],5);
i++;
}

double account = AccountEquity();
double Lots = NormalizeDouble(LT/3000000*account*AF*Leverage,4);

double price12,price2;

int ticket1,ticket12,ticket2,error;
int NrOfDigits = MarketInfo(Symbol(),MODE_DIGITS);
int PipAdjust;
if(NrOfDigits == 5 || NrOfDigits == 3)
PipAdjust = 10;
else
if(NrOfDigits == 4 || NrOfDigits == 2)
PipAdjust = 1;
expiration=CurTime()+10800;

slippage = Slippage * PipAdjust;

 

PriceL = lines[0]+10*Point;
PriceH = lines[0]-10*Point;

price12 = NormalizeDouble(PriceH+pipApart2*Point*PipAdjust,Digits);
price2 = NormalizeDouble(PriceL-pipApart2*Point*PipAdjust,Digits);

PriceH = PriceH+3*Point;
PriceL = PriceL-3*Point;

 

for (i=OrdersTotal()-1; i>=0 ; i–)
{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
{
Print(“Access to orders list failed with error (“,GetLastError(),”)”);
break;
}
if (OrderMagicNumber()==magic_number )
counter = counter +1;

}

double increment = NormalizeDouble(15 * Point * counter, 5);

if(Bid<price12 && counter<4 )
{

ticket12=OrderSend(Symbol(),OP_SELLLIMIT,Lots,price12+increment,slippage,price12+increment+Stop_Loss*Point*PipAdjust,price12+increment-Take_Profit*Point*PipAdjust,”BEE 60 SELL LMT 3H 260/500″,magic_number,expiration,Black);
if(ticket1<1)
{
error=GetLastError();
Print(“Error = “,ErrorDescription(error));
return(0);
}

}

if(Ask>price2 && counter<4 )
{

ticket2=OrderSend(Symbol(),OP_BUYLIMIT,Lots,price2-increment,slippage,price2-increment-Stop_Loss*Point*PipAdjust,price2-increment+Take_Profit*Point*PipAdjust,”BEE 60 BUY LMT 3H 260/500”,magic_number,expiration,Black);
if(ticket1<1)
{
error=GetLastError();
Print(“Error = “,ErrorDescription(error));
return(0);
}

}

Sleep(490000000000000);
return(0);
}

semi_auto2