//+-----------+ //| TwoPerBar | //+-----------+ #property copyright "Ron Thompson" #property link "http://www.lightpatch.com/forex/" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 DodgerBlue #property indicator_color2 Magenta extern double BDistance = 14; // plus how much extern int BPeriod = 15; // Bollinger period extern double Deviation = 2; // Bollinger deviation // Bar handling datetime bartime=0; // used to determine when a bar has moved int bartick=0; // number of times bars have moved bool AlertOK=true; // can we do alerts? //---- buffers double val1[]; double val2[]; //+----------------+ //| Custom init | //+----------------+ int init() { IndicatorBuffers(2); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,233); SetIndexBuffer(0,val1); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,234); SetIndexBuffer(1,val2); } //+----------------+ //| Custom DE-init | //+----------------+ int deinit() { Print("DE-Init happened ",CurTime()); Comment(" "); } //+-----+ //| TPB | //+-----+ int start() { int i; int mybars=Bars; // bar counting if(bartime!=Time[0]) { bartime=Time[0]; bartick++; AlertOK=true; } double ma = iMA(Symbol(),0,BPeriod,0,MODE_SMA,PRICE_OPEN,0); double stddev = iStdDev(Symbol(),0,BPeriod,0,MODE_SMA,PRICE_OPEN,0); double bup0 = ma+(Deviation*stddev); double bdn0 = ma-(Deviation*stddev); for (i=mybars; i>=0; i--) { ma = iMA(Symbol(),0,BPeriod,0,MODE_SMA,PRICE_OPEN,i); stddev = iStdDev(Symbol(),0,BPeriod,0,MODE_SMA,PRICE_OPEN,i); bup0 = ma+(Deviation*stddev); bdn0 = ma-(Deviation*stddev); if( High[i]>=bup0+(BDistance*Point) ) { val2[i]=bup0+(BDistance*Point); if(i==0 && AlertOK) { Alert("Close outside by "+BDistance,Close[0],"!!!"); AlertOK=false; } } if( Low[i]<=bdn0-(BDistance*Point) ) { val1[i]=bdn0-(BDistance*Point); if(i==0 && AlertOK) { Alert("Close outside by "+BDistance,Close[0],"!!!"); AlertOK=false; } } }//for }//start
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains the highest prices of each bar
Series array that contains close prices for each bar
Series array that contains the lowest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_ARROW
Indicators Used:
Moving average indicator
Standard Deviation indicator
Custom Indicators Used:
Order Management characteristics:
Other Features:
It issuies visual alerts to the screen