0
43
//+------------------------------------------------------------------+ //| nadex5mins.mq4 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //General variables extern double TakeProfit =0.0015; extern double StopLoss =-0.0015; string filename; int file_handle,Date; //--- parameters for writing data to file input string InpFileName="deta.csv"; // File name input string InpDirectoryName="Data"; // Folder name //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int init() { //--- file_handle=FileOpen(InpDirectoryName+"//"+InpFileName,FILE_READ|FILE_WRITE|FILE_CSV); if(file_handle!=INVALID_HANDLE) { PrintFormat("%s file is available for writing",InpFileName); PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH)); } else PrintFormat("Failed to open %s file, Error code = %d",InpFileName,GetLastError()); //--- return (0); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { int count; for(count=0;count<=OrdersHistoryTotal();count++) { OrderSelect (count, SELECT_BY_POS, MODE_HISTORY); FileWrite(file_handle,Symbol()+" "+TimeDayOfYear(OrderOpenTime())+" "+TimeHour(OrderOpenTime())+":"+TimeMinute(OrderOpenTime())+" "+OrderOpenPrice()+" "+TimeHour(OrderCloseTime())+":"+TimeMinute(OrderCloseTime())+" "+OrderClosePrice()+" "+TimeDayOfYear(OrderCloseTime())+" "+OrderType()); } //--- close the file. FileClose(file_handle); PrintFormat("Data is written, %s file is closed",InpFileName); return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- Date = DayOfYear(); //int ticket; double LONG_TP = NormalizeDouble(TakeProfit,5); double LONG_SL = NormalizeDouble(StopLoss,5); if(TimeMinute(TimeCurrent())%5 == 0) // int Tyme = TimeMinute(TimeCurrent())%5; // if(Tyme == 5) { RefreshRates(); double bid =MarketInfo(Symbol(),MODE_BID); // Request for the value of Bid double ask =MarketInfo(Symbol(),MODE_ASK); // Request for the value of Ask int ticket = OrderSend(Symbol(),OP_BUY ,0.1,NormalizeDouble(ask,5),3,NormalizeDouble(ask-StopLoss,5),NormalizeDouble(ask+TakeProfit,5),"",0, TimeCurrent() + 300, Green); FileWrite(file_handle,"kula mavy"); if(TimeMinute(TimeCurrent())== TimeMinute(OrderOpenTime())+5){ OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(bid,5), 10, Blue); } } //---- return(0); }