You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, I am trying to code an indicator that draws a line of the average movement in pips. I don't know what function to use to return the applied price; Please have a look at my code below. I appreciate your help
//+------------------------------------------------------------------+
//| AverageMovement.mq4 |
//| Copyright 2015, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Matt"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//#property indicator_chart_window
#property indicator_separate_window
//#property indicator_chart_window
#property indicator_buffers 2
#property indicator_level1 3.0
#property indicator_level2 -3.0
#property indicator_level3 0.0
#property indicator_levelcolor clrDarkGray
#property indicator_levelstyle STYLE_DOT
#property indicator_width1 0
#property indicator_width2 0
#property indicator_color1 Red//wick
#property indicator_color2 Blue//wick
#include <WinUser32.mqh>
//---- stoch settings
extern string AM_SetUp = "------< AM_SetUP >------";
extern ENUM_APPLIED_PRICE applied_price = PRICE_CLOSE;
extern int Y_Bars_check = 5;
//---- buffers
double AverageMovement[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(1);
SetIndexBuffer(0,AverageMovement);
SetIndexStyle(0,DRAW_LINE,0,0);
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for(int i=0 ; i<=MathMax(Bars-1-IndicatorCounted(),1); i++)
{
double ma1 = iCustom(Symbol(),0, applied_price ,i);
double ma2 = iCustom(Symbol(),0, applied_price ,i+Y_Bars_check);
AverageMovement[i] =NormalizeDouble( MathAbs((ma1 -ma2) /MathAbs(i-( i+Y_Bars_check))),Digits)*10000 ;
}
return(0);
}
//+------------------------------------------------------------------+