Author: Dmitry Yakovlev, Russia,Omsk WM R865705290089
WPROnChart
Indicators Used
Larry William percent range indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1Uses files from the file systemIt reads information from a fileIt writes information to file
0 Views
0 Downloads
0 Favorites
WPROnChart
#property copyright "Dmitry Yakovlev, Russia,Omsk WM R865705290089"
#property link      "http://fehu.nxt.ru/   dmitryyakv@yandex.ru"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 RoyalBlue
#property indicator_width1 2
#property indicator_color2 RoyalBlue
#property indicator_width2 1
#property indicator_color3 RoyalBlue
#property indicator_width3 1
#property indicator_color4 RoyalBlue
#property indicator_width4 1

#import  "shell32.dll"           //Connect a dll (provided with Windows)             
  int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd); 
#import "user32.dll"
  int MessageBoxA(int hWnd ,string lpText,string lpCaption,int uType);
//------------------------------------------------------------------------------------------------------
extern int period=14;
extern int MA=50;
extern int Scale=100;
extern int ShowLevels=1;
extern int ShowExtremums=1;
extern string  _donate1="Äëÿ \"ñïàñèáî\" :-)";
extern string  _donate2="R865705290089";
extern string  _advert="Íàïèøó íà çàêàç,ïåðåäåëàþ.";

//---- buffers
double Signal[];
double Buffer1[];
double Buffer0[];
double Buffer5[];
double WPR[];
//----
int draw_begin1=0;
int draw_begin2=0;

int lblcnt=40;
int init()
{
   int i;
   string short_name;
   
   string tmp;
   for(int k=0;k<lblcnt;k++)
   {
      tmp="myWPRSignal"+period+"_"+k;
      ObjectDelete(tmp);
   }

   CheckDonate();

   IndicatorBuffers(4);

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, Signal);
   if(ShowLevels==1)
   {
      SetIndexStyle(1,DRAW_LINE);
      SetIndexBuffer(1, Buffer1);
      SetIndexStyle(2,DRAW_LINE);
      SetIndexBuffer(2, Buffer5);
      SetIndexStyle(3,DRAW_LINE);
      SetIndexBuffer(3, Buffer0);
   }
   else
      for(i=1;i<=3;i++) SetIndexStyle(i,DRAW_NONE);
   
   for(i=4;i<=7;i++) SetIndexStyle(i,DRAW_NONE);
   
   short_name="WPR("+period+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetIndexLabel(1,"-80%");
   SetIndexLabel(2,"-50%");
   SetIndexLabel(3,"-20%");
//----
   draw_begin1=period;
   SetIndexDrawBegin(0,draw_begin1);
   SetIndexDrawBegin(1,draw_begin1);
   SetIndexDrawBegin(2,draw_begin1);
   SetIndexDrawBegin(3,draw_begin1);
//----
   ArraySetAsSeries(WPR,true);
   return(0);
  }

void deinit()
{
   string tmp;
   for(int k=0;k<lblcnt;k++)
   {
      tmp="myWPRSignal"+period+"_"+k;
      ObjectDelete(tmp);
   }
}

int start()
  {
   int    i,k;
   int    counted_bars=IndicatorCounted();
   double price;
//----
   if(Bars<=draw_begin2) return(0);
   if(ArraySize(WPR)!=Bars) ArrayResize(WPR,Bars);
   //---- initial zero
   if(counted_bars<1)
      for(i=1;i<=draw_begin2;i++)
      {
         Signal[Bars-i]=0;
         Buffer0[Bars-i]=0;
         Buffer1[Bars-i]=0;
         Buffer5[Bars-i]=0;
         WPR[Bars-i]=0;
      }
   
   double kk=Point*Scale/100;
   int limit=Bars-counted_bars;
   for(i=0; i<limit; i++)
   {
      WPR[i]=iWPR(Symbol(),0,period,i);
      Signal[i]=iMA(Symbol(),0,MA,0,MODE_EMA,PRICE_MEDIAN,i)+(WPR[i]+50)*kk;
      if(ShowLevels==1)
      {
         Buffer1[i]=iMA(Symbol(),0,MA,0,MODE_EMA,PRICE_MEDIAN,i)+30*kk;
         Buffer5[i]=iMA(Symbol(),0,MA,0,MODE_EMA,PRICE_MEDIAN,i);
         Buffer0[i]=iMA(Symbol(),0,MA,0,MODE_EMA,PRICE_MEDIAN,i)-30*kk;
      }
   }
   
   //<-signal
   if(ShowExtremums==1)
   {
      int wpr;
      double wpr0,wpr1,wpr2;
      i=0;k=0;
      while(k<lblcnt && i<Bars)
      {
         wpr=0;
         while(i<Bars && wpr==0)
         {
            wpr0=iWPR(Symbol(),0,period,i+0);
            wpr1=iWPR(Symbol(),0,period,i+1);
            wpr2=iWPR(Symbol(),0,period,i+2);
            if(wpr0>wpr1 && wpr2>wpr1) wpr=+1;
            if(wpr0<wpr1 && wpr2<wpr1) wpr=-1;
            if(wpr!=0) break;
            i++;
         }

         string tmp="myWPRSignal"+period+"_"+k;
         ObjectDelete(tmp);
         if(wpr==+1)
         {
            ObjectCreate(tmp,OBJ_ARROW,0,Time[i],Low[i]);
            ObjectSet(tmp,OBJPROP_ARROWCODE,108);
            ObjectSet(tmp,OBJPROP_COLOR,Lime);
            k++;
         }
         if(wpr==-1)
         {
            ObjectCreate(tmp,OBJ_ARROW,0,Time[i],High[i]+(WindowPriceMax()-WindowPriceMin())/10);
            ObjectSet(tmp,OBJPROP_ARROWCODE,108);
            ObjectSet(tmp,OBJPROP_COLOR,Red);
            k++;
         }
         i+=1;
      }
   }
   //->
   
   return(0);
}

void CheckDonate()
{
   int fd=0; string pay="0"; datetime dt=0;
   string fn="WPROC.txt";
   fd=FileOpen(fn,FILE_READ|FILE_CSV,";");
   if(fd>=1)
   {
      pay=FileReadString(fd); if(pay!="0" && pay!="1") pay="0";
      dt=StrToTime(FileReadString(fd));
   }
   else
   {
      dt=TimeCurrent();
      fd=FileOpen(fn,FILE_WRITE|FILE_CSV,";");
      FileWrite(fd,"0",TimeToStr(dt,TIME_DATE));
   }
   FileClose(fd);
   
   if(pay=="0" && (TimeCurrent()-dt)>10*24*60*60) // 5 äíåé
   {
      if(MessageBoxA(0,"Åñëè Âàì ïîíðàâèëñÿ èíäèêàòîð On Chart WPR,\n õîòèòå ïîìî÷ü àâòîðó ìàòåðèàëüíî?","Âîïðîñ",4)==6)
      {
         ShellExecuteA(0,"Open","iexplore.exe","wmk:payto?Purse=R865705290089&Amount=100&Desc=Indicator&BringToFront=Y&ExecEvenKeeperIsOffline=Y","",7);
         pay="1";
      }
      dt=TimeCurrent();
      
      fd=FileOpen(fn,FILE_WRITE|FILE_CSV,";");
      FileWrite(fd,pay,TimeToStr(dt,TIME_DATE));
      FileClose(fd);
   }
   FileClose(fd);
}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---