如何编码? - 页 144

 

这是错误的:如果(totalOrders==0 && Magic==OrderMagicNumber() &&

OrderSelect(i-1 , SELECT_BY_POS,MODE_HISTORY) ==true)

因为你在OrderSelect()之前 调用OrderMagicNumber(),所以它可能是指之前的调用。

 
EBK:
哦,对不起,我错误地表达了我的观点。

我想编写一些代码(但我无法做到),如果股权低于某个值,将停止EA交易(或EA交易的一部分)。

谢谢你的帮助,Roger09,但我不需要在图表上显示资产。

试试这个EA

CloseAllBuySell - MQL4代码基础

使用它的想法,制作一个代码,如

if (AccountEquity()<YourValue) closeallorders()。

 

谁能把EMA追踪止损添加到移动平均线 EA样本中?

EMA尾随设置为1

然后将入口改为

Buy=Open[1]>ma && Close[1]>ma;

Sell=Open[1]<ma && Close[1]<ma。

这应该是一个非常好的简单剥头皮程序。

谢谢

贝诺

附加的文件:
 
 

在程序的开头添加

extern int pips=2;//(或你的点数)

然后替换为

if ((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice()))

sl = OrderOpenPrice() ;

if ((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))

sl = OrderOpenPrice() ;[/CODE]

to

[CODE]if ((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice()))

sl = OrderOpenPrice() +pips*Point;

if ((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))

sl = OrderOpenPrice() -pips*Point;
 

谁能帮我在这个指标中设置一个警报,当它画出一个新的箭头时?

谢谢!

附加的文件:
hilow3.mq4  2 kb
 

不,修复它

extern int pips=2;

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

//| 脚本程序启动功能|

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

int start()

{

//----

string curr = Symbol();

int ot = OrdersTotal();

int ords[200], ordType[200], ordTicket[200]; double ordLots[200];

字符串 ordComments[200]。

int ix=0。

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

{

int o = OrderSelect(i, SELECT_BY_POS)。

如果(OrderSymbol() == Symbol()

如果((OrderType() == OP_BUY)|| (OrderType() == OP_SELL))

{

double sl = 0。

如果((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice() ))

sl = OrderOpenPrice() +pips*Point;

如果((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))

sl = OrderOpenPrice() -pips*Point;

如果(sl != 0+10)

OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0)。

}

}

//----

return(0);

 

好了,现在的代码看起来像这样。

extern int pips=10;//

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

//| 脚本程序启动功能|

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

int start()

{

//----

string curr = Symbol();

int ot = OrdersTotal();

int ords[200], ordType[200], ordTicket[200]; double ordLots[200];

字符串 ordComments[200]。

int ix=0。

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

{

int o = OrderSelect(i, SELECT_BY_POS)。

如果(OrderSymbol() == Symbol()

如果((OrderType() == OP_BUY)|| (OrderType() == OP_SELL))

{

double sl = 0。

如果((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice() ))

sl = OrderOpenPrice() +pips*Point;

如果((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))

sl = OrderOpenPrice() -pips*Point;

如果(sl != 0)

OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0)。

}

}

//----

返回(0)。

}

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

 

嗨,Roger09。

非常感谢你对这段代码的帮助。我的脚本代码现在看起来是这样的(我添加了红色的修改,只是为了这个回复,MQ4中的代码看起来就像其他地方的代码)。

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

//| 脚本程序启动功能

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

int start()

{

//----

外来的int pips=2;//

string curr = Symbol();

int ot = OrdersTotal();

int ords[200], ordType[200], ordTicket[200]; double ordLots[200];

字符串 ordComments[200]。

int ix=0。

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

{

int o = OrderSelect(i, SELECT_BY_POS)。

如果(OrderSymbol() == Symbol()

如果((OrderType() == OP_BUY)|| (OrderType() == OP_SELL))

{

double sl = 0。

如果((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice() ))

sl = OrderOpenPrice() +pips*Point;

如果((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))

sl = OrderOpenPrice() -pips*Point;

如果(sl != 0)

OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0)。

}

}

//----

返回(0)。

你能让我知道我的理解是否正确吗?我在这里是盲目的,所以请容忍我。

 

事实上,这将是可行的,但这个代码并不好。不幸的是,我不知道你的主要目标,不能推荐其他东西。