How to code? - page 315

 

...

If you need it for fixed 0.5 than you can use MathSqrt(x)

But if you need the calculation for variable 0.5 part too than you can use MathPow(x,0.5) (the 0.5 part can be changed too)

dasio:
Hi.

There is a function that allow me to calculate this operation?

x^0,5 (x= know value)

And another question.

I have 5 digit broker. It is possible to get only the firt 4 decimal of know value? Thank you

Thank you
 
mladen:
If you need it for fixed 0.5 than you can use MathSqrt(x) But if you need the calculation for variable 0.5 part too than you can use MathPow(x,0.5) (the 0.5 part can be changed too)

Thank you for your reply. It's work fine.

For the second request?

If i have 5 digit broker the code give me prive with 5 digit broker but i need it in 4 digit. How i can tranfom the value from 5 to 4 digit?

Thank you

 

dasio

Use something like this :

price4digit = NormalizeDouble(price,4);
dasio:
Thank you for your reply. It's work fine.

For the second request?

If i have 5 digit broker the code give me prive with 5 digit broker but i need it in 4 digit. How i can tranfom the value from 5 to 4 digit?

Thank you
 

Finding the intersection point

Hi,

I have fond the following indicator:

#property copyright "Kalenzo"

#property link "bartlomiej.gorski@gmail.com"

#property indicator_color1 DodgerBlue

#property indicator_color2 Lime

#property indicator_buffers 2

extern int MoMPeriod = 14;

extern int MaType = MODE_EMA;

extern int MaPeriod = 50;

extern int TimeFrame = 60;

double mom[],

ema[],

momTF[],

emaTF[];

#property indicator_separate_window

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

IndicatorBuffers(4);

SetIndexBuffer(0,mom);

SetIndexBuffer(1,ema);

SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);

SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);

SetIndexBuffer(2,momTF);

SetIndexBuffer(3,emaTF);

IndicatorShortName("MTF Momentum "+tf());

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

//----

int bbshift,limit,limitTF;

limit=Bars;

limitTF = iBars(Symbol(),TimeFrame);

for(int i=0; i<limitTF; i++) momTF = iMomentum(Symbol(),TimeFrame,MoMPeriod,PRICE_CLOSE,i);

for(int j=0; j<limitTF; j++) emaTF[j] = iMAOnArray(momTF,0,MaPeriod,0,MaType,j);

for(int t=0; t<limit; t++)

{

bbshift = iBarShift(Symbol(),TimeFrame,Time[t]);

mom[t] = momTF;

ema[t] = emaTF;

}

//----

return(0);

}

[/PHP]

But I can't get the intersection point from this two lines with my ea, even I can't get the right value from the indicator, which is displayed.

Why?

I tried this for example:

[PHP]

x1= iCustom(NULL,0,"MOM_EMA_MTF",14,MODE_EMA,50,60,0,1);

 
mladen:
dasio

Use something like this :

price4digit = NormalizeDouble(price,4);

Hi mladen,

it is right how i code it?

Pivot = NormalizeDouble(( PDayHigh + PDayLow + Close ) / 3,4)

MathPow((MathPow(Pivot,0.5)+Number(defined)),2)

Thank you

 

...

The first line is OK

A question about this line :

MathPow((MathPow(Pivot,0.5)+Number(defined)),2);

What is the exact intention of that line? The way it is written it returns the square of the (square root of pivot + defined increase). Is that what you had in mind?

dasio:
Hi mladen,

it is right how i code it?

Pivot = NormalizeDouble(( PDayHigh + PDayLow + Close ) / 3,4)

MathPow((MathPow(Pivot,0.5)+Number(defined)),2)

Thank you
 
mladen:
The first line is OK

A question about this line :

MathPow((MathPow(Pivot,0.5)+Number(defined)),2);
What is the exact intention of that line? The way it is written it returns the square of the (square root of pivot + defined increase). Is that what you had in mind?

Yes it calculate first the value of MathPow(Pivot,0.5)+Number(defined) and after i must calculate the square of the result.

An example.

10 = Pivot

1 = number defined

I have ((10^0,5)+1)^2 The result is:

((3,162)+1)^2 ----> (4,162)^2------>17,324

 

Then it is all OK

dasio:
Yes it calculate first the value of MathPow(Pivot,0.5)+Number(defined) and after i must calculate the square of the result.
 
mladen:
Then it is all OK

Ok thank you.

But i need also this operation

(MathPow((MathPow((Pivot*10000),0.5)+number),2)/10000)

But it give me a different value if i calculate it manually.

The differente is high.

to clarify if i have 1,2989 how pivot i need to do the operation how 12989 and after all operation i need to divide the result for 10000.

I don't know why it give me different value

 

dasio

I do not know the "intention" of that line. Mathematically there is nothing wrong with that line (set the "number" to 0 and you will see that it will return exactly the same value as the Pivot which means that it works correctly, so if it is different than you expect it to be, the only part that makes the difference is the addition of "number"). What exactly are you trying to calculate with that line?

dasio:
Ok thank you.

But i need also this operation

(MathPow((MathPow((Pivot*10000),0.5)+number),2)/10000)

But it give me a different value if i calculate it manually.

The differente is high.

to clarify if i have 1,2989 how pivot i need to do the operation how 12989 and after all operation i need to divide the result for 10000.

I don't know why it give me different value
Reason: