int MAGIC = 1234;
extern double lots =0.1;
extern double hh = 4;
extern double hn = 4;
extern double hb = 4;
extern double hc = 4;
extern double n = 4;
extern double p = 65;
extern double stop_loss = 1000; //100 for 4 Digits
extern double take_profit = 700; //70
extern bool mod_vsa = false;
extern int v1 = 100;
extern int v2 = 100;
extern int v3 = 100;
extern int v4 = 100;
extern int p2 = 10;
int last_bar = 0;
int start(){
if (last_bar == Bars) return(0);
last_bar = Bars;
if (OrdersTotal() <= 0 ){
if( OPEN_POS()>0&&(!mod_vsa || vsa()>0)
&& Hour()!=hh&& Hour()!=hn&& Hour()!=hb&& Hour()!=hc&& Hour()!=hb+n&& Hour()!=hc+n)OrderSend(Symbol(), OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid + take_profit * Point, WindowExpertName(), MAGIC, 0, Blue);
if( OPEN_POS()<0 &&(!mod_vsa || vsa()<0)
&& Hour()!=hh&& Hour()!=hn&& Hour()!=hb&& Hour()!=hc&& Hour()!=hb+n&& Hour()!=hc+n)OrderSend(Symbol(), OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, WindowExpertName(), MAGIC+1, 0, Red);
}
return(0);
}
double OPEN_POS()
{
double L = iLow(NULL, 0, 1);
double H = iHigh(NULL, 0, 1);
double C = iClose(NULL, 0, 1);
if( ((H-C) / (H-L+0.00001))*100 > p ) { return(1); }
if( ((C-L) / (H-L+0.00001))*100 > p ) { return(-1);}
return(0);
}
double vsa() {
double w1 = v1 - 50;
double w2 = v2 - 50;
double w3 = v3 - 50;
double w4 = v4 - 50;
double a1 = (iATR(NULL,60,1,p2 *1) - iATR(NULL,60,1,p2 *2));
double a2 = (iATR(NULL,60,1,p2 *2) - iATR(NULL,60,1,p2 *3));
double a3 = (iATR(NULL,60,1,p2 *3) - iATR(NULL,60,1,p2 *4));
double a4 = (iATR(NULL,60,1,p2 *4) - iATR(NULL,60,1,p2 *5));
return(w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4);
}
Comments