|
标出周线交错X次的K线(限周图使用)
代码:
- #property indicator_chart_window
- #property indicator_buffers 1
- #property indicator_color1 Yellow
- extern int SymbolNumber=225;
- extern int HowManyKs=5;
- double Symbol_Buffer[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- SetIndexStyle(0,DRAW_ARROW,0,0);
- SetIndexArrow(0,SymbolNumber);
- SetIndexBuffer(0,Symbol_Buffer);
- SetIndexEmptyValue(0,0.0);
-
- for(int i=0;i<=IndicatorCounted();i++){
- Symbol_Buffer[i]=0;
- }
-
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int start()
- {
- int limit;
- int counted_bars=IndicatorCounted();
- if(counted_bars>0) counted_bars--;
- limit=Bars-counted_bars;
- for(int i=0; i<limit; i++){
- if(之前几个K均不相同(HowManyKs,i)==true){
- Symbol_Buffer[i]=Low[i]-(WindowPriceMax()-WindowPriceMin())/20;
- }
- }
- return(0);
- }
- //+------------------------------------------------------------------+
- bool 之前几个K均不相同(int HowManyKs,int i){
- bool 阴阳数组[20];
- bool 数组中是否有同样的K=false;
- for(int j=1;j<=HowManyKs;j++){
- 阴阳数组[j]=某索引K线阴阳(i+j-1);
- }
-
- for(j=1;j<=HowManyKs-1;j++){ //假设要判断是否有连续不同的7个K,则从索引1检查到索引6
- if(阴阳数组[j]!=阴阳数组[j+1]){}
- else if(阴阳数组[j]==阴阳数组[j+1]){数组中是否有同样的K=true;}
- }
- if(数组中是否有同样的K==true){return (false);} //出现了同样的K,搜索失败
- else if(数组中是否有同样的K==false){return (true);} //没有出现同样的K,搜索成功
-
- }
- bool 某索引K线阴阳(int i){
- if(Open[i]>Close[i]) return (false); //false代表阴
- else if(Open[i]<Close[i]) return (true); //true代表阳
- }
复制代码
|
|