//+------------------------------------------------------------------+//| MACD Sample.mq4 |//| Copyright 2005-2014, MetaQuotes Software Corp. |//| http://www.mql4.com |//+------------------------------------------------------------------+#property copyright"2005-2014, MetaQuotes Software Corp."#property link"http://www.mql4.com"inputdouble TakeProfit =3160;
inputdouble Lots =0.5;
inputdouble TrailingStop =1040;
inputint OpenLevel =22;
inputint CloseLevel=77;
inputintPeriod =85;
inputint Period1 =57;
int LastBars=0;
externint Magic = 110725;
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnTick(void)
{
int cnt,ticket,total;
//---// initial data checks// it is important to make sure that the expert works with a normal// chart and the user did not make any mistakes setting external // variables (Lots, StopLoss, TakeProfit, // TrailingStop) in our case, we check TakeProfit// on a chart of less than 100 bars//---//--- Trade only if new bar has arrivedif(LastBars!=Bars) LastBars=Bars;
elsereturn(0);
if(Bars<100)
{
Print("bars less than 100");
return;
}
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return;
}
//--- to simplify the coding and speed up access data are put into internal variables
total=OrdersTotal();
if(total<1)
{
//--- no opened orders identifiedif(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",AccountFreeMargin());
return;
}
//--- check for long position (BUY) possibilityif(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period)>iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period1))
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-TakeProfit*Point,Bid+TakeProfit*Point,"USDCADH4",Magic,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
elsePrint("Error opening BUY order : ",GetLastError());
return;
}
//--- check for short position (SELL) possibilityif(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period1)<iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period))
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+TakeProfit*Point,Ask-TakeProfit*Point,"USDCADH4",Magic,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice());
}
elsePrint("Error opening SELL order : ",GetLastError());
}
//--- exit from the "no opened orders" blockreturn;
}
//--- it is important to enter the market correctly, but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++)
{
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
//--- long position is openedif(OrderType()==OP_BUY)
{
//--- should it be closed?if(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period1)<iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period))
{
//--- close order and exitif(!OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet))
Print("OrderClose error ",GetLastError());
return;
}
//--- check for trailing stopif(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
//--- modify order and exitif(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green))
Print("OrderModify error ",GetLastError());
return;
}
}
}
}
else// go to short position
{
//--- should it be closed?if(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period)>iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period1))
{
//--- close order and exitif(!OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet))
Print("OrderClose error ",GetLastError());
return;
}
//--- check for trailing stopif(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
//--- modify order and exitif(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red))
Print("OrderModify error ",GetLastError());
return;
}
}
}
}
}
}
//---
}
//+------------------------------------------------------------------+
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()&& OrderMagicNumber()==Magic) // check for symbol
我昨天发了一个请求,一天多过去了,没有动静。
1.去最近的自动取款机,插入卡,输入密码...
2.去最近的银行,进行眼神交流,然后按照情况...
3.去市场。3)去市场。到银行去。提取资金(你可以提取所有的资金,而不仅仅是你自己的资金......) ...
4.如果你必须从MMM取钱,那么即使是坦克也不会帮助你!如果你必须从MMM取钱,那么即使是坦克也不会帮助你。
而且说真的,你不能这样做!
你好,请帮助我理解......如果有其他人的交易,专家顾问会关闭其他人的交易或不打开自己的交易。
你好,请帮助我理解......如果有其他人的交易,专家顾问会关闭其他人的交易或不打开自己的交易。
如果上面写的是,专家顾问关闭手动开启的交易。
如果我这样说的话
如果有任何手动开启的交易,那么专家顾问将不会关闭其他交易,但如果有任何手动开启的交易,它将不会开启自己的交易。
如果上面写的是,专家顾问关闭手动开启的交易。
如果我这样说的话
如果有任何手动开启的交易,那么专家顾问将不会关闭其他交易,但如果有任何手动开启的交易,它将不会开启自己的交易。
我还需要选择开幕时的神奇数字
这是什么?开口表示。问题是,当你使用几个专家顾问时,没有任何问题。 问题只发生在账户中手动开仓的时候。
只要账户上有手动开启的交易,专家顾问就会停止工作。
只要我在代码中删除这个,total=OrdersTotal()。
如果(total<1)
EAs直接上场,但开出大量的交易
这是什么?开口表示。问题是,当你使用几个EA时,没有任何问题。 问题只发生在账户中手动开仓的时候。
只要账户上有手动开启的交易,专家顾问就会停止工作。
只要我在代码中删除这个,total=OrdersTotal()。
如果(total<1)
EAs直接上场,但开出很多交易。
这就是我所说的 - OrdersTotal()是针对所有订单的,你需要一个EA订单
这就是我所说的,OrdersTotal()是所有的订单,你想让EA订单
这是在代替
total=OrdersTotal()。
if(total<1)还是把这一条也留下?