Hi. May I ask if there's anyone who knows how to write the
YTD % changed - or in points of any particular symbol ?
Example:
EURUSD YTD% changed = Current Price - December 31,2014
Thanks.
Sorry, are you talking about how to write it in code? MT4 or 5?
Cheers
Hi Vantages
Sorry, are you talking about how to write it in code? MT4 or 5?
Cheers
Thank you for your response.
Yes. Right now, I only know for monthly:
MTD = ( MarketInfo ( Symb1,MODE_BID ) - iClose ( Symb1,PERIOD_MN1,1 ) );
It would be much useful to me if I would know the YTD% & YTD points.
Thanks.
It's for MT4.
You could try something like this. I'm not at my trading PC so can't confirm if this compiles but it should do the trick.
Do the standard 4/5 digit broker check in OnInit() (after declaring the variable "point" in your declarations):
// Broker digits point=Point; if((Digits==3) || (Digits==5)) { point*=10; }
Then add this in your main iteration:
datetime EndOfYear=D'2014.12.31 00:00'; int EndOfYearShift=iBarShift(NULL,PERIOD_D1,EndOfYear); double EndOfYearClose=iClose(Symbol(),PERIOD_D1,EndOfYearShift); double CurrentPrice=MarketInfo(Symbol(),MODE_BID); double YTDPoints=( (CurrentPrice - EndOfYearClose)/point ); double YTDPercent = ( (CurrentPrice - EndOfYearClose) ) / (CurrentPrice )* 100; Comment ("Points: ", YTDPoints, " Percent: ", YTDPercent, "%");
Hope that points you in the right direction
Cheers
Stu
Hello. Thank you very much.
It was written perfectly!
Hello. Thank you very much.
It was written perfectly!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi. May I ask if there's anyone who knows how to write the
YTD % changed - or in points of any particular symbol ?
Example:
EURUSD YTD% changed = Current Price - December 31,2014
Thanks.