//+------------------------------------------------------------------+ //|Simple counter-indicated trader for AUD/USD | //+------------------------------------------------------------------+ #property copyright "Ron T" #property link "http://www.lightpatch.com" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 White //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //|------------------------------------------------------------------| int init() { SetIndexStyle(0,DRAW_ARROW); SetIndexBuffer(0, ExtMapBuffer1); SetIndexArrow(0,234); //down red SetIndexStyle(1,DRAW_ARROW); SetIndexBuffer(1, ExtMapBuffer2); SetIndexArrow(1,233); //up white return(0); } //+------------------------------------------------------------------+ //| Cursor indicator deinit | //+------------------------------------------------------------------+ int deinit() { int i; for( i=0; i<Bars; i++ ) ExtMapBuffer1[i]=0; for( i=0; i<Bars; i++ ) ExtMapBuffer2[i]=0; return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { double curTYP=0; double oldTYP=0; double change=0; int ticket=1; Print ("tick at ",CurTime()); //trades no more often than once an hour + 1 minute if(CurTime()-OrderOpenTime()<3660) return(0); oldTYP=(High[2]+Low[2]+Close[2])/3; curTYP=(High[1]+Low[1]+Close[1])/3; // buffer1 Red down // buffer2 White up change=curTYP-oldTYP; if ( change < -0.0005 ) { ExtMapBuffer1[1]=curTYP; ExtMapBuffer2[2]=0; ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,0,Ask-10*Point,Ask+10*Point,"ASD/USD BUY order",525125,0,Green); if(ticket<0) { Print("OrderSend BUY failed with error #",GetLastError()); return(0); } } if ( change > 0.0005 ) { ExtMapBuffer1[1]=0; ExtMapBuffer2[2]=curTYP; ticket=OrderSend(Symbol(),OP_SELL,0.1,Ask,0,Ask+10*Point,Ask-10*Point,"ASD/USD SELL order",525525,0,Red); if(ticket<0) { Print("OrderSend SELL failed with error #",GetLastError()); return(0); } } return(0); }
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_ARROW
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
It automatically opens orders when conditions are reached
Other Features: