|
很容易的修改万能指标代码 1
改变红色代码 您的买入卖出条件
#property copyright "SH Lim"
#property link "[email protected]"
#property indicator_chart_window
#property indicator_color1 White
#property indicator_color2 Yellow
extern bool Alertbuy = false;
extern bool Alertsell = false;
extern int distance = 5;
extern int Symbol_1_Kod=181; // 可以改 100 至 255
extern string NameFileSound = "alert.wav";
#property indicator_buffers 2
//---- input parameters
//---- buffers
double UpBuffer[];
double DnBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
// IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW,0,0);
SetIndexArrow(0,Symbol_1_Kod);
SetIndexBuffer(0,UpBuffer);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW,0,0);
SetIndexArrow(1,Symbol_1_Kod);
SetIndexBuffer(1,DnBuffer);
SetIndexEmptyValue(1,0.0);
SetIndexLabel(0,"Up Signal");
SetIndexLabel(1,"Down Signal");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor 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=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i = 0 ;i < limit ;i++)
{
//indicators
double m1 = iCustom(NULL,0, "MTF_MACD_inColor", 15, 12, 26, 9, 0, 0, i);
double m1a = iCustom(NULL,0, "MTF_MACD_inColor", 15, 12, 26, 9, 0, 1, i);
double m2 = iCustom(NULL,0, "MTF_MACD_inColor", 30, 12, 26, 9, 0, 0, i);
double m2a = iCustom(NULL,0, "MTF_MACD_inColor", 30, 12, 26, 9, 0, 1, i);
double m3 = iCustom(NULL,0, "MTF_MACD_inColor", 240, 12, 26, 9, 0, 0, i);
double m3a = iCustom(NULL,0, "MTF_MACD_inColor", 240, 12, 26, 9, 0, 1, i);
//end of indicators
if((m1>m1a)&&(m2>m2a)&&(m3>m3a)) // Up Trend Condition 上升趋势条件
{
UpBuffer = iLow(Symbol(),0,i)-(distance*Point); // Signal Location 信号位置
DnBuffer = EMPTY_VALUE;
if (Alertbuy==1) Alert("H4 Buy at Ask=",Ask,", Bid=",Bid," Symbol=",Symbol());
}
else if((m1<m1a)&&(m2<m2a)&&(m3<m3a)) // Down Trend Condition 下降趋势条件
{
UpBuffer = EMPTY_VALUE;
DnBuffer = iHigh(Symbol(),0,i)+(distance*Point); // Signal Location 信号位置
if (Alertsell==1) Alert("H4 Sell at Ask=",Ask,", Bid=",Bid," Symbol=",Symbol());
}
else
{
DnBuffer = EMPTY_VALUE;
UpBuffer = EMPTY_VALUE;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
万能指标代码 2
很容易的修改万能指标代码 !
改变红色代码 您的买入卖出条件
#property copyright "SH Lim"
#property link "[email protected]"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Yellow
#property indicator_width1 1 //
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3
//---- input parameters
extern int BarWidth = 1,
CandleWidth = 3;
//---- buffers
double Bar1[],
Bar2[],
Candle1[],
Candle2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorShortName("My");
IndicatorBuffers(4);
SetIndexBuffer(0,Bar1);
SetIndexBuffer(1,Bar2);
SetIndexBuffer(2,Candle1);
SetIndexBuffer(3,Candle2);
SetIndexStyle(0,DRAW_HISTOGRAM,0,BarWidth);
SetIndexStyle(1,DRAW_HISTOGRAM,0,BarWidth);
SetIndexStyle(2,DRAW_HISTOGRAM,0,CandleWidth);
SetIndexStyle(3,DRAW_HISTOGRAM,0,CandleWidth);
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void SetCandleColor(int col, int i)
{
double high,low,bodyHigh,bodyLow;
{
bodyHigh = MathMax(Open,Close);
bodyLow = MathMin(Open,Close);
high = High;
low = Low;
}
Bar1 = low; Candle1 = bodyLow;
Bar2 = low; Candle2 = bodyLow;
switch(col)
{
case 1: Bar1 = high; Candle1 = bodyHigh; break;
case 2: Bar2 = high; Candle2 = bodyHigh; break;
}
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for(int i = MathMax(Bars-1-IndicatorCounted(),1); i>=0; i--)
{
// indicators
double m1 = iCustom(NULL,0, "MTF_MACD_inColor", 15, 12, 26, 9, 0, 0, i);
double m1a = iCustom(NULL,0, "MTF_MACD_inColor", 15, 12, 26, 9, 0, 1, i);
double m2 = iCustom(NULL,0, "MTF_MACD_inColor", 30, 12, 26, 9, 0, 0, i);
double m2a = iCustom(NULL,0, "MTF_MACD_inColor", 30, 12, 26, 9, 0, 1, i);
double m3 = iCustom(NULL,0, "MTF_MACD_inColor", 240, 12, 26, 9, 0, 0, i);
double m3a = iCustom(NULL,0, "MTF_MACD_inColor", 240, 12, 26, 9, 0, 1, i);
//end indicators
if((m1>m1a)&&(m2>m2a)&&(m3>m3a)) SetCandleColor(1,i); //Up Trend Condition 上升趋势条件
else if((m1<m1a)&&(m2<m2a)&&(m3<m3a)) SetCandleColor(2,i); // Down Trend Condition 下降趋势条件
}
return(0);
}
//+------------------------------------------------------------------+
|
|