Metatrader 5 coding questions / issues - page 16

 

Can TTM waves be made for metatrader 5 too?

 
checkin:
Can TTM waves be made for metatrader 5 too?

Posted one version for metatrader 5 here : https://www.mql5.com/en/forum/181297/page53

 
mladen:
Posted one version for metatrader 5 here : https://www.mql5.com/en/forum/181297/page53

Thank you

 

Mladen

Do you have any tip on how to do this: When MA 10 crosses MA 50 open position only and only if the close of last bar is not more than 15 pips to the point where the MA crossed.

Thanks.

 
funayot:
Mladen

Do you have any tip on how to do this: When MA 10 crosses MA 50 open position only and only if the close of last bar is not more than 15 pips to the point where the MA crossed.

Thanks.

funayot

You can not have an exact value (as an exact price) where 2 mas cross (that cross can happen somewhere in between the bars - it is due to the discrete nature of the ma calculation - only values at equidistant in time values are used instead of continuous stream of values). Because of that the point where 2 mas are crossing is simply a matter of estimation. We can use some math to estimate that, but even then it is an estimation, not an exact point where they crossed

 
mladen:
funayot You can not have an exact value (as an exact price) where 2 mas cross (that cross can happen somewhere in between the bars - it is due to the discrete nature of the ma calculation - only values at equidistant in time values are used instead of continuous stream of values). Because of that the point where 2 mas are crossing is simply a matter of estimation. We can use some math to estimate that, but even then it is an estimation, not an exact point where they crossed

Mladen

Well said. And how can we go about it with the cross approximations? I think I will like to go with the approximations, that's good enough. I'm looking forward to your solution.

 
funayot:
Mladen Well said. And how can we go about it with the cross approximations? I think I will like to go with the approximations, that's good enough. I'm looking forward to your solution.

In time series we have one problem : we are actually dealing with 2 different dimensions on a chart. We are having a price as one and time as the other. Those two are incompatible. But if we make some approximation of the time (as, for example, making it equal to atr) the the following way could be used : Line-line intersection - Wikipedia, the free encyclopedia

 
mladen:
In time series we have one problem : we are actually dealing with 2 different dimensions on a chart. We are having a price as one and time as the other. Those two are incompatible. But if we make some approximation of the time (as, for example, making it equal to atr) the the following way could be used : Line-line intersection - Wikipedia, the free encyclopedia

I read the article on Wikipedia. This requires developing an entirely new algorithm, an area where I'm still sharpening my skills. I have some suggestions on how to go around this:

1. We use the MA cross indicator attached below to determine the exact cross. (MA 10 crosses MA 50).

2. We note the candle where the cross occurred and determine how many pips away its close is from MA 50.

My question/concern is how to determine the value of price on MA 50. If we can know this, we can then determine the pips by calculating the difference between the value of the price of iclose (previous/cross candle close value) and the MA 50 price value.

Files:
 
funayot:
I read the article on Wikipedia. This requires developing an entirely new algorithm, an area where I'm still sharpening my skills. I have some suggestions on how to go around this:

1. We use the MA cross indicator attached below to determine the exact cross. (MA 10 crosses MA 50).

2. We note the candle where the cross occurred and determine how many pips away its close is from MA 50.

My question/concern is how to determine the value of price on MA 50. If we can know this, we can then determine the pips by calculating the difference between the value of the price of iclose (previous/cross candle close value) and the MA 50 price value.

funayot

You can simply do the following :

double ma[2];

CopyBuffer(ma_handle,0,bar,2,ma)

//

// after this copy

// ma[0] previous bar ma value

// ma[1] current bar ma value

//

You have to create a handle to the ma 50 first (using iMA() for that) and store it to _ma_handle

 

Mladen

Yes I know that part on creating handles. I'll however like to clarify if the MA[0] value is actually equivalent to the price value. Because this is only the way that we will be able to deduct from last closed bar and get the pips required in the logic.

mladen:
funayot

You can simply do the following :

double ma[2];

CopyBuffer(ma_handle,0,bar,2,ma)

//

// after this copy

// ma[0] previous bar ma value

// ma[1] current bar ma value

//

You have to create a handle to the ma 50 first (using iMA() for that) and store it to _ma_handle
Reason: