Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
as I'm not well-versed in MT4 coding I need help with a simple formula called Buff MA; I've the corresponding formula in Metastock language as the following one:
Buff MA helps in determining the most probable side to trade... when price is above Buff and aligned with it* only long positions are allowed... viceversa for short ones.
*(that's if Buff and price both are upward it's OK to be long... viceversa for shorting)
Thanks a lot
ontherun
ps: I've been looking for the Sum() and Cum() corresponding functions in the MetaEditor but I've not found anything related to those functions...
Someone familiar with Metastock may correct me, but by the looks of it, you have a "BUFF" function that looks at the 32 most recent bars, adds up the volume times the close price for them, and divides that by the total volume for those bars. It could look like the following in MT4:
PHP Code:
double buff()
{
double sum = 0;
double v = 0;
for ( int i = 0; i < 32; i++ ) {
sum += Volume[ i ] * Close[ i ];
v += Volume[ i ];
}
return( sum / v );
}
no, right; it will need to compute the value relative to prior bars, and assign BUFF with the values.... like
PHP Code:
int start() { for ( int bar = Bars - IndicatorCounted(); bar >= 0; bar-- ) { indicate( bar ); } }
void indicate(int bar) { double sum=0; double v=0; for ( int i=0; i<32; i++ ) { sum += Volume[ bar + i ] * Close[ bar + i ]; v += Volume[ bar + i ]; } BUFF[ bar ] = sum/v; }
Just replace your start() function with the above two functions, and it should do the trick.
Last edited by ralph.ronnquist; 09-11-2007 at 10:53 AM.
The Buff formula with your modification plots correct as for the calculated values (I compare them to those plotted by the Buff in Metastock) but it doesn't update... that's it stops plotting just at the bar developing the moment I attach it to the chart.