rsi1=iRSI(NULL,0,14,PRICE_CLOSE,1);
rsi2=iRSI(NULL,0,14,PRICE_CLOSE,0);
if(rsi2>70 && Ask > High[1] + (10*pips2dbl) )
{
Opn_S=true;
}
elseif(rsi2>70 && Ask < High[1] + (10*pips2dbl))
{
Opn_S=false;
}
Here you give value to Opn_S, but you do nothing with it
lastTicket=OrderSend(Symbol(),OP_BUY,mylot(),Ask,0,0,0,"My Comment",magic,0,Green);
{
int cnt;
int NumTrades; // Number of buy and sell trades in this symbol
NumTrades = 0;
for (cnt = OrdersTotal()-1 ; cnt >=0 ; cnt--)
{
if(OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES)==true)
if ( OrderSymbol() != Symbol()) continue;
if ( OrderMagicNumber() != magic) continue;
if(OrderType() == OP_BUY ) NumTrades++;
if(OrderType() == OP_SELL ) NumTrades++;
}
}
then getting my ea to work with my loop by just adding if(NumTrades==0 && Opn_B==true) // No new orders +
this ensures my ea to open just 1 order on a giving chart but now i want to expand my ea to open more than one order i remove NumTrades==0
to let the ea open order unrestricted with my ordersend as little i know now i know we can loop through order for so many reason and when it comes
to the looping for highest order on the chart i dont know that well,but can do it if example is giving. please bear with my little coding knowledge and put me through
below is my ea please assist me
double highest_open_price=0;
int highest_Ticket=-1;
for(int pos=OrdersTotal()-1; pos>=0; pos--)
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES) // Only my orders w/
&& OrderMagicNumber()==0// my magic number
&& OrderSymbol()==Symbol() // and my pair.
&& OrderOpenPrice()>=highest_open_price)
{
highest_open_price=OrderOpenPrice();
highest_Ticket=OrderTicket();
}
double highest_open_price=0;
int highest_Ticket=-1;
for(int pos=OrdersTotal()-1; pos>=0; pos--)
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES) // Only my orders w/
&& OrderMagicNumber()==0// my magic number
&& OrderSymbol()==Symbol() // and my pair.
&& OrderOpenPrice()>=highest_open_price)
{
highest_open_price=OrderOpenPrice();
highest_Ticket=OrderTicket();
}
正如我所说--简单的替换
正如我所说--简单的替换
谢谢GumRai: 但我的进一步问题是,我相信 ?????????() 是 OrderOpenTime()
现在我如何让它与我的交易逻辑一起工作,就像你早期指出的那样
这里没有开单的条件,你改写了lastTicket的值。
你的代码没有逻辑,只有3段完全不相关的代码
===========================================================================================================================
我问的原因是,我在下面的代码......,结果是我想要的,但问题是它在一行中打开了多个订单。见上面的结果图片。
你的代码有三个部分,相互之间没有联系,所以没有逻辑。
我只能得出结论,你从其他EA中复制和粘贴了一些代码,妄想让它们一起工作。
"我相信?????????()是OrderOpenTime()"
证明你不知道这个循环的作用,也不是你写的。
我 的整个代码是这样的,主要是只打开卖出。就像你说的,所有这些断开的结果是允许我的EA打开多个订单和循环的事情,之前只是简单地切断我的订单,像这样
我不确定该EA是写得不好,还是不完整,或者是一个被删除了 大块代码的有效EA。
你说它主要是卖出,但我不认为它可以买入。
开启买入的主要条件是
代码中唯一出现Opn_B的地方是
Opn_B=false
所以没有任何地方可以将其设置为真。
顺便提一下
一个只打开订单的循环--伟大的评论。
我不确定该EA是写得不好,还是不完整,或者是一个被删除了大块代码的有效EA。
你说它主要是卖出,但我不认为它可以买入。
开启买入的主要条件是
代码中唯一出现Opn_B的地方是
所以没有任何地方可以将其设置为真。
顺便提一下
一个只打开订单的循环--伟大的评论。
谢谢你审查我的代码并指出建议和更正。
GumRai:这就是为什么我告诉你,许多人可能不理解,但我理解,你能够理解,因为你非常了解代码。
此外,我有我的理由让EA只开放卖出,我的这个要求的问题使我的EA变得粗糙,但当我得到解决方案时,我将重新组织每件事情。
看一下这个EA,我删除了关闭条件和买入条件, 这使得EA看起来不完整。
.为什么呢,因为我想确保它满足这个条件......,在当前图表符号中的最高开盘价和买入条件下的开盘指令。
当前图表符号中的最高开盘价,如果是买入,在其上方开10个点,如果是卖出,在其下方开10个点。
我去掉了平仓条件,因为我不希望在测试时回测平仓,以确保在其他条件到位之前代码是正确的。
一旦解决方案达成,我将重新组织我的EA,使用适当的关闭条件,这就是为什么我请求你帮助我解决这个问题,尽管你的帮助。
好吧,我已经给了你代码来找到最高开仓价 的订单。
现在只需检查价格是否比这个值至少高出10个点,如果是,就再开一个订单
请GumRai:我怎样才能在EA中放置循环,因为我的方法在回测 中不起作用......。
我是如何做到的?我用最高开盘价 和最高票价 在EA中写了一些条件,但在回测中没有得到我想要的结果。
也许我错过了什么?