//+------------------------------------------------------------------+ //| baiso1.mq4 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Expert initialization function | // NOI KHAI BAO BIEN extern double khoiLuong= 0.01;// 0 double stoploss = 0; double takeprofit = 0; extern string ghichu = "hello"; color maucualenh = clrRed; extern int loaiLenh = OP_BUY; double giavaolenh=0; datetime thoigiangiaodich; bool chophepGD = true; //+------------------------------------------------------------------+ int OnInit() { //--- checkLisicen(); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //khai báo hàm ở đây //+------------------------------------------------------------------+ void OnTick() { //--- /* tinhlotsize(); checkDKvaolenh(); dinhdangLot(); vaolenh();*/ if(chophepGD == false){return;} if(OrdersTotal()>0){return;} // chi cho vao 1 lenh // if(iTime(Symbol(),15,0) == thoigiangiaodich){return;} thoigiangiaodich = iTime(Symbol(),15,0); if( Close[1]>Open[1] ){ loaiLenh = OP_BUY; } if(Close[1] MarketInfo(Symbol(),MODE_MAXLOT)){ khoiLuong = MarketInfo(Symbol(),MODE_MAXLOT) ; } khoiLuong = NormalizeDouble(khoiLuong,2); // bằng 0 --> lot nhỏ nhất chấp nhận 0.01 0.001 0.1 //9000 lot --> 50 lot sô lot lớn nhất dc chấp nhận. //0.014875 --> 0.01 0.02 return(khoiLuong);// tra ve khoi da duoc dinh dang } //====================================================== void checkLisicen() { if(AccountNumber() != 22629828 ){Alert("khong dung tai khoan");chophepGD= false;} if(AccountEquity() < 1000 ){ Comment("tai khoan qua nho , rui ro cao"); } if(IsTradeAllowed() ==false ){ Alert("hay click vao trade allow");} } //==========================================