#property indicator_chart_window
中国国情国力extern int ma1per= 10; extern int ma2per= 20;
extern int mamode= 0;
double up[];
double dn[];
double dnok[];
double dir[];
double upBuffer[];
double dnBuffer[];
/
/+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll();
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int counted_bars= IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit= Bars-counted_bars;
贞元集团for(int i=limit; i>1; i--){
//--i为三K线中的高棒时
if(i==iHighest(NULL, 0, MODE_HIGH, 3, i-1)){ // (含未来)
//--查左框边
for(int upLeft=i; upLeft<Bars; upLeft++){
if(Low[upLeft+1]<Low[upLeft]){
upLeft= upLeft+1;
break;
}
}
//--查右框边
for(int upRight=i; upRight>=0; upRight--){
if(Low[upRight-1]<Low[upRight]){
upRight= upRight-1;
break;
}
}
int count= 0;
for(int j=i-1; j>=0; j--){
if(Close[j]>=iMA(NULL, 0, ma1per, 0, mamode, PRICE_CLOSE, j))马未都说玉
count= 0;
else
count++;
//--超过三 则跳出
if(count>=3)
break;
}
//--
if(upRight!=i && i==iHighest(NULL, 0, MODE_HIGH, upLeft-upRight, upRight) && count>=3 && iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, i)>iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, i)){
drawline("up"+Time[upLeft], Time[upLeft], MathMin(Low[upLeft],Low[upRight]), Time[upRight], High[i], Red);
i= upRight; // 顶部
}
}
}
//--m为三K线中的低棒时
for(int m=limit; m>1; m--){
if(m==iLowest(NULL, 0, MODE_LOW, 3, m-1)){
for(int downLeft=m; downLeft<Bars; downLeft++){
if(High[downLeft+1]>High[downLeft]){
downLeft= downLeft+1;
break;
}
}
for(int downRight=m; downRight>=0; downRight--){
if(High[downRight-1]>High[downRight]){
downRight= downRight-1;
break;
}
}
if(downRight!=m && m==iLowest(NULL, 0, MODE_LOW, downLeft-downRight, downRight) && iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, m)<iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, m)){
drawline("down"+Time[downLeft], Time[downLeft], MathMax(High[downLeft], High[downRight]), Time[downRight], Low[m], Blue);
m= downRight; // 底部
}
}
}
return(0);
}
//+-------------------------------------------------------
-----------+
void drawline(string linename, int t1, double price1, int t2, double price2, int lincolor)
{
se18mmif(ObjectFind(linename)<0){
ObjectCreate(linename, OBJ_RECTANGLE, 0, t1, price1, t2, price2);
//ObjectSet(linename, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(linename, OBJPROP_COLOR, lincolor);
//ObjectSet(linename, OBJPROP_RAY, false);
}
else{
ObjectSet(linename, OBJPROP_TIME1, t1);
ObjectSet(linename, OBJPROP_PRICE1, price1);
iec标准ObjectSet(linename, OBJPROP_TIME2, t2);
ObjectSet(linename, OBJPROP_PRICE2, price2);
}
return;
}