[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 631

 
I probably have a silly question, but if the terminal uses five-digit quotes, should the global variables be specified with extra zeros as well? For example TP = 500 instead of 50?
 
artmedia70:

...Try formulating the same question in a different way, so that no one picks on it... ;)


Why should I formulate a question to which I know the answer.
 
alsu:
It means that in order to calculate the indicator on the current bar we need a certain amount of previous price values, in this case PeriodSMA. If we don't decrease the index of the initial bar, we will have several incorrectly calculated indicator values at the very left end of the chart.

alsu if you don't mind, could you give me a small example? I don't really understand the point of this "shift". After all, the whole series of bars will be calculated in any case, then why this shift? And why choose PeriodSMA and not any

and not any other value that differs from it? I can't find any description or explanation of this issue anywhere. Thank you!

 
skyjet:
I probably have a silly question, but if the terminal uses five-digit quotes, should the global variables be specified with extra zeros as well? For example TP = 500 instead of 50?
new_sl = NormalizeDouble(MathMax(order_open_price + MathMax(STOP_LOSS*coef,stop_level)*Point, Ask + stop_level*Point), Digits)
 
Fox_RM:

alsu if you don't mind, could you give me a small example? I don't really understand the point of this "shift". After all, the whole series of bars will be calculated in any case, then why this shift? And why choose PeriodSMA and not any

and not any other value that differs from it? I can't find any description or explanation of this issue anywhere. Thank you!

For example, you need to calculate a simple moving average with PeriodSMA. To calculate the SMA you need to add the values of the last PeriodSMA bars and divide by the PeriodSMA. It is obvious that for the bars with numbers Bars-1, Bars-2, ..., Bars-PeriodSMA+1 it will not work, because we simply do not have the necessary amount of bars for the calculation (the leftmost bar has Bars-1 index). Therefore, we have to start calculation of the indicator not with the last bar in the chart, but with the bar with the Bars-PeriodSMA index.

Why do they write this value, and not an arbitrary one? It is because this shift of the calculation start allows us to calculate the maximal amount of bars without prejudice to correctness of the calculation.

But keep in mind that this is the simplest case. Sometimes it may not be immediately clear from the code how many past bars the program needs for calculation and where exactly this shift comes from. Well, you should probably ask the developer who wrote the code. But in general, there is a universal way - just look at the code, what in principle the maximum index of the bar can be obtained using price data and index buffers data during the program operation, usually already at this stage it becomes clear...

 
YOUNGA:
new_sl = NormalizeDouble(MathMax(order_open_price + MathMax(STOP_LOSS*coef,stop_level)*Point, Ask + stop_level*Point), Digits) feel this construction
If you had mentioned that "coef" variable equals 10 for a 5-digit number and 1 for a 4-digit one I would feel it too.

And by the way, in the question the example was expected for TP and you have "new_sl = ".
You should be more attentive, beginners after all ..., the answer should be clever, not abstruse.
 
prorab:
If you had mentioned that your "coef" variable is 10 for 5 digits and 1 for 4 digits, I would have felt it too, but otherwise...

And by the way, in the question the example was expected for TP and you have "new_sl = ".
You should be more attentive, beginners after all ..., the answer should be clever.
I wish someone would tell me a working strategy (a man's tear falls to the floor...)
 
YOUNGA:
I wish someone would tell me a working strategy (a man's tear falls to the floor...)


If I understood correctly, this construct can be inserted after start()?

Also the variable coef, how do I give it the values from the previous comment? I mean 10 for a 5th digit and 1 for a 4th digit?

 
skyjet:


If I understand, this construct can be inserted after start()?

Also coef variable, how to give it the values from the previous comment? I mean 10 for a 5-symbol and 1 for a 4-symbol?

The Expert Advisors that I use have approximately the same construction:

if (Digits==4 || Digits==2) coef=1; else coef=10; // multiplier for different account types 4/2 and 5/3


 
Oboltus:

The EAs I use have roughly this design:

if (Digits==4 || Digits==2) coef=1; else coef=10; // multiplier for different account types 4/2 and 5/3



Thanks for the clarification!

And just to clarify, if I mechanically add 0, will TP and SL work in this type of terminal?