commet when opening trade

 

Hi,

I would like to have comments when opening trade (backtesting). It will be indicators values like below.

string comment= (" ATRd "+ATRd+"\n"
                 " MomentumD1down "+MomentumD1down+"\n"
                  " MomentumD1up "+MomentumD1up );

string comment= (" ATRd "+ATRd);

input int    MTRperiod=7;
input int    MomentumD1OkresSr=100;
input double MomentumD1minmax= 0.1;

  int    res,j,o,p;
   double ATRd = iCustom(NULL,PERIOD_D1,"MTR",MTRperiod,0,1);
    double MomentumD1= iMomentum(NULL,PERIOD_D1,1,PRICE_CLOSE,1);
  double n[], MomentumD1down, MomentumD1up;
  ArrayResize(n,MomentumD1OkresSr-1);
  for(j=0;j<MomentumD1OkresSr;j++)
      { n[j]=iMomentum(NULL,PERIOD_D1,1,PRICE_CLOSE,1+j);}
    ArraySort(n);
    o=MathRound(MomentumD1OkresSr*MomentumD1minmax);
    p=MathRound(MomentumD1OkresSr*(1-MomentumD1minmax));
    MomentumD1down= n[ o-1];
    MomentumD1up= n[ p-1];

 The first comment doesnt work, but the second does... why? too much text?

 

Where are you putting the comments in your code?

When you have 2 comments, the first one is replaced so quickly that you don't see it

 
Brt88: I would like to have comments when opening trade (backtesting). It will be indicators values like below.

 The first comment doesnt work, but the second does... why? too much text?

That is not your real code, as it will not compile. There is executable code outside of a function (globally scoped) and you define the variable "comment" twice and the contents is assigned before the actual data is available.

You will have to supply more realistic code, that includes calling Comment(), for it be scrutinized by us correctly.

Also, when using the Comment() function, it will always replace the previous one displayed. It will not append to it and you will have to do that yourself in your code.

EDIT: PS! Also, instead of "adding" strings together, use StringConcatenate() so as to prevent any undue problems with string corruption that has been reported by some users.

 
GumRai:

Where are you putting the comments in your code?

When you have 2 comments, the first one is replaced so quickly that you don't see it

 res=OrderSend(Symbol(),OP_SELL,WielkoscPozycji,Bid,3,SLs,OrderTakeProfit(),"1Dsell  "+comment,MAGICMA,0,Red);

ofcourse there is 1 variable "comment" but for checking whats wrong a pasted 2 versions. It looks like there is some limit in signs...


edit////  27-31 signs for Order comment, if more rejected

 
Brt88: ofcourse there is 1 variable "comment" but for checking whats wrong a pasted 2 versions. It looks like there is some limit in signs...


edit////  27-31 signs for Order comment, if more rejected

There is a difference between comments on the chart (namely Comment() function) and Order Comments. So in future posts, please be clear about to which one you are referring.

As for Order Comments, you cannot depend on them because not all brokers support it. Some allow it, but only for short strings and with a restricted character set, while others even change the contents completely for their own use.

So, the recommendation is not to use it at all, or if you do, don't depend on it at all for any kind of processing or follow-up.

You should rather rely on the built-in journal log (with the Print() and PrintFormat() functions) or output your own logs to user files.

I also call your attention again about not "adding" strings together, but to rather use StringConcatenate() so as to prevent any undue problems with string corruption that has been reported by some users.

 
FMIC:

There is a difference between comments on the chart (namely Comment() function) and Order Comments. So in future posts, please be clear about to which one you are referring.

As for Order Comments, you cannot depend on them because not all brokers support it. Some allow it, but only for short strings and with a restricted character set, while others even change the contents completely for their own use.

So, the recommendation is not to use it at all, or if you do, don't depend on it at all for any kind of processing or follow-up.

You should rather rely on the built-in journal log (with the Print() and PrintFormat() functions) or output your own logs to user files.

I also call your attention again about not "adding" strings together, but to rather use StringConcatenate() so as to prevent any undue problems with string corruption that has been reported by some users.

Thank you for your advice. Plz tell me how could I present the values of indicators (in D1 period) while backtesting EA on H1 timeframe. If the periods match the indicator is on the chart or below... but how to show them (on the screen with charts or below them)  in this case? My way was using Order comment, do you know any better?
 
Brt88:
Thank you for your advice. Plz tell me how could I present the values of indicators (in D1 period) while backtesting EA on H1 timeframe. If the periods match the indicator is on the chart or below... but how to show them (on the screen with charts or below them)  in this case? My way was using Order comment, do you know any better?

I have already answered that in my previous post and I quote:

You should rather rely on the built-in journal log (with the Print() and PrintFormat() functions) or output your own logs to user files.

 
FMIC:

I have already answered that in my previous post and I quote:

You should rather rely on the built-in journal log (with the Print() and PrintFormat() functions) or output your own logs to user files.

I have already clarified where i would like to see the comment or any type of info  about the values of indicators  "(on the screen with charts or below them) " not in journal nor in log. It coud be some kind of indicator below chart but the problem is that the indicators are calculated on a differrent timeframes.  (indicators - D1, backtesting -H1)
 
Brt88 but the problem is that the indicators are calculated on a differrent timeframes.
Why is that a problem? They return a value, show it!
 
Brt88:
I have already clarified where i would like to see the comment or any type of info  about the values of indicators  "(on the screen with charts or below them) " not in journal nor in log. It coud be some kind of indicator below chart but the problem is that the indicators are calculated on a differrent timeframes.  (indicators - D1, backtesting -H1)
So what is the problem! Just display Chart Objects on the H1 chart, referencing D1 data. Alternatively, just alter the D1 indicators to work as Multi-Timeframe Indicator on the H1 chart!