mt4mt4自动显示高低点点价格指标

扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
精选MT4指标280个
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口您现在的位置:>>
>>正文内容
Price Alert (价格预警指标MT4 MT5指标)[MT5公式]
该指标适用于MT4和MT5。
当价格到达交易商设置的价位时,会发出声音示警的指标。有三种类型的示警:第一种用于价格上涨至设定价位的上方时(在图表上显示为绿线),第二种用于价格下跌至设定价位的下方时(在图表上显示为红线),第三种用于价格接近某一确切的价位时(显示为黄线)。所有的示警在被触发之后,都会关闭,但当设定新值之后,可以再次开启。如果您使用电子邮件示警功能,那么不要忘记在您的MetaTrader平台选项窗口设置电子邮件设置。
输入参数:
SoundWhenPriceGoesAbove (默认 = 0.0) & 如果价格上涨至此值的上方将触发示警。
SoundWhenPriceGoesBelow (默认 = 0.0) & 如果价格下跌至此值的下方将触发示警。
SoundWhenPriceIsExactly (默认 = 0.0) & 如果价格到达此值时将触发示警。
SendEmail (默认 = false) & 如果选择为true且正确的电子邮件设置已经设置在MetaTrader选项窗口,那么示警将发送到设置的电子邮箱地址。
该指标不能用作一种交易系统,它不产生任何信号。无论何时您希望收到某一新价位的通知时,您都可以使用该指标。之后,您可以利用您的时间在市场上做一些您想做的事情。如果您不想使用它们中的某些,您可以将输入参数设置为零。
标签:MT4 MT5指标源码
//+------------------------------------------------------------------+
PriceAlert.mq4 |
Copyright ? ,
Issues sound alerts when price reaches certain levels. |
modded by Mn ------------------------
//+------------------------------------------------------------------+
#property copyright &&
#property link
#property indicator_chart_window
extern double SoundWhenPriceGoesAbove = 0;
extern double SoundWhenPriceGoesBelow = 0;
extern double SoundWhenPriceIsExactly = 0;
extern bool SendEmail = //If true e-mail is sent to the e-mail address set in your MT4. E-mail SMTP Server settings should also be configured in your MT4
//+------------------------------------------------------------------+
//| Custom indicator initialization function
//+------------------------------------------------------------------+
int init()
if (SoundWhenPriceIsExactly & 0)
ObjectCreate(&SoundWhenPriceIsExactly&, OBJ_HLINE, 0, Time[0], SoundWhenPriceIsExactly);
ObjectSet(&SoundWhenPriceIsExactly&, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(&SoundWhenPriceIsExactly&, OBJPROP_COLOR, Yellow);
ObjectSet(&SoundWhenPriceIsExactly&, OBJPROP_WIDTH, 1);
if (SoundWhenPriceGoesAbove & 0)
ObjectCreate(&SoundWhenPriceGoesAbove&, OBJ_HLINE, 0, Time[0], SoundWhenPriceGoesAbove);
ObjectSet(&SoundWhenPriceGoesAbove&, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(&SoundWhenPriceGoesAbove&, OBJPROP_COLOR, Green);
ObjectSet(&SoundWhenPriceGoesAbove&, OBJPROP_WIDTH, 1);
if (SoundWhenPriceGoesBelow & 0)
ObjectCreate(&SoundWhenPriceGoesBelow&, OBJ_HLINE, 0, Time[0], SoundWhenPriceGoesBelow);
ObjectSet(&SoundWhenPriceGoesBelow&, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(&SoundWhenPriceGoesBelow&, OBJPROP_COLOR, Red);
ObjectSet(&SoundWhenPriceGoesBelow&, OBJPROP_WIDTH, 1);
return(0);
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function
//+------------------------------------------------------------------+
int deinit()
ObjectDelete(&SoundWhenPriceIsExactly&);
ObjectDelete(&SoundWhenPriceGoesAbove&);
ObjectDelete(&SoundWhenPriceGoesBelow&);
return(0);
//+------------------------------------------------------------------+
//| Custom indicator iteration function
//+------------------------------------------------------------------+
int start()
// added by Mn -----------------------------------------------------------
if (ObjectGet(&SoundWhenPriceGoesAbove&, 1) != SoundWhenPriceGoesAbove)
SoundWhenPriceGoesAbove = ObjectGet(&SoundWhenPriceGoesAbove&, 1);
if (ObjectGet(&SoundWhenPriceGoesBelow&, 1) != SoundWhenPriceGoesBelow)
SoundWhenPriceGoesBelow = ObjectGet(&SoundWhenPriceGoesBelow&, 1);
if (ObjectGet(&SoundWhenPriceIsExactly&, 1) != SoundWhenPriceIsExactly)
SoundWhenPriceIsExactly = ObjectGet(&SoundWhenPriceIsExactly&, 1);
// added by Mn -----------------------------------------------------------
if ((Ask & SoundWhenPriceGoesAbove) && (SoundWhenPriceGoesAbove & 0))
Alert(&Price above the alert level.&);
PlaySound(&alert.wav&);
SendMail(&Price for & + Symbol() +
& above the alert level & + Ask, &Price for & + Symbol() +
& reached & + Ask + & level, which is above your alert level of & + SoundWhenPriceGoesAbove);
ObjectDelete(&SoundWhenPriceGoesAbove&);
SoundWhenPriceGoesAbove = 0;
if ((Bid & SoundWhenPriceGoesBelow) && (SoundWhenPriceGoesBelow & 0))
Alert(&Price below the alert level.&);
PlaySound(&alert.wav&);
SendMail(&Price for & + Symbol() +
& below the alert level & + Bid, &Price for & + Symbol() +
& reached & + Bid + & level, which is below your alert level of & + SoundWhenPriceGoesBelow);
ObjectDelete(&SoundWhenPriceGoesBelow&);
SoundWhenPriceGoesBelow = 0;
if ((Bid == SoundWhenPriceIsExactly) || (Ask == SoundWhenPriceIsExactly))
Alert(&Price is exactly at the alert level.&);
PlaySound(&alert.wav&);
SendMail(&Price for & + Symbol() +
& exactly at the alert level & + Ask, &Price for & + Symbol() +
& reached & + Ask + &/& + Bid + & level, which is exactly your alert level of & + SoundWhenPriceIsExactly);
ObjectDelete(&SoundWhenPriceIsExactly&);
SoundWhenPriceIsExactly = 0;
//+------------------------------------------------------------------+
点击复制上述代码粘贴到到公式管理器
MT5源码://+------------------------------------------------------------------+
PriceAlert.mq5 |
Copyright ? ,
Issues sound alerts when price reaches certain levels. |
//+------------------------------------------------------------------+
#property copyright &&
#property link
#property version
#property description &Update 1.01: Dragging lines on chart will now change the alert levels.&
#property indicator_chart_window
input double SoundWhenPriceGoesAbove = 0;
input double SoundWhenPriceGoesBelow = 0;
input double SoundWhenPriceIsExactly = 0;
input bool SendEmail = //If true e-mail is sent to the e-mail address set in your MT5. E-mail SMTP Server settings should also be configured in your MT5.
//Vars to substitute input parameters to be able to modify them
double SWPGB;
double SWPGA;
double SWPIE;
//+------------------------------------------------------------------+
//| Custom indicator initialization function
//+------------------------------------------------------------------+
void OnInit()
if (SoundWhenPriceIsExactly & 0)
SWPIE = SoundWhenPriceIsE
ObjectCreate(0, &SoundWhenPriceIsExactly&, OBJ_HLINE, 0, TimeCurrent(), SoundWhenPriceIsExactly);
ObjectSetInteger(0, &SoundWhenPriceIsExactly&, OBJPROP_STYLE, STYLE_SOLID);
ObjectSetInteger(0, &SoundWhenPriceIsExactly&, OBJPROP_COLOR, Yellow);
ObjectSetInteger(0, &SoundWhenPriceIsExactly&, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, &SoundWhenPriceIsExactly&, OBJPROP_SELECTABLE, true);
if (SoundWhenPriceGoesAbove & 0)
SWPGA = SoundWhenPriceGoesA
ObjectCreate(0, &SoundWhenPriceGoesAbove&, OBJ_HLINE, 0, TimeCurrent(), SoundWhenPriceGoesAbove);
ObjectSetInteger(0, &SoundWhenPriceGoesAbove&, OBJPROP_STYLE, STYLE_SOLID);
ObjectSetInteger(0, &SoundWhenPriceGoesAbove&, OBJPROP_COLOR, Green);
ObjectSetInteger(0, &SoundWhenPriceGoesAbove&, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, &SoundWhenPriceGoesAbove&, OBJPROP_SELECTABLE, true);
if (SoundWhenPriceGoesBelow & 0)
SWPGB = SoundWhenPriceGoesB
ObjectCreate(0, &SoundWhenPriceGoesBelow&, OBJ_HLINE, 0, TimeCurrent(), SoundWhenPriceGoesBelow);
ObjectSetInteger(0, &SoundWhenPriceGoesBelow&, OBJPROP_STYLE, STYLE_SOLID);
ObjectSetInteger(0, &SoundWhenPriceGoesBelow&, OBJPROP_COLOR, Red);
ObjectSetInteger(0, &SoundWhenPriceGoesBelow&, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, &SoundWhenPriceGoesBelow&, OBJPROP_SELECTABLE, true);
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
ObjectDelete(0, &SoundWhenPriceIsExactly&);
ObjectDelete(0, &SoundWhenPriceGoesAbove&);
ObjectDelete(0, &SoundWhenPriceGoesBelow&);
//+------------------------------------------------------------------+
//| Custom indicator iteration function
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
double Ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double Bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
if ((Ask & SWPGA) && (SWPGA & 0))
Alert(&Price above the alert level.&);
PlaySound(&alert.wav&);
SendMail(&Price for & + Symbol() +
& above the alert level & + DoubleToString(Ask), &Price for & + Symbol() +
& reached & + DoubleToString(Ask) + & level, which is above your alert level of & + DoubleToString(SWPGA));
ObjectDelete(0, &SoundWhenPriceGoesAbove&);
SWPGA = 0;
if ((Bid & SWPGB) && (SWPGB & 0))
Alert(&Price below the alert level.&);
PlaySound(&alert.wav&);
SendMail(&Price for & + Symbol() +
& below the alert level & + DoubleToString(Bid), &Price for & + Symbol() +
& reached & + DoubleToString(Bid) + & level, which is below your alert level of & + DoubleToString(SWPGB));
ObjectDelete(0, &SoundWhenPriceGoesBelow&);
SWPGB = 0;
if ((Bid == SWPIE) || (Ask == SWPIE))
Alert(&Price is exactly at the alert level.&);
PlaySound(&alert.wav&);
SendMail(&Price for & + Symbol() +
& exactly at the alert level & + DoubleToString(Ask), &Price for & + Symbol() +
& reached & + DoubleToString(Ask) + &/& + DoubleToString(Bid) + & level, which is exactly your alert level of & + DoubleToString(SWPIE));
ObjectDelete(0, &SoundWhenPriceIsExactly&);
SWPIE = 0;
return(rates_total);
void OnChartEvent(const int id,
const long& lparam,
const double& dparam,
const string& sparam)
if (id != CHARTEVENT_OBJECT_DRAG)
double newprice = ObjectGetDouble(0, sparam, OBJPROP_PRICE);
if (sparam == &SoundWhenPriceIsExactly&) SWPIE =
else if (sparam == &SoundWhenPriceGoesAbove&) SWPGA =
else if (sparam == &SoundWhenPriceGoesBelow&) SWPGB =
//+------------------------------------------------------------------+
点击复制上述代码粘贴到到公式管理器
【字体: 】【】【】
下一篇:没有了!
没有相关内容
本月热门排行
会员登录/注册有人有MT4的缠论指标吗
理想小二级同学
还需要 74 积分才能升级
有人有MT4的缠论指标吗
浏览:3134
欢迎光临理想论坛,由于您没有登录,所以无法查看到论坛的附件及隐藏分区,也无法与其他会员交流。
还没有理想论坛的帐号?
有人有MT4的缠论指标吗,求分享哈哈,谢谢大神们了股票论坛
积分126&理想币12 个&彩币5 个&共享币104 个&注册时间&
理想高二级同学
还需要 6168 积分才能升级
理论太深奥,看不懂。不过还是在网上找到一个指标包,分享一下:
积分13832&理想币2817 个&彩币1 个&共享币97 个&注册时间&
理想高二级同学
还需要 6168 积分才能升级
大智慧,飞狐,MT4缠论公式源码
NinjaTrader
using System.Collections.G
namespace CHAN
& & public struct CALCINFO
& && &&&public int m_dataT
& && &&&public int m_nNumD
& && &&&public IList&Bar& m_pD
& && &&&public int[] m_pResultB
& && &&&public object m_pfParam1;
& && &&&public object m_pfParam2;
& & class kbar
& & enum DATA_TYPE
& && &&&TICK_DATA = 2,& && && && && && && && && && &&&//分笔成交
& && &&&MIN1_DATA,& && && && && && && && && && && && && & //1分钟线
& && &&&MIN5_DATA,& && && && && && && && && && && && && & //5分钟线& && && && && && && && && && && && && &
& && &&&MIN15_DATA,& && && && && && && && && && && && && & //15分钟线
& && &&&MIN30_DATA,& && && && && && && && && && && && && & //30分钟线
& && &&&MIN60_DATA,& && && && && && && && && && && && && & //60分钟线
& && &&&DAY_DATA,& && && && && && && && && && && && && & //日线
& && &&&WEEK_DATA,& && && && && && && && && && && && && & //周线
& && &&&MONTH_DATA,& && && && && && && && && && && && && & //月线
& && &&&YEAR_DATA,& && && && && && && && && && && && && & //年线
& && &&&MULTIDAY_DATA,& && && && && && && && && && &&&//多日线
& && &&&MULTIMIN_DATA& && && && && && && && && && &&&//多分钟线
& & public class ClassChan
& && &&&IList&kbar&
& && &&&void init(CALCINFO pData)
& && && && &int prnum = pData.m_nNumD
& && && && &pr = new List&kbar&(prnum);
& && && && &for (int i = 0; i & i++)
& && && && &{
& && && && && & pr.Add(new kbar());
& && && && && & pr.hprice = pData.m_pData.H
& && && && && & pr.lprice = pData.m_pData.L
& && && && && & pr.flag = 0;
& && && && &}
& && &&&public int bi(ref CALCINFO pData)
& && && && &double biquekou = 0.0001;
& && && && &int i = 1, j, k, l, m,
& && && && &double p1, p2,
& && && && &bool ctfg,
& && && && &int prtype = pData.m_dataT
& && && && &int prnum = pData.m_nNumD
& && && && &double[]
& && && && &while (i & (prnum - 1))
& && && && &{
& && && && && & if (pData.m_pData.Date &= new DateTime(, 13, 19, 0))
& && && && && && &&&m = 1;
& && && && && & k = pr.
& && && && && & if (k != 0)
& && && && && & {
& && && && && && &&&j = i + 1;
& && && && && && &&&l = pr[j].
& && && && && && &&&while ((l == 0) && (j & prnum - 1))//找到下一个不为0的
& && && && && && &&&{
& && && && && && && && &j++;
& && && && && && && && &l = pr[j].
& && && && && && &&&}//找到两个值;
& && && && && && &&&if (l == 0)
& && && && && && && && && && && && && && && && & //判断包含后的距离
& && && && && && &&&buf = new double[10];
& && && && && && &&&for (int ii = 0; ii & 10; ii++)
& && && && && && && && &buf[ii] = 0;
& && && && && && &&&m = 0;
& && && && && && &&&for (k = k &= k++)
& && && && && && &&&{
& && && && && && && && &s = pr[k].
& && && && && && && && &ctfg =
& && && && && && && && &for (l = 0; l &= 5; l++)//查找是否在队列中
& && && && && && && && &{
& && && && && && && && && & if (s == buf[l])
& && && && && && && && && & {
& && && && && && && && && && &&&ctfg =
& && && && && && && && && && &&&
& && && && && && && && && & }
& && && && && && && && &}
& && && && && && && && &if (!ctfg)//如果不在队列中
& && && && && && && && &{
& && && && && && && && && & for (l = 0; l &= 5; l++)
& && && && && && && && && & {
& && && && && && && && && && &&&if (buf[l] == 0)
& && && && && && && && && && &&&{
& && && && && && && && && && && && &buf[l] =
& && && && && && && && && && && && &m++;
& && && && && && && && && && && && &
& && && && && && && && && && &&&}
& && && && && && && && && & }
& && && && && && && && &}
& && && && && && && && &if (m &= 4)
& && && && && && && && && &
& && && && && && &&&}
& && && && && && &&&bictfg =& && &//缺口处理过程
& && && && && && &&&s = 0;
& && && && && && &&&if (pr.flag == -1)//向上
& && && && && && &&&{
& && && && && && && && &for (k = k & k++)
& && && && && && && && &{
& && && && && && && && && & p1 = pData.m_pData[k].H
& && && && && && && && && & p2 = pData.m_pData[k + 1].L
& && && && && && && && && & if (p2 & p1)
& && && && && && && && && && &&&s = (p2 / p1 - 1) +
& && && && && && && && &}
& && && && && && &&&}
& && && && && && &&&else//向下
& && && && && && &&&{
& && && && && && && && &for (k = k & k++)
& && && && && && && && &{
& && && && && && && && && & p1 = pData.m_pData[k].L
& && && && && && && && && & p2 = pData.m_pData[k + 1].H
& && && && && && && && && & if (p1 & p2)
& && && && && && && && && && &&&s = Math.Abs(p2 / p1 - 1) +
& && && && && && && && &}
& && && && && && &&&}
& && && && && && &&&if (s &= biquekou)
& && && && && && && && &bictfg =
& && && && && && &&&if (m &= 4)//包含后大于4根,再次判断
& && && && && && &&&{
& && && && && && && && &if (j - i &= 4) //不包含,至少5根
& && && && && && && && &{
& && && && && && && && && & if (prtype != (int)DATA_TYPE.MIN5_DATA)&&//5分钟分笔幅度太小的,舍掉
& && && && && && && && && && &&&bictfg =
& && && && && && && && && & else
& && && && && && && && && & {
& && && && && && && && && && &&&if (pr[j].flag == 1)
& && && && && && && && && && &&&{
& && && && && && && && && && && && &s = (pr[j].hprice - pr.lprice) / pr.
& && && && && && && && && && && && &if ((j - i &= 6) || (s &= 0.008))
& && && && && && && && && && && && && & bictfg =
& && && && && && && && && && &&&}
& && && && && && && && && && &&&if (pr[j].flag == -1)
& && && && && && && && && && &&&{
& && && && && && && && && && && && &s = (pr.hprice - pr[j].lprice) / pr.
& && && && && && && && && && && && &if ((j - i &= 6) || (s &= 0.008))
& && && && && && && && && && && && && & bictfg =
& && && && && && && && && && &&&}
& && && && && && && && && & }
& && && && && && && && &}
& && && && && && &&&}// end m&=4
& && && && && && &&&if (!bictfg) //如果不是一笔,进行下面的处理
& && && && && && &&&{
& && && && && && && && &k =
& && && && && && && && &l = pr[k].
& && && && && && && && &k++;
& && && && && && && && &while ((l != pr[k].flag) && (k & prnum - 1))//取下相同的顶或底
& && && && && && && && &{
& && && && && && && && && & k++;
& && && && && && && && &}
& && && && && && && && &if (l == 1)//如果是顶
& && && && && && && && &{
& && && && && && && && && & p1 = pr.
& && && && && && && && && & p2 = pr[k].
& && && && && && && && && & if (p1 &= p2) //前顶比后顶高;
& && && && && && && && && & {
& && && && && && && && && && &&&pr[j].flag = 0;
& && && && && && && && && && &&&pr[k].flag = 0;
& && && && && && && && && & }
& && && && && && && && && & else//前顶比后顶矮
& && && && && && && && && & {
& && && && && && && && && && &&&pr.flag = 0; //先把自己去掉
& && && && && && && && && && &&&n =
& && && && && && && && && && &&&m = pr[n].
& && && && && && && && && && &&&n--;
& && && && && && && && && && &&&while ((m != pr[n].flag) && (n & 0))
& && && && && && && && && && && && &n--;
& && && && && && && && && && &&&p1 = pr[n].
& && && && && && && && && && &&&p2 = pr[j].
& && && && && && && && && && &&&if (p1 & p2)
& && && && && && && && && && &&&{
& && && && && && && && && && && && &pr[j].flag = 0;
& && && && && && && && && && &&&}
& && && && && && && && && && &&&else
& && && && && && && && && && && && &pr[n].flag = 0;
& && && && && && && && && & }
& && && && && && && && && & i--;
& && && && && && && && &}
& && && && && && && && &if (l == -1)
& && && && && && && && &{
& && && && && && && && && & p1 = pr.
& && && && && && && && && & p2 = pr[k].
& && && && && && && && && & if (p1 &= p2)&&//前底比后底矮
& && && && && && && && && & {
& && && && && && && && && && &&&pr[j].flag = 0;
& && && && && && && && && && &&&pr[k].flag = 0;
& && && && && && && && && & }
& && && && && && && && && & else//前底比后底高
& && && && && && && && && & {
& && && && && && && && && && &&&pr.flag = 0;
& && && && && && && && && && &&&n =
& && && && && && && && && && &&&m = pr[n].
& && && && && && && && && && &&&n--;
& && && && && && && && && && &&&while ((m != pr[n].flag) && (n & 0))
& && && && && && && && && && && && &n--;
& && && && && && && && && && &&&p1 = pr[n].
& && && && && && && && && && &&&p2 = pr[j].
& && && && && && && && && && &&&if (p1 & p2)
& && && && && && && && && && && && &pr[j].flag = 0;
& && && && && && && && && && &&&else
& && && && && && && && && && && && &pr[n].flag = 0;
& && && && && && && && && & }
& && && && && && && && && & i--;
& && && && && && && && &}
& && && && && && &&&}
& && && && && & }// end if k&&0;
& && && && && & i++;
& && && && &} //
& && && && &///?& && &&&checkhl();& && && & //检查最后一笔的高低点
& && && && &i = prnum - 1;
& && && && &while ((pr.flag == 0) && (i & 0))
& && && && && & i--;
& && && && &if (pr.flag == 1)
& && && && &{
& && && && && & for (j = i + 1; j & j++)
& && && && && & {
& && && && && && &&&if (pr[j].hprice & pr.hprice)
& && && && && && &&&{
& && && && && && && && &pr.flag = 0;
& && && && && && && && &
& && && && && && &&&}
& && && && && & }
& && && && &}
& && && && &if (pr.flag == -1)
& && && && &{
& && && && && & for (j = i + 1; j & j++)
& && && && && && &&&if (pr[j].lprice & pr.lprice)
& && && && && && &&&{
& && && && && && && && &pr.flag = 0;
& && && && && && && && &
& && && && && && &&&}
& && && && &}
& && && && &pData.m_pResultBuf = new int[prnum];
& && && && &for (i = 0; i & i++)
& && && && &{
& && && && && & pData.m_pResultBuf = pr.
& && && && &}
& && && && &return 1;
& && &&&//处理kxian顶底的源代码& &作者:悟多&&c++ version
& && &&&public int kxian(ref CALCINFO pData)
& && && && &int i, j = 1, k, m,
& && && && &double h, h1, h2, h3, h4, h5, h6, h7;
& && && && &bool tj1, tj2, tj3, tj4,
& && && && &init(pData);
& && && && &if ((pData.m_pfParam1 != null) && (pData.m_pfParam2 != null))
& && && && &{
& && && && && & int prnum = pData.m_nNumD
& && && && && & ///?& && && && && & adjustkline(pData); //处理包含关系;
& && && && && & //标出顶和底
& && && && && & pr[0].flag = 0;
& && && && && & pr[prnum - 1].flag = 0;
& && && && && & for (i = 1; i & prnum - 1; i++)
& && && && && & {
& && && && && && &&&if (pData.m_pData.Date &= new DateTime(, 13, 19, 0))
& && && && && && && && &m = 1;
& && && && && && &&&j =
& && && && && && &&&h = pr.
& && && && && && &&&j--;
& && && && && && &&&h1 = pr[j].
& && && && && && &&&while ((h == h1) && (j & 0))//取前一个不同的高值
& && && && && && &&&{
& && && && && && && && &j--;
& && && && && && && && &h1 = pr[j].
& && && && && && &&&}
& && && && && && &&&m =
& && && && && && &&&if (j & 0) j--;
& && && && && && &&&h2 = pr[j].
& && && && && && &&&while ((h1 == h2) && (j & 0))//最前2个不同的值
& && && && && && &&&{
& && && && && && && && &j--;
& && && && && && && && &h2 = pr[j].
& && && && && && &&&}
& && && && && && &&&if (j & 0) j--;
& && && && && && &&&h3 = pr[j].
& && && && && && &&&while ((h2 == h3) && (j & 0))//取前3个不同的值
& && && && && && &&&{
& && && && && && && && &j--;
& && && && && && && && &h3 = pr[j].
& && && && && && &&&}
& && && && && && &&&k = i + 1;
& && && && && && &&&if (k == prnum)
& && && && && && && && &
& && && && && && &&&h4 = pr[k].
& && && && && && &&&while ((h == h4) && (k & prnum - 1)) //后一个不同高值
& && && && && && &&&{
& && && && && && && && &k++;
& && && && && && && && &h4 = pr[k].
& && && && && && &&&}
& && && && && && &&&n =
& && && && && && &&&if (k & prnum - 1) k++;
& && && && && && &&&h5 = pr[k].
& && && && && && &&&while ((h4 == h5) && (k & prnum - 1)) //后2个不同高值
& && && && && && &&&{
& && && && && && && && &k++;
& && && && && && && && &h5 = pr[k].
& && && && && && &&&}
& && && && && && &&&if (k & prnum - 1) k++;
& && && && && && &&&h6 = pr[k].
& && && && && && &&&while ((h5 == h6) && (k & prnum - 1)) //后3个不同高值
& && && && && && &&&{
& && && && && && && && &k++;
& && && && && && && && &h6 = pr[k].
& && && && && && &&&}
& && && && && && &&&if ((k &= prnum) || (n + 3 &= prnum))
& && && && && && && && &
& && && && && && &&&tj1 =
& && && && && && &&&tj2 =
& && && && && && &&&tj3 =
& && && && && && &&&tj4 =
& && && && && && &&&if ((h &= h1) && (h &= h2) && (h &= h3) && (h &= h4) && (h &= h5) && (h &= h6)) //判断顶底
& && && && && && && && &tj1 =
& && && && && && &&&if (m &= 3)
& && && && && && && && &h7 = pr[m - 3].
& && && && && && &&&else
& && && && && && && && &h7 = pr[0].
& && && && && && &&&if ((h &= h1) && (h &= h2) && (h &= h3) && (h &= h7) && (h &= pr[n].hprice) && (h &= pr[n + 1].hprice) && (h &= pr[n + 2].hprice) && (h &= pr[n + 3].hprice))
& && && && && && && && &tj2 =
& && && && && && &&&if (!(tj1 && tj2))
& && && && && && &&&{
& && && && && && && && &j =
& && && && && && && && &h = pr.
& && && && && && && && &j--;
& && && && && && && && &h1 = pr[j].
& && && && && && && && &while ((h == h1) && (j & 0))//取前一个不同的低值
& && && && && && && && &{
& && && && && && && && && & j--;
& && && && && && && && && & h1 = pr[j].
& && && && && && && && &}
& && && && && && && && &m =
& && && && && && && && &if (j & 0) j = j - 1;
& && && && && && && && &h2 = pr[j].
& && && && && && && && &while ((h1 == h2) && (j & 0))//最前2个不同的值
& && && && && && && && &{
& && && && && && && && && & j--;
& && && && && && && && && & h2 = pr[j].
& && && && && && && && &}
& && && && && && && && &if (j & 0) j--;
& && && && && && && && &h3 = pr[j].
& && && && && && && && &while ((h2 == h3) && (j & 0))//取前3个不同的值
& && && && && && && && &{
& && && && && && && && && & j--;
& && && && && && && && && & h3 = pr[j].
& && && && && && && && &}
& && && && && && && && &k =
& && && && && && && && &k++;
& && && && && && && && &if (k == prnum)
& && && && && && && && && &
& && && && && && && && &h4 = pr[k].
& && && && && && && && &while ((h == h4) && (k & prnum - 1)) //后1个不同低值
& && && && && && && && &{
& && && && && && && && && & k++;
& && && && && && && && && & h4 = pr[k].
& && && && && && && && &}
& && && && && && && && &n =
& && && && && && && && &if (k & prnum - 1) k++;
& && && && && && && && &h5 = pr[k].
& && && && && && && && &while ((h4 == h5) && (k & prnum - 1)) //后2个不同高值
& && && && && && && && &{
& && && && && && && && && & k++;
& && && && && && && && && & h5 = pr[k].
& && && && && && && && &}
& && && && && && && && &if (k & prnum - 1) k++;
& && && && && && && && &h6 = pr[k].
& && && && && && && && &while ((h5 == h6) && (k & prnum - 1)) //后3个不同高值
& && && && && && && && &{
& && && && && && && && && & k++;
& && && && && && && && && & h6 = pr[k].
& && && && && && && && &}
& && && && && && && && &if ((k &= prnum) || (n + 3 &= prnum))
& && && && && && && && &if ((h &= h1) && (h &= h2) && (h &= h3) && (h &= h4) && (h &= h5) && (h &= h6)) //判断底
& && && && && && && && && & tj3 =
& && && && && && && && &if (m &= 3)
& && && && && && && && && & h7 = pr[m - 3].
& && && && && && && && &else
& && && && && && && && && & h7 = pr[0].
& && && && && && && && &if ((h &= h1) && (h &= h2) && (h &= h3) && (h &= h7) && (h &= pr[n].lprice) && (h &= pr[n + 1].lprice) && (h &= pr[n + 2].lprice) && (h &= pr[n + 3].lprice))
& && && && && && && && && & tj4 =
& && && && && && &&&}
& && && && && && &&&if (tj1 && tj2)
& && && && && && && && &pr.flag = 1;
& && && && && && &&&else
& && && && && && && && &if (tj3 && tj4)
& && && && && && && && && & pr.flag = -1;
& && && && && && && && &else
& && && && && && && && && & pr.flag = 0;
& && && && && & }//end for
& && && && && & for (i = 1; i &= prnum - 2; i++) //检查几个包含后重复的。
& && && && && & {
& && && && && && &&&m = pr.
& && && && && && &&&if (m == 1)
& && && && && && &&&{
& && && && && && && && &j =
& && && && && && && && &if (pData.m_pData.High == pr.hprice)
& && && && && && && && &{
& && && && && && && && && & pr.flag = 1;
& && && && && && && && && & j++; //如果前面的相同,只标最后一个
& && && && && && && && && & h = pr[j].
& && && && && && && && && & while ((h == pr.hprice) && (j & prnum - 1))
& && && && && && && && && & {
& && && && && && && && && && &&&j++;
& && && && && && && && && && &&&h = pr[j].
& && && && && && && && && & }
& && && && && && && && && & for (k = i + 1; k &= (j - 1); k++)
& && && && && && && && && && &&&pr[k].flag = 0;
& && && && && && && && &}
& && && && && && && && &else
& && && && && && && && && & pr.flag = 0;
& && && && && && &&&}
& && && && && && &&&if (m == -1)
& && && && && && &&&{
& && && && && && && && &if (pData.m_pData.Low == pr.lprice)
& && && && && && && && &{
& && && && && && && && && & j =
& && && && && && && && && & pr.flag = -1;
& && && && && && && && && & j++; //如果前面的相同,只标最后一个
& && && && && && && && && & h = pr[j].
& && && && && && && && && & while ((h == pr.lprice) && (j & prnum - 1))
& && && && && && && && && & {
& && && && && && && && && && &&&j++;
& && && && && && && && && && &&&h = pr[j].
& && && && && && && && && & }
& && && && && && && && && & for (k = i + 1; k &= (j - 1); k++)
& && && && && && && && && && &&&pr[k].flag = 0;
& && && && && && && && &}
& && && && && && && && &else
& && && && && && && && && & pr.flag = 0;
& && && && && && &&&}
& && && && && & }//end 检查重复的
& && && && && & ///?& && && && && & adjustdd(1,prnum-2);
& && && && && & ///?& && && && && & checkhl();
& && && && && & pData.m_pResultBuf = new int[prnum];
& && && && && & for (i = 0; i &= prnum - 1; i++)
& && && && && && &&&pData.m_pResultBuf = pr.
& && && && && & return 1;
& && && && &} // end if NULL
& && && && &else
& && && && && & return -1;
积分13832&理想币2817 个&彩币1 个&共享币97 个&注册时间&
理想高二级同学
还需要 6168 积分才能升级
MT4平台技术指标之“缠论分笔”
MT4平台自定义指标使用方法
& & 缠论是个伟大的理论,但很难精通,本博为了学习研究之用,开发了缠论分笔指标。开发这个指标工作量很大,花费了我几个月的时间去完善。到目前为止,我认为是最能反应走势的分笔方法。分享给学缠的爱好者。
& &1.笔的定义有两种:新笔和老笔。还要处理顶比底还低,底比顶还高的问题。顶比底还低及底比顶还高又存在不同的定义,比如:顶底K线能否存在包含关系,顶底左右的K线能否比较高底,是否需要比较收盘价的高底。有太多种组合关系。
& & 当市场出现极端行情时(比如1分钟下跌20美元),有时候用一种定义比较符合走势,有时候用另一种定义比较符合走势。
& & 在黄金市场,因为受消息驱动。市场出现极端行情的机会还是比较多的。本人经过长时间(2年左右)的测试修改,得到了最符合大部分走势规律的处理方法。但没有任何一种完美的定义可以适合任何走势。在使用过程中可能有不够完美的地方,不过出现概率已经很低了。
&&2. 可修改外部变量type的值为0或1,0为画点,1为画线。
&&3. 按Home键到图表的最左端后继续向左移动图表存在计算错误的BUG,这个BUG基本不影响使用,笔的计算是个复杂的过程,为了平衡计算速度,少占用 CPU资源,这个BUG不做修改。如果出现了错误,重新切换一下周期即可。如果修改好这个BUG,我的其中一个笔记本电脑反应较慢,呵呵,老式的。
&&4.本指标可以计算MACD的面积。
源代码如下:
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
extern int type=1;//0为点,1为线
//---- buffers
double IndicatorBuffer1[];
double DingOrDi[];
double MACDAreaBuffer[];
double MaiMaiDianBuffer[];
int Deviation=0; //& &忽略次要波动,小于100个Point Value的波动是小波动(黄金、A300的Point Value均为0.01)
bool NeedPrint(int i)
return (false);//不打印
if(& & TimeYear(Time)==2013
& &&&&& TimeMonth(Time)==10
& &&&&& TimeDay(Time)==17
& &&&&& TimeHour(Time)==20
& &&&&& TimeMinute(Time)==45
&&return (true);
&&return (false);
//+------------------------------------------------------------------+
//| Custom indicator iteration function& && && && && && && && && && &|
//+------------------------------------------------------------------+
int start()
//没有产生新的K线前,不重复计算
& & static datetime&&dt=0;
& & if(dt==Time[0])
& &&&dt=Time[0];
& &Sleep(5000);
& &// Print(&DateTime:&,dt);
& &int counted_bars = IndicatorCounted();
& &//---- check for possible errors
& &if (counted_bars&0) return(-1);
& &//---- previous counted bar will be recounted
& &if (counted_bars&0) counted_bars--;
& &limit = Bars - counted_
& &if(counted_bars==0 && Bars&=6 )
& & limit-=6;
& &else if(limit&=2)
&&// limit-=2;
& & double high=0,low=0;
& & int previousDi=-1,previousDing=-1,HasFirstDing=0,HasFirstDi=0,DingTempState=0,DiTempState=0;
& & ComputeMacdArea(Bars);//计算MACD面积
& &for(int i=B i&=1; i--)
& & int FenXing=0;//-1表示底分型 1表示顶分型
& & if(IsDingFenXing(i) && !IsDiFenXing(i))
& && &FenXing=1;
& & else if(IsDiFenXing(i) && !IsDingFenXing(i))
& && &FenXing=-1;
& & else if(IsDingFenXing(i) && IsDiFenXing(i)) //即是顶分型又是底分型的时候需要确定用哪一个更合适
& && &if(previousDing==-1 || previousDi==-1)//前面没有底或没有顶时取顶
& && && && && && && && && && && && && && & //(为了计算方便,最初限制不太严格,可能不够完美,但对操作没有任何影响)
& && &&&FenXing=1;
& && &else //前面既有顶又有底时
& && &&&if(previousDing & previousDi) //最近是顶
& && && & if(Low&High[previousDing]) FenXing=-1;
& && && & else&&FenXing=1;
& && &&&else //最近是底
& && && & if(High&Low[previousDi]) FenXing=1;
& && && & else&&FenXing=-1;
& & DingOrDi=0;
& & if(NeedPrint(i))&&Print(&Current Time:&,TimeYear(Time),&-&,TimeMonth(Time),&-&,TimeDay(Time),& &,
& && && && && && && && && && &TimeHour(Time),&:&,TimeMinute(Time),& number:&,i);
& & if( IsDingFenXing(i)&& FenXing==1)
& && &//找到一个顶
& && &DingOrDi=1;
& && &&&if(NeedPrint(i))
& && && && &{
& && && && & Print(&PreviousDi:&,TimeHour(Time[previousDi]),&:&,TimeMinute(Time[previousDi]),&,number:&,previousDi,&,DingOrDi:&,DingOrDi[previousDi]);
& && && && & Print(&previousDing:&,TimeHour(Time[previousDing]),&:&,TimeMinute(Time[previousDing]),&,number:&,previousDing,&,DingOrDi:&,DingOrDi[previousDing]);
& && && && &}
& && & if(DingTempState!=0)//顶中间状态找到一个顶
& && &&&if(High&=High[DingTempState])//当前顶比中间状态的顶低叉掉当前的顶
& && && && &DingOrDi=0;
& && && && &if(NeedPrint(i))& & Print(&Ding_0_1:&,i);
& && &&&else if(previousDi-i+1&5 && HasGap(previousDi,i)==0) //当前顶比中间状态的顶高且当前顶与前底比不够5周期仍处于中间状态
& && && && &DingOrDi=0;
& && && && &DingTempState=i;
& && && && &if(NeedPrint(i))& & Print(&Ding_0_2:&,i);
& && &&&else //当前顶比中间状态的顶高且当前顶与前底比够5周期结束中间状态并保留此顶
& && && &DingTempState=0;
& && && &if(NeedPrint(i))& & Print(&Ding_0_3:&,i);
& && & else if(DiTempState!=0)//底中间状态找到一个顶
& && && & if(DiTempState-i+1&5 && HasGap(DiTempState,i)==0) //当前顶与底中间状态的底比不够5周期仍处于中间状态
& && && & {
& && && && &DingOrDi=0;
& && && && &if(NeedPrint(i))& & Print(&Ding_0_4:&,i);
& && && & }
& && && & else&&//当前顶与底中间状态的底比够5周期&&结束中间状态叉掉前顶和前底
& && && & {
& && && &&&
& && && && & DingOrDi[previousDi]=0;
& && && && & DingOrDi[previousDing]=0;
& && && && & previousDi=DiTempS
& && && && & DingOrDi[previousDi]=-1;
& && && && & DiTempState=0;
& && && && & if(NeedPrint(i))& & Print(&Ding_0_5:&,i);
& && && &}
& && & else if(HasFirstDi==1 && HasFirstDing==0)//第一个底后紧跟一个顶不够5周期叉掉此顶
& && && & if(previousDi-i+1&5 && HasGap(previousDi,i)==0)//不够5周期叉掉此顶
& && && & {
& && && && &DingOrDi=0;
& && && && &if(NeedPrint(i))& &Print(&Ding_1:&,i);
& && && & }
& && && & else//够5周期保留此顶
& && && & {
& && && && &if(NeedPrint(i))& &Print(&Ding_2:&,i);
& && && & }
& && & else if(HasFirstDi==1 && HasFirstDing==1 && previousDing&previousDi)//顶前有底,底前又有顶
& && && & if(previousDi-i+1&5 && HasGap(previousDi,i)==0) //不够5周期
& && && & {
& && && &&&if(High&=High[previousDing])//不够5周期且当前顶比前顶低叉掉此顶
& && && && &{
& && && && & DingOrDi=0;
& && && && & if(NeedPrint(i))&&Print(&Ding_3:&,i);
& && && && &}
& && && &&&else//不够5周期且当前顶比前顶高进入顶中间状态并叉掉此顶
& && && &&&{
& && && && &DingTempState=i;
& && && && &DingOrDi=0;
& && && && &if(NeedPrint(i))&&Print(&Ding_3_2:&,i);
& && && &&&}
& && && & }
& && && & else//够5周期保留此顶
& && && & {
& && && &&&if(NeedPrint(i))&&Print(&Ding_4_3:&,i);
& && && & }
& && &&&else if(HasFirstDing==1 && (HasFirstDi==0 || previousDi&previousDing ) //连续出现两个顶
& && && && && &)
& && && & if(High[previousDing]&High)
& && && &&&{
& && && && & DingOrDi[previousDing]=0; //叉掉前面一个顶
& && && && & DingOrDi=1;
& && && && &if(NeedPrint(i))& &Print(&Ding_5:&,i);
& && && &&&}
& && && & else
& && && &&&{
& && && && & DingOrDi=0;//叉掉当前的顶
& && && && &if(NeedPrint(i))& & Print(&Ding_6:&,i);
& && && &&&}
& && &&&else
& && && &DingOrDi=1;
& && && &if(NeedPrint(i))& &Print(&Ding_7:&,i);
& && & if(DingOrDi==1)
& && &&&if((previousDi!=-1&&DingOrDi[previousDi]==0) || (previousDing!=-1&&DingOrDi[previousDing]==0))//已叉掉前面的顶或底时,保留此顶
& && && &if(NeedPrint(i))& &Print(&Ding_8_0:&,i);
& && && &HasFirstDing=1;
& && && &previousDing=i;
& && &&&}& && &
& && &&&else if(previousDi!=-1
& && && &&&//&& (previousDi-i)&10& && && && && & //极端情况下,会造成中间很多笔缺失,大于10个周期可看做时间换空间
& && && &&&&& (Close&Close[previousDi]||High&Low[previousDi]
& && && && && &||(High&=High[previousDi] && previousDi-i&10)//10周期内不允许存在包含关系
& && && && && &||(Low&=Low[previousDi] && previousDi-i&10) //10周期内不允许存在包含关系
& && && && && &||(Low[i-1]&=Low[previousDi]&& previousDi-i&10)
& && && && && &||(Low[i+1]&=Low[previousDi]&& previousDi-i&10)
& && && && && &||(High[previousDi+1]&=High&& previousDi-i&10)
& && && && && &||(High[previousDi-1]&=High&& previousDi-i&10)
& && && & ))//当前顶比前底还低时 顶比底低
& && && &{
& && && & if(HasGap(previousDi,i)==0) //无缺口时叉掉此顶
& && && &&&{
& && && && & if(!(HasFirstDing==1 && (HasFirstDi==0 || previousDi&previousDing ) && High[previousDing]&High))
& && && && & {
& && && && &&&DingOrDi=0;
& && && && &&&if(NeedPrint(i))& &Print(&Ding_8_1:&,i);
& && && && & }
& && && && & else ////连续出现两个顶且前顶比当前顶低时保留当前顶
& && && && & {
& && && && && & HasFirstDing=1;
& && && && && & previousDing=i;
& && && && && & if(NeedPrint(i))& &Print(&Ding_8_2:&,i);
& && && && & }
& && && &&&}
& && && &&&else if(!(High&=High[previousDi]||Low&=Low[previousDi]
& && && && && && & //& &||Low[i+1]&=Low[previousDi]||High[previousDi-1]&=High
& && && && && && & ))//有缺口且顶分型不比底型低时保留此顶
& && && &&&{
& && && && &HasFirstDing=1;
& && && && &previousDing=i;
& && && && &if(NeedPrint(i))& &Print(&Ding_9:&,i);
& && && &&&}
& && && &&&else //有缺口且顶分型比底型低仍叉掉此顶
& && && &&&{
& && && && & DingOrDi=0;
& && && && & if(NeedPrint(i))& &Print(&Ding_9_2:&,i);
& && && &&&}
& && &&&else if(previousDi!=-1 && (High-Low[previousDi])&=Point*Deviation) //忽略波动小于一定点位的次要波动 叉掉此顶
& && && &DingOrDi=0;
& && && &if(NeedPrint(i))& &Print(&Ding_10:&,i);
& && &&&else if(HasFirstDi==1 &&&&previousDi!=-1)
& && && &for(int ii=i+1;ii&previousDi;ii++)
& && && &{
& && && &&&if(High[ii]&High)
& && && &}
& && && &if(ii==previousDi || previousDi-i&=10)//当前顶分型为笔中的最高点或者够10周期 保留此顶
& && && &{
& && && & if(NeedPrint(i))& &Print(&Ding_11:&,i);
& && && & HasFirstDing=1;
& && && & previousDing=i;
& && && &}
& && && &else //当前顶分型不是笔中的最高点且不够10周期 删除此顶
& && && &{
& && && &&&if(NeedPrint(i))& &Print(&Ding_12:&,i);
& && && &&&DingOrDi=0;
& && && &}
& && &&&else//保留此顶
& && && &if(NeedPrint(i))& &Print(&Ding_13:&,i);
& && && &HasFirstDing=1;
& && && &previousDing=i;
& & else if(IsDiFenXing(i) && FenXing==-1)
& && &//找到一个底
& && &DingOrDi=-1;
& && &if(NeedPrint(i))
& && && && &{
& && && && & Print(&PreviousDing:&,TimeHour(Time[previousDing]),&:&,TimeMinute(Time[previousDing]),&,number:&,previousDing,&,DingOrDi:&,DingOrDi[previousDing]);
& && && && & Print(&previousDi:&,TimeHour(Time[previousDi]),&:&,TimeMinute(Time[previousDi]),&,number:&,previousDi,&,DingOrDi:&,DingOrDi[previousDi]);
& && && && &}
& && &if(DiTempState!=0)//底中间状态找到一个底
& && &&&if(Low&=Low[DiTempState])//当前底比中间状态的底高叉掉当前的底
& && && && &DingOrDi=0;
& && && && &if(NeedPrint(i))& & Print(&Di_0_1:&,i);
& && &&&else if(previousDi-i+1&5 && HasGap(previousDi,i)==0) //当前底比中间状态的底低且当前底与前顶比不够5周期仍处于中间状态
& && && && &DingOrDi=0;
& && && && &DiTempState=i;
& && && && &if(NeedPrint(i))& & Print(&Di_0_2:&,i);
& && &&&else //当前底比中间状态的底低且当前底与前顶比够5周期结束中间状态并保留此底
& && && &DiTempState=0;
& && && &if(NeedPrint(i))& & Print(&Di_0_3:&,i);
& && & else if(DingTempState!=0)//顶中间状态找到一个底
& && && &if(DingTempState-i+1&5 && HasGap(DingTempState,i)==0) //当前底与顶中间状态的顶比不够5周期仍处于中间状态
& && && & {
& && && && &DingOrDi=0;
& && && && &if(NeedPrint(i))& & Print(&Di_0_4:&,i);
& && && & }
& && && & else&&//当前底与顶中间状态的顶比够5周期&&结束中间状态叉掉前顶和前底
& && && & {& && && &&&
& && && && & DingOrDi[previousDi]=0;
& && && && & DingOrDi[previousDing]=0;
& && && && & previousDing=DingTempS
& && && && & DingOrDi[previousDing]=1;
& && && && & DingTempState=0;
& && && && & if(NeedPrint(i))& & Print(&Di_0_5:&,i);
& && && & }
& && & else if(HasFirstDing==1&&&& HasFirstDi==0)//第一个顶后紧跟一个底不够5周期叉掉此底
& && && & if(previousDing-i+1&5 && HasGap(previousDing,i)==0)&&//不够5周期叉掉此底
& && && & {
& && && && &DingOrDi=0;
& && && &&&if(NeedPrint(i))& &Print(&Di_1:&,i);
& && && & }
& && && & else//够5周期保留此底
& && && & {
& && && && &if(NeedPrint(i))& &Print(&Di_2:&,i);
& && && & }
& && && && &
& && &else if(HasFirstDing==1&&&& HasFirstDi==1 && previousDi&previousDing)//底前有顶,顶前又有底
& && && & if(previousDing-i+1&5 && HasGap(previousDing,i)==0)&&//不够5周期
& && && & {
& && && &&&if(Low&=Low[previousDi])//不够5周期且当前底比前底高叉掉此底
& && && &&&{
& && && && &DingOrDi=0;
& && && && &if(NeedPrint(i))& &Print(&Di_3:&,i);
& && && &&&}
& && && &&&else//不够5周期且当前底比前底低进入底中间状态并叉掉此底
& && && &&&{
& && && && & DiTempState=i;
& && && && & DingOrDi=0;
& && && && & if(NeedPrint(i))& &Print(&Di_3_2:&,i);
& && && &&&}
& && && & }
& && && & else//够5周期保留此底
& && && & {
& && && && &if(NeedPrint(i))& &Print(&Di_4_3:&,i);
& && && & }& && &
& && &&&else if(HasFirstDi==1 && (HasFirstDing==0||previousDing&previousDi )//连续出现两个底
& && && && && &)
& && && & if(Low[previousDi]&Low)
& && && &&&{
& && && && & DingOrDi[previousDi]=0; //叉掉前面一个底
& && && && & DingOrDi=-1;
& && && && & if(NeedPrint(i))& &Print(&Di_5:&,i);
& && && &&&}
& && && & else
& && && & {
& && && && &DingOrDi=0;//叉掉当前的底
& && && && &if(NeedPrint(i))& &Print(&Di_6:&,i);
& && && & }
& && &&&else
& && && &DingOrDi=-1;
& && && &if(NeedPrint(i))& &Print(&Di_7:&,i);
& && &if(DingOrDi==-1)
& && &&&if((previousDi!=-1&&DingOrDi[previousDi]==0) || (previousDing!=-1&&DingOrDi[previousDing]==0))//已叉掉前面的顶或底时,保留此底
& && && &if(NeedPrint(i))& &Print(&Di_8_0:&,i);
& && && &HasFirstDi=1;
& && && &previousDi=i;
& && &&&}&&
& && &&&else if(previousDing!=-1
& && && &// && (previousDing-i)&10& && &&&//极端情况下,会造成中间很多笔缺失,大于10个周期可看做时间换空间
& && && & &&(Close&Close[previousDing]||Low&High[previousDing]
& && && && & ||(Low&=Low[previousDing] && previousDing-i&10)//10周期内不允许存在包含关系
& && && && & ||(High&=High[previousDing] && previousDing-i&10)//10周期内不允许存在包含关系
& && && && & ||(High[i-1]&=High[previousDing]&& previousDing-i&10)
& && && && & ||(High[i+1]&=High[previousDing]&& previousDing-i&10)
& && && && & ||(Low[previousDing+1]&=Low&& previousDing-i&10)
& && && && & ||(Low[previousDing-1]&=Low&& previousDing-i&10)
& && && && &))//当前底比前顶还高 底比顶高
& && && &if(HasGap(previousDing,i)==0)//无缺口时叉掉此底
& && && &{
& && && & if(!(HasFirstDi==1 && (HasFirstDing==0||previousDing&previousDi)&& Low[previousDi]&Low))
& && && & {
& && && &&&DingOrDi=0;
& && && &&&if(NeedPrint(i))& &Print(&Di_8_1:&,i);
& && && & }
& && && & else //连续出现两个底且前底比当前底高时保留当前底
& && && & {
& && && && &if(NeedPrint(i))& &Print(&Di_8_2:&,i);
& && && && &HasFirstDi=1;
& && && && &previousDi=i;
& && && & }
& && && &}
& && && &else if(!(Low&=Low[previousDing]||High&=High[previousDing]
& && && && && &//& &&&||High[i+1]&=High[previousDing]||Low[previousDing-1]&=Low
& && && && && &))//有缺口且底分型不比顶型高时保留此底
& && && &&&{
& && && && &&&HasFirstDi=1;
& && && && &&&previousDi=i;
& && && && &&&if(NeedPrint(i))& &Print(&Di_9:&,i);
& && && &&&}
& && && &else //有缺口且底分型比顶型高仍叉掉此底
& && && &{
& && && & DingOrDi=0;
& && && & if(NeedPrint(i))& &Print(&Di_9_2:&,i);
& && && &}
& && &&&else if(previousDing!=-1 && (High[previousDing]-Low)&=Point*Deviation) //忽略波动小于一定点位的次要波动 叉掉此底
& && && &DingOrDi=0;
& && && &if(NeedPrint(i))& &Print(&Di_10:&,i);
& && &&&else if(HasFirstDing==1 &&&&previousDing!=-1)
& && && &for(int jj=i+1;jj&previousDjj++)
& && && &{
& && && & if(Low[jj]&Low)
& && && &}
& && && &if(jj==previousDing || previousDing-i&=10)//当前底分型为笔中的最底点或者够10周期 保留此底
& && && &{
& && && & if(NeedPrint(i))& &Print(&Di_11:&,i);
& && && & HasFirstDi=1;
& && && & previousDi=i;
& && && &}
& && && &else //当前底分型不是笔中的最低点且不够10周期 删除此底
& && && &{
& && && &&&if(NeedPrint(i))& &Print(&Di_12:&,i);
& && && &&&DingOrDi=0;
& && && &}
& && &&&else//保留此底
& && && &HasFirstDi=1;
& && && &previousDi=i;
& && && &if(NeedPrint(i))& &Print(&Di_13:&,i);
& & //买卖点计算
& & // MaiMaiDianJiSuan(i);
&&int k=0;
&&for(int m=1;m&Bm++)
& &&&if(DingOrDi[m]==1)//
& && & IndicatorBuffer1[m]=High[m];
& && & if(k&2)
& && && &high=High[m];
& && && &k++;
& & else if(DingOrDi[m]==-1)//
& && & IndicatorBuffer1[m]=Low[m];
& && & if(k&2)
& && && &low=Low[m];
& && && &k++;
& && & IndicatorBuffer1[m]=0;
& &return(0);
bool IsDingFenXing(int i)
//(High&=High[i+1]&&High&=High[i-1]&&Low&=Low[i+1]&&Low&=Low[i-1])||
& && &if(i&=4)
& && && & if(iHighest(NULL,0,MODE_HIGH,9,i-4)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && &else if(i==3)
& && && & if(iHighest(NULL,0,MODE_HIGH,8,i-3)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && & else if(i==2)
& && && & if(iHighest(NULL,0,MODE_HIGH,7,i-2)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && & else if(i==1)
& && && & if(iHighest(NULL,0,MODE_HIGH,6,i-1)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && & else if(i==0)
& && && & if(iHighest(NULL,0,MODE_HIGH,5,i-0)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && & }& && &
bool IsDiFenXing(int i)
//(Low&=Low[i+1]&&Low&=Low[i-1]&&High&=High[i+1]&&High&=High[i-1])||
& &&&if(i&=4)
& && && & if(iLowest(NULL,0,MODE_LOW,9,i-4)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && &else if(i==3)
& && && & if(iLowest(NULL,0,MODE_LOW,8,i-3)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && & else if(i==2)
& && && & if(iLowest(NULL,0,MODE_LOW,7,i-2)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && & else if(i==1)
& && && & if(iLowest(NULL,0,MODE_LOW,6,i-1)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
& && & else if(i==0)
& && && & if(iLowest(NULL,0,MODE_LOW,5,i-0)==i)
& && && && & {
& && && && &&&return (true);
& && && && & }
& && && &&&else
& && && && & {
& && && && &&&return (false);
& && && && & }
int ComputeMacdArea(int nBars)
for(int i=nB i&=1; i--)
& &//计算MACD红绿柱面积&&Begin
& && &&&MACDAreaBuffer=0;
& && &&&double HistogramBuffer1_iplus1,HistogramBuffer1_i,HistogramBuffer2_iplus1,HistogramBuffer2_i;
& && &&&HistogramBuffer1_iplus1=iCustom(NULL,0,&Ljp_MACD&,2,i+1);
& && &&&HistogramBuffer1_i=iCustom(NULL,0,&Ljp_MACD&,2,i);
& && &&&HistogramBuffer2_iplus1=iCustom(NULL,0,&Ljp_MACD&,3,i+1);
& && &&&HistogramBuffer2_i=iCustom(NULL,0,&Ljp_MACD&,3,i);
& &//计算红柱面积
& && &if(HistogramBuffer1_i&0)//目前是红柱
& && &&&if(HistogramBuffer2_iplus1&0)//前一个周期是绿柱
& && && & MACDAreaBuffer=HistogramBuffer1_i;
& && &&&else
& && && & MACDAreaBuffer=MACDAreaBuffer[i+1]+HistogramBuffer1_i;
& && & else&&if(HistogramBuffer2_i&0)//目前是绿柱
& && &&&//计算绿柱面积
& && &&&if(HistogramBuffer1_iplus1&0)//前一个周期是红柱
& && && & MACDAreaBuffer=HistogramBuffer2_i;
& && &&&else
& && && & MACDAreaBuffer+=HistogramBuffer2_i+MACDAreaBuffer[i+1];
& && & else //目前没有红绿柱,HistogramBuffer1_i,HistogramBuffer2_i均为0
& && && &//Print(&i=&,i,&,Time=&,Time,&,Bars=&,Bars); //经测试发现,只有计算的最初两个柱子红绿柱才会均为0
& && && &MACDAreaBuffer=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function& && && && && && && && & |
//+------------------------------------------------------------------+
int init()
& &IndicatorBuffers(4);
& &IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
& &//---- indicators
& &if(type==1)
& && &&&SetIndexStyle(0,DRAW_SECTION,STYLE_DOT);
& && &&&//SetIndexStyle(0,DRAW_SECTION);
& && & SetIndexStyle(0,DRAW_ARROW);
& && & SetIndexArrow(0,161);// 159小圆点 222耳机 114 方框 116菱形&&可查看所有箭头形状
& &SetIndexBuffer(0,IndicatorBuffer1);
& &SetIndexEmptyValue(0,0);
& &SetIndexBuffer(1,DingOrDi);
& &SetIndexBuffer(2,MACDAreaBuffer);
& &SetIndexBuffer(3,MaiMaiDianBuffer);
& &SetIndexStyle(3,DRAW_ARROW,0,0,Red);
& &SetIndexArrow(3,159);
& &//---- name for DataWindow and indicator subwindow label
& &IndicatorShortName(&FenBi&);
& &SetIndexLabel(0,&FenBiValue&);
& &SetIndexLabel(1,&DingOrDi&);
& &SetIndexLabel(2,&Area_MACD&);
& &SetIndexLabel(3,&MaiMaiDian&);
& &//Print(&Point=&,Point,&,&,&Digits=&,Digits);
& &if(Symbol()==&SILVER&)
& &&&Deviation=50;
& & // Print(Symbol());
& &else&&if(Symbol()==&GOLD&)
& &&&Deviation=50;
& & //&&Print(Symbol());
& &return(0);
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function& && && && && && && &&&|
//+------------------------------------------------------------------+
int deinit()
& &return(0);
int HasGap(int m,int n) //判断是否有缺口
&&for(int i=m;i&n;i--)
& &&&if(Low&High[i-1] || High&Low[i-1])&&
& &&&return (1);
& &return (0);
//+------------------------------------------------------------------+
积分13832&理想币2817 个&彩币1 个&共享币97 个&注册时间&
理想高二级同学
还需要 6168 积分才能升级
MT4平台技术指标之“多功能MACD双线特色指标”
MT4指标源码&&
MT4平台自定义指标使用方法
& & 因MT4平台没有双线MACD指标,本博一年前编写了双线MACD指标,并在使用过程中增添了部分特色功能。现将指标源码公开。请在尊重知识产权的前提下使用本代码,否则本博以后就不公开代码了。
& & 本MACD指标有以下特色:
&&1.有MACD黄白线、红绿柱。(这个不算特色,只是恢复了MACD指标的本来面目,呵呵。)
&&2.声音和画面提醒平仓功能。默认没有打开。如需打开此功能,可以在加载指标时双击输入参数中的第二个参数&NeedOrderWarning&,把&false&改为&true&。或者在加载指标后修改指标参数(如果不会,请百度一下)。如下图:
如果打开此功能,在以下三种情况下,会提示您平仓:
1).有一定赢利后,再从赢利变为亏损时。
2).开仓后长时间(指标内设置为25分钟,可自行调整)无赢利时,按时间止损法则提示止损。
3).开仓后赢利较多,按赢利的50%回撤法则提示止赢。
&&3.突破盘整区间报警。此功能默认是关闭的。可通过改变NeedAlert为true打开此功能。打开方法请参考第二步。打开此功能后请设置好盘整区间,最低点设置到LowPrice中,最高点设置到HighPrice中,请参看上图(图中的盘整区间为0-99999,哈哈)。
& & 下图中把盘整区间改为(注意NeedAlert要设为true)。
设置后会在MACD指标区显示盘整区间,并在价格突破盘整区间后声音提醒。如下图:
&&4.交易提醒。此功能可以在MACD指标内设置重要的提醒内容。可通过改变上图中的Warning的内容而改变提醒内容。如下图:
&&效果如下:
&&5.红绿柱极值点变色。(代码中有,默认关闭了)
&&该指标源代码如下:(MT4平台自定义指标使用方法)
// This is the correct computation and display of MACD.
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Snow
#property indicator_color2 Gold
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_color5 Olive
extern bool NeedAlert=
extern bool NeedOrderWarning=
extern double HighPrice=99999;
extern double LowPrice=0;
extern string Warning = &&;
//---- input parameters
extern int& && & FastMAPeriod=12;
extern int& && & SlowMAPeriod=26;
extern int& && & SignalMAPeriod=9;
//---- buffers
double MACDLineBuffer[];
double SignalLineBuffer[];
double HistogramBuffer1[];
double HistogramBuffer2[];
double HistogramBuffer3[];
//---- variables
string ShortN
int shouldCreateWarning=1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function& && && && && && && && & |
//+------------------------------------------------------------------+
int init()
& &IndicatorBuffers(5);
& &IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
& &//---- indicators
& &SetIndexStyle(0,DRAW_LINE);
& &SetIndexBuffer(0,MACDLineBuffer);
& &SetIndexDrawBegin(0,SlowMAPeriod);
& &SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
& &SetIndexBuffer(1,SignalLineBuffer);
& &SetIndexDrawBegin(1,SlowMAPeriod+SignalMAPeriod);
& &SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
& &SetIndexBuffer(2,HistogramBuffer1);
& &SetIndexDrawBegin(2,SlowMAPeriod+SignalMAPeriod);
& &SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1);
& &SetIndexBuffer(3,HistogramBuffer2);
& &SetIndexDrawBegin(3,SlowMAPeriod+SignalMAPeriod);
& &SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,1);
& &SetIndexBuffer(4,HistogramBuffer3);
& &SetIndexDrawBegin(4,SlowMAPeriod+SignalMAPeriod);
& &//---- name for DataWindow and indicator subwindow label
& &if(NeedOrderWarning) temp=&OrderWarningOpened&;&&else temp=&&;
& &if(NeedAlert)
& &&&ShortName=&MACD(&+FastMAPeriod+&,&+SlowMAPeriod+&,&+SignalMAPeriod+&)&
& && && && && && && &&&+& AlertOpened&+&(&+DoubleToStr(LowPrice,1)+&--&+DoubleToStr(HighPrice,1)+&) &+
& &&&ShortName=&MACD(&+FastMAPeriod+&,&+SlowMAPeriod+&,&+SignalMAPeriod+&)&+& &+
& &IndicatorShortName(ShortName);
& &SetIndexLabel(0,&MACD&);
& &SetIndexLabel(1,&Signal&);
& &SetIndexLabel(2,&Red&);
& &SetIndexLabel(3,&Green&);
& &SetIndexLabel(4,&Extreme&);
& &shouldCreateWarning=1;
& &return(0);
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function& && && && && && && &&&|
//+------------------------------------------------------------------+
int deinit()
& &ObjectDelete(&Label_Warning&);
& &//Print(&deinit~~~~~~~~~~~~&);
& &return(0);
int OrderWarning()
&&static int count=0;
&&int FontS
&&int objNumber=0;
&&for(int i=0;i&5;i++)//一个帐户订单数限制在5个以内,放在这里而不是在下面循环的开头是因为帐户切换时,不同帐户订单不一样
& && &if(ObjectFind(&OrderWarning1&+i)!=-1) ObjectDelete(&OrderWarning1&+i);
& && &if(ObjectFind(&OrderWarning2&+i)!=-1) ObjectDelete(&OrderWarning2&+i);
& && &if(ObjectFind(&OrderWarning3&+i)!=-1) ObjectDelete(&OrderWarning3&+i);
&&for(int pos=0;pos&OrdersTotal();pos++)
& && &if(!OrderSelect(pos,SELECT_BY_POS,MODE_TRADES))
& && &&&Print(&OrderSelect error:#&,GetLastError());
& && &else
& && & int PointOfProfit=OrderProfit()/OrderLots();//黄金的赢利点数,如需使用其它品种,此值需修改
& && & //Print(PointOfProfit,&,&,(Close[0]-OrderOpenPrice())*100);//经测试,两者计算出的利润正好差点差50点
& && & //if(pos==1)Print(TimeHour(OrderOpenTime()),&:&,TimeMinute(OrderOpenTime()));
& && & //Print(MarketInfo(Symbol(),MODE_POINT));//经测试,黄金此值为0.01,白银为0.001
& && & //Print(MarketInfo(Symbol(),MODE_SPREAD));//经测试,黄金此值为50,白银为30
& && & int SpreadValueInPoints=MarketInfo(Symbol(),MODE_SPREAD);
& && & double MaxPrice=0,MinPrice=;
& && & int DuringTime=0;
& && & //求出从定单下单开始到现在的最高价和最低价
& && & for(i=0; i&B i++)
& && && & {
& && && && &//if(pos==0 && i&=1)Print(OrderOpenTime(),&-&,Time);
& && && &&&
& && && && &if(iHigh(NULL,PERIOD_M1,i)&MaxPrice) {MaxPrice=iHigh(NULL,PERIOD_M1,i);}
& && && && &if(iLow(NULL,PERIOD_M1,i)&MinPrice) {MinPrice=iLow(NULL,PERIOD_M1,i);}
& && && &&&// if(pos==1&& i&35) Print(i);
& && && && &if(OrderOpenTime()-iTime(NULL,PERIOD_M1,i)&=0)//定单时间是以秒为单位的
& && && && &{
& && && && &&&
& && && && &}
& && && & }
& && && &//if(pos==0) Print(MinPrice,&-&,MaxPrice);
& && && &//Print(i);
& && && &DuringTime=i;
& && && &//Print(&DuringTime:&,DuringTime);
& && & switch(count)
& && && &&&case 0:
& && && && && & Color=Y
& && && && && & FontSize=20;
& && && && && &
& && && &&&case 1:
& && && && && & Color=LawnG
& && && && && & FontSize=20;
& && && && && &
& && && &&&case 2:
& && && && && & Color=R
& && && && && & FontSize=20;
& && && && && &
& && && &&&default:
& && && && && &
& && && &}
& && & bool HasProfit=false,Need50Percent=false,NeedBalance=
& && & double MaxProfit=0;//最大利润点数,负数为亏损点数
& && & if(PointOfProfit&0) HasProfit=
& && & if(OrderType()==OP_BUY)
& && && & MaxProfit=(MaxPrice-OrderOpenPrice())*100;//最大曾经赢利点数,因报价就是平仓价。不需扣除点差。
& && && & if(MaxProfit&=200) //曾经赢利200个点以上才使用50%赢利法则
& && && & {
& && && && &if(PointOfProfit&MaxProfit/2) Need50Percent=
& && && & }
& && && & else if(MaxProfit&=100)//曾经赢利100个点以上使用赢亏平衡止损法则
& && && & {
& && && && & if(PointOfProfit&0) NeedBalance=
& && && & }
& && && & //if(pos==2)Print(MaxPrice,&-&,OrderOpenPrice(),& &,MaxPrice-OrderOpenPrice());
& && && & //Print(OrderOpenPrice());
& && &&&else if(OrderType()==OP_SELL)
& && && & MaxProfit=(OrderOpenPrice()-MinPrice)*100-SpreadValueInP//最大曾经赢利点数,扣除点差后
& && && & if(MaxProfit&=200) //曾经赢利200个点以上才使用50%赢利法则
& && && & {
& && && && &if(PointOfProfit&MaxProfit/2) Need50Percent=
& && && & }
& && && & else if(MaxProfit&=100)//曾经赢利100个点以上使用赢亏平衡止损法则
& && && & {
& && && && & if(PointOfProfit&0) NeedBalance=
& && && & }
& && &&&else//挂单
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
& && & //时间止损法则
& && & if(DuringTime&25 && !HasProfit)
& && && & if(!ObjectCreate(&OrderWarning1&+pos, OBJ_LABEL, 0, 0, 0))
& && && &&&{
& && && && &&&Print(&error: cannot create OrderWarning1 object! code #&,GetLastError());
& && && &&&}
& && && &&&else
& && && &&&{
& && && && & ObjectSet(&OrderWarning1&+pos, OBJPROP_XDISTANCE, 100);
& && && && & ObjectSet(&OrderWarning1&+pos, OBJPROP_YDISTANCE, 10+objNumber*30);
& && && && & ObjectSetText(&OrderWarning1&+pos, &(定单&+pos+&)&+&赢利点数:&+PointOfProfit+&(Max:&+DoubleToStr(MaxProfit,0)+&)&
& && && && && && && && && & +&~~~时间止损:&+DuringTime+&分钟!&, FontSize,&微软雅黑&,Color);
& && && && & PlaySound(&expert.wav&);
& && && && & objNumber++;
& && && &&&}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~& && &
& && &&&//50%止赢法则
& && &&&if(Need50Percent)
& && && & if(!ObjectCreate(&OrderWarning2&+pos, OBJ_LABEL, 0, 0, 0))
& && && &&&{
& && && && &&&Print(&error: cannot create OrderWarning2 object! code #&,GetLastError());
& && && &&&}
& && && &&&else
& && && &&&{
& && && && & ObjectSet(&OrderWarning2&+pos, OBJPROP_XDISTANCE, 100);
& && && && & ObjectSet(&OrderWarning2&+pos, OBJPROP_YDISTANCE, 10+objNumber*30);
& && && && & ObjectSetText(&OrderWarning2&+pos, &(定单&+pos+&)&+&赢利点数:&+PointOfProfit+&(Max:&+DoubleToStr(MaxProfit,0)+&)&
& && && && && && && && && &&&+&~~~50%法则止赢!&,FontSize,&微软雅黑&,Color);
& && && && & PlaySound(&expert.wav&);
& && && && & objNumber++;
& && && &&&}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~& && &
& && && &//赢亏平衡止损法则
& && && &if(NeedBalance)
& && && &{
& && && & if(!ObjectCreate(&OrderWarning3&+pos, OBJ_LABEL, 0, 0, 0))
& && && &&&{
& && && && &&&Print(&error: cannot create OrderWarning3 object! code #&,GetLastError());
& && && &&&}
& && && &&&else
& && && &&&{
& && && && & ObjectSet(&OrderWarning3&+pos, OBJPROP_XDISTANCE, 100);
& && && && & ObjectSet(&OrderWarning3&+pos, OBJPROP_YDISTANCE, 10+objNumber*30);
& && && && & ObjectSetText(&OrderWarning3&+pos, &(定单&+pos+&)&+&赢利点数:&+PointOfProfit+&(Max:&+DoubleToStr(MaxProfit,0)+&)&
& && && && && && && && && &+&~~~赢亏平衡止损!&, FontSize,&微软雅黑&,Color);
& && && && & PlaySound(&expert.wav&);
& && && && & objNumber++;
& && && &&&}
& && && &}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~& && &
& & count=(count+1)%3;
//+------------------------------------------------------------------+
//| Custom indicator iteration function& && && && && && && && && && &|
//+------------------------------------------------------------------+
int start()
&&// if(Period()==PERIOD_M1 || Period()==PERIOD_M5)
&&if(NeedOrderWarning)
& && &OrderWarning();
&&//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
& &int counted_bars = IndicatorCounted();
& &//---- check for possible errors
& &if (counted_bars&0) {Print(counted_bars); return(-1);}
& &//---- last counted bar will be recounted
& &if (counted_bars&0) counted_bars--;
& &limit = Bars - counted_
& &if (NeedAlert)
& && & if(& &(Close[0]&HighPrice && Close[1]&=HighPrice)
& && && &&&||(Close[0]&HighPrice && Close[1]&HighPrice && Close[2]&=HighPrice)
& && && &&&||(Close[0]&LowPrice && Close[1]&=LowPrice)
& && && &&&||(Close[0]&LowPrice && Close[1]&LowPrice && Close[2]&=LowPrice)
& && && &)
& && && & {
& && && && & //Alert(&区间&,LowPrice,&-&,HighPrice,&被突破&);
& && && && & PlaySound(&expert.wav&);
& && && && & //PlaySound(&alert.wav&);
& && && & }
& &if(shouldCreateWarning==1 && Warning!=&&) //在指标窗口创建提醒信息
& &&&int indexofWindow=WindowFind(ShortName);
& &&&if(!ObjectCreate(&Label_Warning&, OBJ_LABEL,indexofWindow,0,0))
& && && &Print(&error: cannot create Label_object! code #&,GetLastError());
& && && &Print(&WindowIndex=&,indexofWindow);
& && && &if(GetLastError()==4200) shouldCreateWarning=0;//对象已存在
& && &else
& && &&&shouldCreateWarning=0;
& && &ObjectSet(&Label_Warning&,OBJPROP_XDISTANCE, 368);
& && &ObjectSet(&Label_Warning&,OBJPROP_YDISTANCE, 0);
& && &//ObjectSet(&Label_Warning&,OBJPROP_STYLE, STYLE_DOT);
& && &ObjectSetText(&Label_Warning&,Warning, 12, &Times New Roman&,C'255,0,0');
& &int FangDaBeiShu=2;
& &for(int i= i&=0; i--)
& && &HistogramBuffer1=0;
& && &HistogramBuffer2=0;
& && &HistogramBuffer3=0;
& && &MACDLineBuffer =& &iMACD(NULL,0,FastMAPeriod,SlowMAPeriod,SignalMAPeriod,PRICE_CLOSE,MODE_MAIN,i);
& && &SignalLineBuffer = iMACD(NULL,0,FastMAPeriod,SlowMAPeriod,SignalMAPeriod,PRICE_CLOSE,MODE_SIGNAL,i);
& &&&if(MACDLineBuffer - SignalLineBuffer&0)
& && && & HistogramBuffer1 = (MACDLineBuffer - SignalLineBuffer)*FangDaBeiS
& && &else
& && && & HistogramBuffer2 = (MACDLineBuffer - SignalLineBuffer)*FangDaBeiS
& &return(0);
//+------------------------------------------------------------------+
积分13832&理想币2817 个&彩币1 个&共享币97 个&注册时间&
理想高二级同学
还需要 6168 积分才能升级
MT4的缠论自动画线及macd5,MT4 zup136蝴蝶指标:
积分13832&理想币2817 个&彩币1 个&共享币97 个&注册时间&
理想初一级同学
还需要 1764 积分才能升级
如闻天书,如有实战画图就易理解了。
积分2236&理想币598 个&彩币0 个&共享币144 个&注册时间&
理想小四级同学
还需要 271 积分才能升级
如闻天书,如有实战画图就易理解了。
积分429&理想币191 个&彩币0 个&共享币100 个&注册时间&
理想高三级同学
还需要 8558 积分才能升级
谢谢分享!!!!!!!!!!
积分21442&理想币11062 个&彩币0 个&共享币322 个&注册时间&
理想小六级同学
还需要 296 积分才能升级
这里用MT4的人应该极少吧.楼主问错地方了?
积分1704&理想币79 个&彩币5 个&共享币104 个&注册时间&
理想博士级同学(菠菜一段)
还需要 38918 积分才能升级
这个太深奥,,,,,,,,,,
积分261082&理想币214548 个&彩币960 个&共享币8673 个&注册时间&
快速回复主题
禁用 URL 识别
使用个人签名
接收新回复邮件通知
发帖请务遵守本站的相关规则,所有发表(包括转发)政治、色情非法信息者本站将实时提供发贴者个人信息给公安局,追究责任,特此申明!
具体规则请参见《》
您需要登录后才可以发帖
发表帖子[完成后可按 Ctrl+Enter 发布]
理想论坛上的网友发表的帖子纯属个人意见,理想论坛不负任何责任!广告赞助商内容与本站无关!
理想论坛值班电话[9:30~18:30]: &#6 5518-1  &#6 5518-2(广告)
工业和信息化部信息备案:
无安全提问
母亲的名字
爷爷的名字
父亲出生的城市
您其中一位老师的名字
您个人计算机的型号
您最喜欢的餐馆名称
驾驶执照的最后四位数字
手机版本,改版说明

我要回帖

更多关于 mt4指标 的文章

 

随机推荐