[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 715

 
dimon74:
This is how it works for me. A position is closed by TP, while to set a new pending order we need TP+n*Point value. And here we get a discrepancy: OrderTakeProfit () gives me four digits (I see it in Alert) and my brokerage company wants five. I have tried many things, but it seems there is more to come. If you have any idea, please give me some ideas. Thanks in advance!
Alert() and Print() produce 4 decimal places by default, while 8 is actually used. For correct output to the "console", use DoubleToStr().
 
dimon74:
This is how it works for me. The position is closed by TP, while a new pending order needs the value of TP+n*Point to be set. Here we get a discrepancy: OrderTakeProfit () gives me four digits (I see it in Alert) and my brokerage company wants five. I have tried many things, but it seems there is more to come. If you have any idea, please give me some ideas. Thanks in advance!

string DoubleToStr( double value, int digits)

Converts a numeric value to a text string containing the character representation of the number in the specified precision format.

This should help for preverification.

It's just that both Alert() and Print() output values to 4 digits. So your problem is different.

 

I can't understand why in this form

for(int a=0;a<8;a++)
// тут что нить делаем
for(int a=0;a<8;a++)
// еще чо нить делаем

It says that the variable has already been defined. I think it gets 0 again in the repetition? And they are in different pieces of code, the first in if, the second in else...

 
Abzasc:

I can't understand why in this form

It says that the variable has already been defined, so why does it get 0 again in the repetition? And they are in different pieces of code, the first in if, the second in else...


int a;
for(a=0;a<8;a++)
// тут что нить делаем
for(a=0;a<8;a++)
// еще чо нить делаем
So why define the same variable twice
 
Vinin:

Why define the same variable twice

To reread

 for(int a=0;a<8;a++)
 aJPY[a]=iCustom(NULL,PERIOD_M15,"Indexes",a,0);

I.e., if the condition is one, read, if another... shit. Got it. But it's a specific case, I don't need this fragment in else.

I don't know how to null the a variable so that it can be used in another code fragment. If the condition is one, we call one indicator and if another one - another... ...because there's not enough variables...

 
Abzasc:

To reread

I.e., if the condition is one, read, if another... shit. Got it. But it's a specific case, I don't need this fragment in else.

I don't know how to null the a variable so that it can be used in another code fragment. If the condition is one, we call one indicator and if another one - another... ...because there's not enough variables...


Nah, we've got to figure it out somehow. There just doesn't seem to be enough code. I was only talking about one thing. Declare a variable and use (with pre-initialization) are different things. One and the same variable can carry very different functional values, the main thing is not to mix up what and where.
 

Let me try to elaborate. There is an indicator, without buffers. It takes values of another indicator in 4 arrays. I'm trying to attach

   int    counted_bars=IndicatorCounted();
   // считать только последний вызов
   int limit;
   if(counted_bars>0)
      counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0;i<limit;i++)
If there is a new bar, all arrays are recalculated. If there is no new bar, only the 0-th one. But we recalculate all the same, i.e. we call both if and else.
 
Abzasc:

Let me try to elaborate. There is an indicator, without buffers. It takes values of another indicator in 4 arrays. I'm trying to attach it.

If there is a new bar, we recalculate all arrays. If there is no bar, we recalculate only the 0-th. But we recalculate all the same, i.e. we call both if and else.


I prefer a different approach

   int    counted_bars=IndicatorCounted();
   // считать только последний вызов
   int limit=Bars-counted_bars-1;
   if(Bars-counted_bars>2)
      limit = //.......................
   for(int i=limit;i>=0;i--)

Although, it's a matter of taste. But at least I can explain each line

 
Vinin:


I prefer a different approach

It's a matter of taste, though. But at least I can explain every line

Let's put it like this. Then if limit = 0, if we write array 0, 1, 2, else - array 0. And a variable error.

Or should we write an array of 1, 2, else - array 0?

Either way, - I can't use the a variable 2 times, that's the problem. I only use it 2 times, though, in if and else. It's not even in shared variables at the top of the code.

 
Abzasc:

Let it be like this. Then if limit = 0, if we write array 0, 1, 2, else - array 0. And a variable error.

Or if we write array 1, 2, else - array 0?

Either way, - I can't use the a variable 2 times, that's the problem. I only use it 2 times, though, in if and else. It's not even in shared variables at the top of the code.


Give me the whole code. You can send it to me in person. I'll try to help.
Reason: