i keep getting error 130 on the journal and implicit conversion from number to string from compiler output i cant figure it out kindly assist guys

 
//+------------------------------------------------------------------+
//|                                                   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);
   }
Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
Choose a suitable trading strategy and subscribe to it with a few clicks. All Signals are provided with detailed statistics and informative charts. Become a trading signal provider and sell subscriptions to thousands of traders around the world. With the Signals service, your successful strategy can generate income with a small start-up budget...
 

There is also the line number and the cursor position of where the error occurs.

 
  1. When providing code for review, please use the SRC button.
  2. Please provide a screenshot of your compiler errors.

Thank you.

- Jack

 
  1. When you post code please use the SRC button! Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. for(count=0;count<=OrdersHistoryTotal();count++)
          {
              OrderSelect (count, SELECT_BY_POS, MODE_HISTORY);
    If there are N positions their index is [0..N-1] OrderSelect( OrdersHistoryTotal() ... ) will always fail. Check your return codes for errors and report them.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

  3. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong

  4. 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);
    You can not use any Trade Functions until you select an order.
  5. You buy at the Ask and sell at the Bid.
    • Your buy order's TP/SL are triggered when the Bid reaches it. Not the Ask.
    • Your sell order's TP/SL will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 and MetaTrader 4 - MQL4 programming forum - Page 3
    • The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools -> Options {control-O} -> charts -> Show ask line.)

  6. After Sleep and between server calls the market will have changed, you must update your variables. To use any pre-defined variables and series arrays you must call RefreshRates
              RefreshRates - Timeseries and Indicators Access - MQL4 Reference
  7. Use the debugger or print out your variables, including _LastError and find out why.
 

Fix these problems first. This will fix some very obvious code issues.


After you do that, show us a screenshot of the compiler without the errors. Then we can move on to the other problems.
 
Jack Thomas:

Fix these problems first. This will fix some very obvious code issues.


After you do that, show us a screenshot of the compiler without the errors. Then we can move on to the other problems.


Thanks Jack, over the last several days I have tried and I can't for the life of me, figure out what the issue is. I guess what I am saying is that I am stuck. I have tried the following:

I, changing all my ordersend arguments with and without normalized double where applicable

ii, used bid instead of ask where appropriate on the ordersend arguments

iii, I placed an order select function before the use of orderopentime function as advised above but still I get thee same warnings in strict mode and error 130 in normal mode when I run the tester.

Files:
dmx.png  106 kb
 
What do you mean no difference? Show us your line 46.
 
duke nyanchoka:


Thanks Jack, over the last several days I have tried and I can't for the life of me, figure out what the issue is. I guess what I am saying is that I am stuck. I have tried the following:

I, changing all my ordersend arguments with and without normalized double where applicable

ii, used bid instead of ask where appropriate on the ordersend arguments

iii, I placed an order select function before the use of orderopentime function as advised above but still I get thee same warnings in strict mode and error 130 in normal mode when I run the tester.


I appoloize didn't rrealize it wasn't captured.
//+------------------------------------------------------------------+
//|                                                   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.0009;
extern double StopLoss    =-0.0009;
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()-1;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(bid-StopLoss,5),NormalizeDouble(bid+TakeProfit,5),"",0, 0, Green);
            RefreshRates();
            if(OrderSelect(ticket,SELECT_BY_TICKET)==TRUE){
            if(TimeMinute(TimeCurrent())== TimeMinute(OrderOpenTime())+5){
               OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(bid,5), 10, Blue);
            
            
            }}
         }
         
         
//----
   return(0);
   }

Files:
dmxxx.png  73 kb
 
FileWrite(file_handle,Symbol()+" "+TimeDayOfYear(OrderOpenTime())+" "+TimeHour(OrderOpenTime())+":"+TimeMinute(OrderOpenTime())+
" "+OrderOpenPrice()+" "+TimeHour(OrderCloseTime())+":"+TimeMinute(OrderCloseTime())+" "+OrderClosePrice()+
" "+TimeDayOfYear(OrderCloseTime())+" "+OrderType());

Implicit int or double to string. Format your output

FileWrite(file_handle,
   StringFormat("%s %i %i:%i %g %i:%i %g %i %i", 
   Symbol(), TimeDayOfYear(OrderOpenTime()), TimeHour(OrderOpenTime()), TimeMinute(OrderOpenTime()),
   OrderOpenPrice(), TimeHour(OrderCloseTime()), TimeMinute(OrderCloseTime()), OrderClosePrice(),
   TimeDayOfYear(OrderCloseTime()), OrderType() ));
Reason: