Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #property indicator_chart_window
- #property indicator_buffers 2
- #property indicator_width1 0
- #property indicator_color1 Lime
- #property indicator_width2 0
- #property indicator_color2 Red
- extern int qual=6;
- extern int len=30;
- extern int Distance = 1;
- extern int Countbars=1000;
- input int TriggerCandle = 1;
- input bool EnableNativeAlerts = true;
- input bool EnableSoundAlerts = true;
- input bool EnableEmailAlerts = true;
- input string AlertEmailSubject = "";
- input string AlertText = "";
- input string SoundFileName = "alert.wav";
- datetime LastAlertTime = D'01.01.1970';
- int LastAlertDirection = 0;
- double Up[];
- double Dn[];
- double point;
- double bs=0;
- double index=0;
- double bindex=0;
- double sindex=0;
- double length=0;
- double ret=0;
- int init() {
- if(Digits==3 || Digits==5) {
- point=10*Point;
- }
- else{
- point=Point;
- }
- IndicatorBuffers(2);
- SetIndexStyle(0, DRAW_ARROW);
- SetIndexBuffer(0, Up);
- SetIndexArrow(0,108);
- SetIndexStyle(1, DRAW_ARROW);
- SetIndexBuffer(1, Dn);
- SetIndexArrow(1,108);
- return (0);
- }
- int deinit() {
- return (0);
- }
- int start() {
- bool TurnedUp = false;
- bool TurnedDown = false;
- double highest,lowest;
- int i,limit,limit2;
- int counted_bars = IndicatorCounted();
- if(counted_bars < 0)
- return(-1);
- limit=Countbars-counted_bars;
- if (i> limit2)
- limit2= i;
- if (limit2 <Countbars-1)
- limit =Countbars- 1;
- for( i=limit; i>=0; i--) {
- if (Close[i]>Close[i+4]){
- bindex=bindex+1;
- }
- if(Close[i]<Close[i+4]){
- sindex=sindex+1;
- }
- ret=0;
- index=0;
- if ((bindex>qual) && (Close[i]<Open[i])&& (High[i]>=High[iHighest(Symbol(),0,MODE_HIGH,len,i+1)])) {
- index=1;
- bindex=0;
- ret=-1;
- }
- if ((sindex>qual) && (Close[i]>Open[i])&& (Low[i]<= Low[iLowest(Symbol(),0,MODE_LOW,len,i+1)])) {
- index=-1;
- sindex=0;
- ret=1;
- }
- if (ret==1 && i!=0){
- Up[i]=Low[i]-Distance*point;
- }
- if (ret==-1 && i!=0){
- Dn[i]=High[i]+Distance*point;
- }
- }
- if (i> limit2)
- limit2= i;
- if (((TriggerCandle > 0) && (Time[0] > LastAlertTime)) || (TriggerCandle == 0))
- {
- string Text;
- // Up Arrow Alert
- if (( Up[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
- {
- Text = AlertText + "ACT: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - ACT.";
- if (EnableNativeAlerts) Alert(Text);
- if (EnableEmailAlerts) SendMail(AlertEmailSubject + "up", Text);
- if (EnableSoundAlerts) PlaySound(SoundFileName);
- LastAlertTime = Time[0];
- LastAlertDirection = 1;
- }
- // Down Arrow Alert
- if ((Dn[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))
- {
- Text = AlertText + "ACT: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - ACT .";
- if (EnableNativeAlerts) Alert(Text);
- if (EnableEmailAlerts) SendMail(AlertEmailSubject + "CCI Arrows Alert", Text);
- if (EnableSoundAlerts) PlaySound(SoundFileName);
- LastAlertTime = Time[0];
- LastAlertDirection = -1;
- }
- }
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement