如何编码? - 页 106

 

这对价格是有效的。他想找到一个指标的最高和最低。

卢克斯

 

你好。

你可以试试这个。

....

int highest=0, lowest=0, bar=WindowBarsPerChart();

for(int shift=0;shift<bar;shift++)

{

double indie=iCustom(.........,shift);

if(highest<indie) highest=indie;

if(lowest==0) lowest=indie;

if(lowest>indie) lowest=indie;

}

.....

注意:这段代码也是计算当前打开的蜡烛图,如果你想只计算关闭的蜡烛图,使用shift=1。

希望这有帮助。

Ardie

 
:: iBarShift将为你找到当天/小时内开始的条形图...或当天/小时内结束的条形图...(取决于你想从哪个时间段或图表开始寻找你的高/低点)。

int iBarShift ( string symbol, int timeframe, datetime time, bool exact=false)

接下来...

使用这些条形位置来寻找iHighest和iLowest的结果

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

int iLowest( 字符串,int timeframe,int type,int count=WHOLE_ARRAY,int start=0)

:: 结果和完成 ,不要在此使用任何循环!

 

按程序刷新重绘指标

你好。

我想找到一种方法来刷新每X分钟的重绘指标。

目前刷新它的唯一方法是在图表上点击指标,然后点击 "确定"。我们可以用MQL4代码来实现自动化吗?

我在codersguru的网站上找到了一些东西,程序化地刷新你的图表|www.metatrader.info, 但它似乎对我不起作用。或者有没有人尝试过并得到不同的结果(工作)?

谢谢你

 

对不起,我的英语不好。

我想计算条件为真时的次数,每条街只有一次。 计算机每条街加起来有许多次。 我做错了什么?

 
IngvarDagmar:
对不起,我的英语不好,我想计算条件为真时的次数,每条街只有一次。 计算机每条街加起来有许多次。 我做错了什么?

使用像这样的函数...

bool NewBar() {

static datetime LastTime = 0;

if (Time[0] != LastTime) {

LastTime = Time[0];

return (true);

} else

return (false);

}

[/php]

Then put an if statement round your main code, like...

[php]

if(NewBar() == true){

// do the main processing here

}

希望这有帮助。

拉克斯

 

你真好,拉克斯。

我发现了这个。

每个条形图只处理一次 - MQL4论坛

Automated 2008.01.15 18:54 你可以在新条形图的第一个刻度处执行你的代码(即在前一个条形图关闭后立即执行)。

这里有一个函数,如果一个新的条形图刚刚形成,将返回TRUE。

// 这个函数在新条形的第一个跳动点(即前一个条形刚刚收盘后)返回TRUE。

bool NewBar()

{

如果(PreviousBarTime<Time[0])

{

PreviousBarTime = Time[0];

return(true);

}

return(false); // 在if-else语句没有被执行的情况下

} 你需要在你的EA的开头声明数据时间PreviousBarTime...

然后在你的代码中,你可以直接使用

if ( NewBar() )

{

...... 你需要在这里收盘后执行的代码 ....

} 谢谢你

automatedfx@gmail.com

---------------------------------------------------

我注意到你使用了STATIC...我查了一下...使用STATIC与全局变量相比有什么好处?

 

多次进场的EA

我想找到或需要帮助创建一个具有以下输入参数的EA。四个独立的交易条目,每个条目 都有手数、止损、追踪止损、收支平衡和盈利目标。

谢谢你

 

在追踪止损选项上需要帮助

我在MQL4论坛发现了这个EA,这是一个相当有趣的EA。

谁能帮助我添加一个追踪止损选项,它可以设置追踪止损,只在我设定的利润值达到后才激活?

他们的想法2.mq4

附加的文件:
 

大家好...

当MACD变成'n'形时,打开卖盘,而当MACD变成'u'形时,EA将打开买盘。

问题是,该EA没有打开任何帖子。在我做了一些回测 之后,该EA也没有打开帖子。

这里是代码...

extern double TakeProfit = 20;

extern double Lots = 0.1;

extern double StopLoss = 20;

extern double MagicNumber = 17384;

extern int FastEMA=12;

extern int SlowEMA=26;

extern int SignalSMA=9;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

double MacdBuffer1[];

double MacdBuffer2[];

double MacdBuffer3[];

double MacdBuffer4[];

double MacdBuffer5[];

double MacdBuffer6[];

double MacdBuffer7[];

double MacdBuffer8[];

int init()

{

//----

//SetIndexBuffer(0, lag1_buffer);

//SetIndexBuffer(1, lag2_buffer);

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

int limit;

int counted_bars=IndicatorCounted();

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---- macd counted in the 1-st buffer

for(int i=0; i<limit; i++)

MacdBuffer1=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

MacdBuffer2=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-1)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-1);

MacdBuffer3=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+1)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+1);

MacdBuffer4=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-2)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-2);

MacdBuffer5=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+2)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+2);

MacdBuffer6=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-3)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-3);

MacdBuffer7=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+3)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+3);

/*Alert( "MacdBuffer7 =",MacdBuffer7);

Alert( "MacdBuffer5 =",MacdBuffer5);

Alert( "MacdBuffer3 =",MacdBuffer3);

Alert( "MacdBuffer1 =",MacdBuffer1);

Alert( "MacdBuffer2 =",MacdBuffer2);

Alert( "MacdBuffer4 =",MacdBuffer4);

Alert( "MacdBuffer6 =",MacdBuffer6);*/

//----

int ticket_buy, ticket_sell, total;

total=OrdersTotal();

//MACD become 'u' shape

if (MacdBuffer7>MacdBuffer5&&MacdBuffer5>MacdBuffer3&&MacdBuffer3>MacdBuffer1

&&MacdBuffer1<MacdBuffer2&&MacdBuffer2<MacdBuffer4&&MacdBuffer4<MacdBuffer6)

{

if (total < 1) {

ticket_buy=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"scalp 1 min - buy",MagicNumber,0,Green);

if(ticket_buy>0)

{

if(OrderSelect(ticket_buy,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

} else {

}

}

//MACD become 'n' shape

if(MacdBuffer7<MacdBuffer5&&MacdBuffer5<MacdBuffer3&&MacdBuffer3<MacdBuffer1

&&MacdBuffer1>MacdBuffer2&&MacdBuffer2>MacdBuffer4&&MacdBuffer4>MacdBuffer6)

{

if (total < 1) {

ticket_sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"scalp 1 min - sell",MagicNumber,0,Red);

if(ticket_sell>0)

{

if(OrderSelect(ticket_sell,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

} else {

}

}

//----

return(0);

}

//+------------------------------------------------------------------+

希望有人能帮我解决这个问题......我不擅长编程,谢谢。