Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 916

 

StringAdd() IntegerToString() - what's wrong?

In a string of the type

x=StringAdd(x,IntegerToString(y));

gives a yellow warning

implicit conversion from 'string' to 'number'

what is wrong?
 

Good afternoon.

Task: calculate to a point the middle of the channel (to be used as a pending order). I set the borders of the channel manually.

double up_level, down_level, stop_size;

int init()
{
   up_level=1.55974;
   down_level=1.55596;
   stop_size = NormalizeDouble((up_level - down_level)/2,5);
   Alert ("Ширина канала = ", NormalizeDouble(up_level - down_level,5));
   Alert ("Середина канала = ", NormalizeDouble(stop_size,5));
   return(0);
}

I calculate it with the calculator

1.55974 - 1.55596 = 0.00378

Alert shows width = 0.0038

0.00378/2 = 0.00189

Alert gives out middle = 0.0019

Question: Why doesn't the program count the 5th digit?

 
GygaByte:
   Alert ("Ширина канала = ", DoubleToString(up_level - down_level,5));
   Alert ("Середина канала = ", DoubleToString(stop_size,5));

When outputting to alert, comment, print, etc. (i.e., "to be seen clearly on the screen"), you need to convert it to text.

You'll get it:

P./S.: And for internal calculations - yes, NormalizeDouble(...).

 
GygaByte:

P./S.: There is also, for example, useful information on this subject and a link to an article in the Forum Navigator.

 
Hobu:

StringAdd() IntegerToString() - what's wrong?

in a string of the type

x=StringAdd(x,IntegerToString(y));

gives a yellow warning

implicit conversion from 'string' to 'number'

what's wrong?

StringAdd is of type bool.

All you have to do is specify the join to the end of the string (if x is of the string type in your case, of course):

StringAdd(x,IntegerToString(y));
 
Hobu:

P./S.: Good examples on strings are in this article, for example: https://www.mql5.com/ru/articles/585

(and there just type or copy-paste from the search page: StringAdd)

 
varyar84:

Please help me understand.

How do I write different lines in the EA from the indicator?

I have an indicator - MACD 2 Line. How to prescribe the lines from the indicator in my Expert Advisor?

Return values:

 
varyar84:

P./S.: How to put this into practice, if questions arise, can be found in a variety of searches on the website and/or in the textbook.

Good luck.

 
Hi all, I have a question, is it better to make one cycle for all purposes or can there be several cycles in a block, is there a difference in terms of performance of the EA or not?
 

Hello all.

To test the strategy on H1 I need to get the previous day's close.

In the indicator I write the following (after declaring "CloseLine" in OnInit()) :


int OnCalculate(const int rates_total, const int prev_calculated,

const datetime &time[], const double &open[],

const double &high[], const double &low[],

const double &close[], const long &tick_volume[],

const long &volume[], const int &spread[])

{

Close_Day=iClose("EURUSD",PERIOD_D1,1);

ObjectSet("CloseLine",OBJPROP_PRICE1,Close_Day);

return(rates_total);

}

As a result, the price from Day TF is not changed and the line is not rearranged.

Please help.

Thank you