Use the MA from the chart
well for starters do you want the simple moving average or the smoothed moving average? simple moving average is SMA smoothed moving average is the SMMA. Secondly the moving average is usually computed at the close unless you want the median use the following
double MoveA = iMA(NULL,1,50,0,MODE_SMA,PRICE_CLOSE,0);
double MoveA = iMA(NULL,PERIOD_M1,50,0,MODE_SMMA,PRICE_MEDIAN,0);
When I use the print function to print out MoveA, it is never very far away from the current quote. That is, it doesn't seem to be the moving average that appears on the chart.