//+------------------------------------------------------------------+ //| SpreadPaintBar.mq4 | //| Copyright © 2008, Trading Automatics Ltd | //| http://www.tradingautomatics.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, Trading Automatics Ltd" #property link "http://www.tradingautomatics.com" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red //---- input parameters extern int Percent = 25; //---- buffers double up[]; double dn[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_HISTOGRAM); SetIndexBuffer(0, up); SetIndexEmptyValue(0, 0); SetIndexStyle(1, DRAW_HISTOGRAM); SetIndexBuffer(1, dn); SetIndexEmptyValue(1, 0); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars = IndicatorCounted(); double spread; double band; int limit = Bars - counted_bars; if(counted_bars == 0) { limit = Bars - 1; } //---- for(int i = 0; i < limit; i++) { spread = High[i] - Low[i]; band = spread * Percent * 0.01; up[i] = 0; dn[i] = 0; if(Open[i] < Low[i] + band && Close[i] > High[i] - band) { dn[i] = Low[i]; up[i] = High[i]; } else if(Close[i] < Low[i] + band && Open[i] > High[i] - band) { up[i] = Low[i]; dn[i] = High[i]; } } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains close prices for each bar
Series array that contains open prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: