Download MetaTrader 5
To add comments, please log in or register
Have you found an interesting application? Publish it in Code Base - millions of traders will appreciate that!
MrChuckW
398
MrChuckW 2015.01.02 01:03 

Is there a way to "batch" enter arrows onto a chart?   say from and excel spread sheet.

Or is the only way to excruciatingly put them in one at a time, or wait for the extreemly slow process of the visual mode?  

The tester spits out in a short time all the orders etc. in a nice report that can be copied to excel.   We are talking several hundred orders... I would love to dump them into a chart window.  What is the fastest way?

Visual mode does not allow me to chance the time frame to see whats happening around my order on different timeframe charts.

Maybe its wishful thinking...   anyone have any ideas?

thanks. 

Keith Watford
Moderator
7918
Keith Watford 2015.01.02 02:05  

You could write code to read the spreadsheet and place arrows on the chart.

Your post suggests that your EA puts arrows on the chart.

I'm not sure, but I think that if you run the EA in Strategy tester (non-visual) and open the chart after it has finished. Then save the chart template, you will be able to apply the template to another chart and be able to change timeframes.

Of course, if the arrows are deleted in de-init, you will need to disable that code 

MrChuckW
398
MrChuckW 2015.01.03 02:56  

I'm not that good a programmer yet...  do you know of any code I could play with to read the spread sheet and place the arrows on the chart?

The only way I know of putting arrows on the chart are one at a time, or doing the visual test, and it places an arrow at every open order and every close order....   either way its way too time consuming.

thanks for the reply....  something to research. 

Keith Watford
Moderator
7918
Keith Watford 2015.01.06 01:06  

This Script may give you a start.

I'm guessing that you copy and paste the results to an excel workbook? I don't see any option to directly save as anything other than a report that opens in your browser.

With this you will need to copy and paste to a CSV file, not XLS

This should just put the buy/sell arrows on the chart. Note, they are easier to see on a bar chart as opposed to a candle chart.

You could create an array to store the details of each trade and then create the objects in a loop to show the closes and lines in between as well. That should not be too difficult.

#property copyright "GumRai"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property script_show_inputs
//--- input parameters
input string      File_Name= "testertrades.csv";

#include <stdlib.mqh>
#include <stderror.mqh>
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

int start() {
   
   for(int x=ObjectsTotal()-1;x>=0;x--)
      {
      string obname=ObjectName(x);
      if(StringFind(obname,"BuyArrow",0)>=0 || StringFind(obname,"SellArrow",0)>=0)
         ObjectDelete(obname);
      }
  
   ResetLastError();
   int handle = FileOpen(File_Name,FILE_SHARE_READ|FILE_CSV )  ;
   if(handle<0)
     {
     Print("Error opening file ",File_Name,". Error- ",ErrorDescription(GetLastError() ) );
     return(0);
     }
     
     
   string split[];
   ushort sep=StringGetCharacter(",",0);   
   int lines =0;
   while(!FileIsEnding(handle))
   {
   lines++;
   string line=FileReadString(handle);
   StringSplit(line,sep,split);
   if(split[2]=="buy")
      {
      ObjectCreate(0,"BuyArrow"+split[3]+" "+split[1],OBJ_ARROW_BUY,0,StrToTime(split[1]),StrToDouble(split[5]));
      }
   else
   if(split[2]=="sell")
      {
      ObjectCreate(0,"SellArrow"+split[3]+" "+split[1],OBJ_ARROW_SELL,0,StrToTime(split[1]),StrToDouble(split[5]));
      }
      
   }
  FileClose(handle);
  Print(lines," Lines");
return(0);
}
/
To add comments, please log in or register