论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:2274回复:12
zh1128
注册时间2006-11-28
秃鹫老师!再请帮忙!
楼主发表于:2007-11-29 08:59只看该作者倒序浏览
1楼 电梯直达
电梯直达
emoji-image 在主图出现变色K线!MA10,20,40,80,160,320;6条均线空头排列K线是黄色K线;6条均线多头排列K线变红色。
TK29帖子1楼右侧xm竖版广告90-240
个性签名

韬客社区www.talkfx.co

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
秃鹫
注册时间2007-05-25
发表于:2007-12-02 12:56只看该作者
2楼
#property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 Yellow #property indicator_color3 Green extern int 显示均线=18; extern int 条件均线1=10; extern int 条件均线2=20; extern int 条件均线3=40; extern int 条件均线4=80; extern int 条件均线5=160; extern int 条件均线6=320; double duo; double kong; double qita; int init() { SetIndexBuffer(0,duo); SetIndexBuffer(1,kong); SetIndexBuffer(2,qita); SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); IndicatorDigits(Digits); return(0); } bool duotou(int t) { if( iMA(NULL,0,条件均线1,0,MODE_SMA,PRICE_CLOSE,t)>=iMA(NULL,0,条件均线2,0,MODE_SMA,PRICE_CLOSE,t) && iMA(NULL,0,条件均线2,0,MODE_SMA,PRICE_CLOSE,t)>=iMA(NULL,0,条件均线3,0,MODE_SMA,PRICE_CLOSE,t) && iMA(NULL,0,条件均线3,0,MODE_SMA,PRICE_CLOSE,t)>=iMA(NULL,0,条件均线4,0,MODE_SMA,PRICE_CLOSE,t) && iMA(NULL,0,条件均线4,0,MODE_SMA,PRICE_CLOSE,t)>=iMA(NULL,0,条件均线5,0,MODE_SMA,PRICE_CLOSE,t) && iMA(NULL,0,条件均线5,0,MODE_SMA,PRICE_CLOSE,t)>=iMA(NULL,0,条件均线6,0,MODE_SMA,PRICE_CLOSE,t) ) return(true); else return(false); } bool kongtou(int t) { if( iMA(NULL,0,条件均线1,0,MODE_SMA,PRICE_CLOSE,t)<=iMA(NULL,0,条件均线2,0,MODE_SMA,PRICE_CLOSE,t) && iMA(NULL,0,条件均线2,0,MODE_SMA,PRICE_CLOSE,t)<=iMA(NULL,0,条件均线3,0,MODE_SMA,PRICE_CLOSE,t) && iMA(NULL,0,条件均线3,0,MODE_SMA,PRICE_CLOSE,t)<=iMA(NULL,0,条件均线4,0,MODE_SMA,PRICE_CLOSE,t) && iMA(NULL,0,条件均线4,0,MODE_SMA,PRICE_CLOSE,t)<=iMA(NULL,0,条件均线5,0,MODE_SMA,PRICE_CLOSE,t) && iMA(NULL,0,条件均线5,0,MODE_SMA,PRICE_CLOSE,t)<=iMA(NULL,0,条件均线6,0,MODE_SMA,PRICE_CLOSE,t) ) return(true); else return(false); } int start() { double temp0,temp1; int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=limit; i>=0; i--) { duo=EMPTY_VALUE; kong=EMPTY_VALUE; qita=EMPTY_VALUE; temp0=iMA(NULL,0,显示均线,0,MODE_SMA,PRICE_CLOSE,i); temp1=iMA(NULL,0,显示均线,0,MODE_SMA,PRICE_CLOSE,i+1); if(duotou(i)) {duo=temp0; if(!duotou(i+1)) duo[i+1]=temp1;} else if(kongtou(i)) {kong=temp0; if(!kongtou(i+1)) kong[i+1]=temp1;} else {qita=temp0; if( duotou(i+1) || kong[i+1]) qita[i+1]=temp1;} } return(0); }bian.gifbian.gif
个性签名

顺势

秃鹫
注册时间2007-05-25
发表于:2007-12-02 13:30只看该作者
3楼
上图中, 当均线系统多头排列时,此均线为红色 当均线系统空头排列时,此均线为黄色 当均线系统既不是多头也不是空头时,此均线为绿色 个人觉得 这样的颜色转换条件太多,失去了渐变过程,一下子全部变红色,一下子又全部变绿色,变化太突然 下面这样是不是会好一些: 当5天金叉10天时,5天线变红色,死叉则5天线变绿色,10天线不变色 当10金叉20时,10天线变红色,死叉则10天线变绿色,20天线不变色 以下类推。。。 源码如下#property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 Yellow extern int 均线=18; double duo; double kong; int init() { SetIndexBuffer(0,duo); SetIndexBuffer(1,kong); SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexDrawBegin(0,均线); SetIndexDrawBegin(1,均线); IndicatorDigits(Digits); return(0); } int start() { double temp0,temp1; int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=limit; i>=0; i--) { duo=EMPTY_VALUE; kong=EMPTY_VALUE; temp0=iMA(NULL,0,均线,0,MODE_SMA,PRICE_CLOSE,i); temp1=iMA(NULL,0,均线,0,MODE_SMA,PRICE_CLOSE,i+1); if(iMA(NULL,0,均线,0,MODE_SMA,PRICE_CLOSE,i)>=iMA(NULL,0,均线*2,0,MODE_SMA,PRICE_CLOSE,i)) {duo=temp0; duo[i+1]=temp1;} else {kong=temp0; kong[i+1]=temp1;} } return(0); } [ 本帖最后由 秃鹫 于 2007-12-2 21:40 编辑 ]
个性签名

顺势

zh1128
注册时间2006-11-28
楼主发表于:2007-12-03 02:31只看该作者
4楼
emoji-image 谢谢秃鹫老师!不过我想在蜡烛线变颜色是怎样写?
个性签名

韬客社区www.talkfx.co

秃鹫
注册时间2007-05-25
发表于:2007-12-03 10:22只看该作者
5楼
原帖由 zh1128 于 2007-12-3 10:31 发表 http://www.talkforex.com/images/common/back.gif emoji-image 谢谢秃鹫老师!不过我想在蜡烛线变颜色是怎样写?
让蜡烛线变颜色,俺和你一样,也不会。 “老师”实在不敢当,下次请称呼“秃鹫同学”。谢谢!
zh1128
注册时间2006-11-28
楼主发表于:2007-12-03 11:33只看该作者
6楼
称呼“老师”当之无愧!emoji-image 下面是我收集蜡烛线变颜色的指标!老师看看能有用?
zh1128
注册时间2006-11-28
楼主发表于:2007-12-03 11:33只看该作者
7楼
//+------------------------------------------------------------------+ //| Stoch Candle OverBought-Sold.mq4 | //| Copyright ?2006, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright ?2006, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" //+------------------------------------------------------------------+ //| StochCandles.mq4 | //| Colored Candles, based on Stochastic Signal. | //+------------------------------------------------------------------+ #property copyright "Copyright ?2007, Christof Risch (iya)" #property link "http://www.forexfactory.com/showthread.php?t=13321" #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 White #property indicator_color2 Lime #property indicator_color3 White #property indicator_color4 Lime #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 3 #property indicator_width4 3 #property indicator_color5 Orange #property indicator_color6 Orange #property indicator_color7 Orange #property indicator_color8 Orange #property indicator_width5 1 #property indicator_width6 1 #property indicator_width7 3 #property indicator_width8 3 //---- stoch settings extern double Stoch_K = 100.0, Stoch_D = 3.0, Stoch_Slowing = 3.0, Upper_Level = 80, Lower_Level = 20; //---- input parameters extern color BarUp = White, BarDown = Lime, BullCandle = White, BearCandle = Lime, BarUp2 = Orange, BarDown2 = Orange, MedCandle = Orange, MedCandle2 = Orange; extern int BarWidth = 1, CandleWidth = 3, BarWidth2 = 1, CandleWidth2 = 3; //---- buffers double Buffer1; double Buffer2; double Buffer3; double Buffer4; double Buffer5; double Buffer6; double Buffer7; double Buffer8; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_HISTOGRAM,0,BarWidth,BarUp); SetIndexStyle(1,DRAW_HISTOGRAM,0,BarWidth,BarDown); SetIndexStyle(2,DRAW_HISTOGRAM,0,CandleWidth,BullCandle); SetIndexStyle(3,DRAW_HISTOGRAM,0,CandleWidth,BearCandle); SetIndexBuffer(0, Buffer1); SetIndexBuffer(1, Buffer2); SetIndexBuffer(2, Buffer3); SetIndexBuffer(3, Buffer4); SetIndexStyle(4,DRAW_HISTOGRAM,0,BarWidth2,BarUp2); SetIndexStyle(5,DRAW_HISTOGRAM,0,BarWidth2,BarDown2); SetIndexStyle(6,DRAW_HISTOGRAM,0,CandleWidth2,MedCandle ); SetIndexStyle(7,DRAW_HISTOGRAM,0,CandleWidth2,MedCandle2 ); SetIndexBuffer(4, Buffer5); SetIndexBuffer(5, Buffer6); SetIndexBuffer(6, Buffer7); SetIndexBuffer(7, Buffer8); return(0); } //+------------------------------------------------------------------+ double Stoch_Main (int i = 0) {return(iStochastic(NULL,0,Stoch_K,Stoch_D,Stoch_Slowing,MODE_SMA,0,MODE_MAIN, i));} //double Stoch_Signal (int i = 0) {return(iStochastic(NULL,0,Stoch_K,Stoch_D,Stoch_Slowing,MODE_SMA,0,MODE_SIGNAL,i));} //+------------------------------------------------------------------+ bool IsMedCandle(int i = 0) { if(i>=Bars) return(false); if(High==Low) return(IsMedCandle(i+1)); return(Buffer5==High && Buffer6==Low); } //+------------------------------------------------------------------+ void SetBullCandle(int i = 0) { Buffer1 = High; Buffer2 = Low; Buffer3 = MathMax(Open,Close); Buffer4 = MathMin(Open,Close); } //+------------------------------------------------------------------+ void SetBearCandle(int i = 0) { Buffer1 = Low; Buffer2 = High; Buffer3 = MathMin(Open,Close); Buffer4 = MathMax(Open,Close); } //+------------------------------------------------------------------+ void SetMedCandle(int i = 0) { Buffer5 = Low; Buffer6 = High; Buffer7 = MathMin(Open,Close); Buffer8 = MathMax(Open,Close); } //+------------------------------------------------------------------+ void SetMedCandle2(int i = 0) { Buffer5 = Low; Buffer6 = High; Buffer7 = MathMin(Open,Close); Buffer8 = MathMax(Open,Close); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { for(int i = MathMax(Bars-1-IndicatorCounted(),1); i >= 0; i--) { // bool bull = Close > Open, // bear = Close < Open; double stochMain = Stoch_Main(i), Med = Stoch_Main(i); bool bull = (stochMain < Lower_Level), bear = (stochMain > Upper_Level ); Med = ((stochMain < Upper_Level )&&(stochMain > 20)); if(!bull && !bear && !Med) { bull = (stochMain < Lower_Level); bear = (stochMain > Upper_Level ); Med = ((stochMain < Upper_Level )&&(stochMain > Lower_Level)); } if (bull) SetBullCandle(i); else if (bear) SetBearCandle(i); else if (IsMedCandle(i+1)) SetMedCandle(i); else SetMedCandle2(i); } return(0); } //+------------------------------------------------------------------+
秃鹫
注册时间2007-05-25
发表于:2007-12-03 11:52只看该作者
8楼
看到变化了,又长了见识,谢谢!俺要好好学习3Q.gif3Q.gif
zh1128
注册时间2006-11-28
楼主发表于:2007-12-03 11:56只看该作者
9楼
我看不懂?能解释吗?
发表于:2009-06-16 13:21只看该作者
10楼
绿色好像是在出,白线好像可以买了。但在2008年10份的白线出现时却不能买(4h)
shenziming
注册时间2009-02-24
发表于:2009-07-05 12:15只看该作者
11楼
这是根据KD线指标的多空转换编写,替代原来K线的指标。这指标俺也有,但只有两色。另外还有根据ADX交叉变色的。
shenziming
注册时间2009-02-24
发表于:2009-07-05 12:22只看该作者
12楼
我也想请老师帮个忙,能不能把lsma均线指标编成在附图栏里显示的光谱指标。或者是主图表中的变色K线。源码附录在后面。谢谢老师。
shenziming
注册时间2009-02-24
发表于:2009-07-05 12:22只看该作者
13楼
#property copyright "Copyright ?2005" #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 DarkKhaki #property indicator_color2 SeaGreen #property indicator_color3 Maroon //---- buffers double ExtMapBuffer1; double ExtMapBuffer2; double ExtMapBuffer3; int width; extern int Rperiod = 25; extern int Draw4HowLongg = 5000; int Draw4HowLong; int shift; int i; int loopbegin; double sum; int length; double lengthvar; double tmp ; double wt; int c; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 2 additional buffers are used for counting. IndicatorBuffers(5); //---- drawing settings SetIndexBuffer(2,ExtMapBuffer1); SetIndexBuffer(1,ExtMapBuffer2); SetIndexBuffer(0,ExtMapBuffer3); SetIndexBuffer(3,sum); SetIndexBuffer(4,wt); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,3); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3); //---- initialization done return(0); } int start() { Draw4HowLong = Bars-Rperiod - 5; length = Rperiod; loopbegin = Draw4HowLong - length - 1; for(shift = loopbegin; shift >= 0; shift--) { sum[1] = 0; for(i = length; i >= 1 ; i--) { lengthvar = length + 1; lengthvar /= 3; tmp = 0; tmp = ( i - lengthvar)*Close[length-i+shift]; sum[1]+=tmp; } wt[shift] = sum[1]*6/(length*(length+1)); //========== COLOR CODING =========================================== ExtMapBuffer3[shift] = wt[shift]; //red ExtMapBuffer2[shift] = wt[shift]; //green ExtMapBuffer1[shift] = wt[shift]; //yellow // for(c=loopbegin;c==shift;c++) // { if (wt[shift+1] > wt[shift]) { ExtMapBuffer2[shift+1] = EMPTY_VALUE; // ObjectCreate("smiley_face", OBJ_ARROW, 0, Time[shift], Low[shift]-Point*20); // Print("time= ",Time[shift]); // ObjectSet("smiley_face", OBJPROP_ARROWCODE, 242); // ObjectSet("smiley_face", OBJPROP_COLOR , Red); // ObjectSet("smiley_face", OBJPROP_WIDTH , 1); // ObjectsRedraw(); //ExtMapBuffer3[shift+1] = EMPTY_VALUE; //ExtMapBuffer3[shift+1] = EMPTY_VALUE; } else if (wt[shift+1] < wt[shift]) { ExtMapBuffer1[shift+1] = EMPTY_VALUE; //-1 red/greem tight //ExtMapBuffer3[shift+1] = EMPTY_VALUE; } else { ExtMapBuffer1[shift+1]=CLR_NONE;//EMPTY_VALUE; ExtMapBuffer2[shift+1]=CLR_NONE;//EMPTY_VALUE; } } return(0); } //+------------------------------------------------------------------+

本站免责声明:

1、本站所有广告及宣传信息均与韬客无关,如需投资请依法自行决定是否投资、斟酌资金安全及交易亏损风险;

2、韬客是独立的、仅为投资者提供交流的平台,网友发布信息不代表韬客的观点与意思表示,所有因网友发布的信息而造成的任何法律后果、风险与责任,均与韬客无关;

3、金融交易存在极高法律风险,未必适合所有投资者,请不要轻信任何高额投资收益的诱导而贸然投资;投资保证金交易导致的损失可能超过您投入的资金和预期。请您考虑自身的投资经验及风险承担能力,进行合法、理性投资;

4、所有投资者的交易帐户应仅限本人使用,不应交由第三方操作,对于任何接受第三方喊单、操盘、理财等操作的投资和交易,由此导致的任何风险、亏损及责任由投资者个人自行承担;

5、韬客不隶属于任何券商平台,亦不受任何第三方控制,韬客不邀约客户投资任何保证金交易,不接触亦不涉及投资者的任何资金及账户信息,不代理任何交易操盘行为,不向客户推荐任何券商平台,亦不存在其他任何推荐行为。投资者应自行选择券商平台,券商平台的任何行为均与韬客无关。投资者注册及使用韬客即表示其接受和认可上述声明,并自行承担法律风险。

版权所有:韬客外汇论坛 www.talkfx.com 联络我们:[email protected]