Download MetaTrader 5
To add comments, please log in or register
Publish your task in Freelance service and developers will execute your order.
Carl Schreiber
5954
Carl Schreiber 2014.03.26 15:58 

At the moment only one terminal b625 is running, 4 charts are open and no EA is applied!!

Now I started my script in debug-mode: line by line. It shall start my test_EA to check how I can set and get the chart comment - an all of a sudden I there was a sell-limit order opened.

The account is not used as it is only to get the newest mt4-builts.

What I really wanted to check is just that the script 1) opens a new chart, 2) places a comment on that new chart and 3) applies a template that will apply the test_EA

//+------------------------------------------------------------------+
//|                                                       test_1.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

void OnStart()
  {
//---
                string tEA= "test_EA";
           string sy = "GBPUSD";
           long chID = ChartOpen( sy, PERIOD_M1 );
           string rmCmt = "IniComment from "+(string)ChartID()+" on " + sy+" with "+(string)chID;
                ChartSetString( chID, CHART_COMMENT, rmCmt );
           if ( !ChartApplyTemplate( chID, tEA ) ) {
                        Alert(  "ERROR(",_LastError,"): Can't apply Template to ",sy,"?");
           }
           Print("Opened ",sy," >",rmCmt,"<  ",(string)chID);
        
   
  }
//+------------------------------------------------------------------+

OK, the test_EA should just grap the comment from the script and save it in a variable and show it:

//+------------------------------------------------------------------+
//|                                                      test_EA.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
string IniCmt;
int OnInit()
  {
  
//---
        IniCmt = ChartGetString( 0, CHART_COMMENT );
        Print("MyCmt(",__LINE__,"): ",IniCmt);

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
        Comment("another Comment\n",IniCmt);
   
  }

I should see: s.th. like:

another Comment
IniComment from 130370193351027483 on GBPUSD with 130370193351027484

But I read on the chart only: another Comment another Comment another Comment\n

And that mysterious limit-order all of a sudden??

Anybody with an idea?

Gooly

tpl-file (re-named as txt)

Files:
test_ea.txt 1 kb
/
To add comments, please log in or register