向老师们请教一个关于编程的问题 新评论 [删除] 2008.12.03 08:23 请问以下程式在说什么? 这个程式的思路是什么? if(PipValue == 0) PipValue = 5; //---- if(PreviousOpenOrders > OpenOrders) { for(cnt=OrdersTotal();cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode = OrderType(); //---- if(OrderSymbol() == Symbol()) { if(mode == OP_BUY) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Blue); //---- if(mode == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Red); return(0); } } } PreviousOpenOrders = OpenOrders; //---- if(OpenOrders >= MaxTrades) ContinueOpening = False; else ContinueOpening = True; //---- if(LastPrice == 0) { for(cnt = 0; cnt < OrdersTotal(); cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode = OrderType(); //---- if(OrderSymbol() == Symbol()) { LastPrice = OrderOpenPrice(); //---- if(mode == OP_BUY) myOrderType = 2; //---- if(mode == OP_SELL) myOrderType=1; } } } //---- if(OpenOrders < 1) { myOrderType = 3; //---- if(iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN,1) > iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 2)) myOrderType = 2; //---- if(iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1) < iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 2)) myOrderType=1; //---- if(ReverseCondition == 1) if(myOrderType == 1) myOrderType = 2; else if(myOrderType == 2) myOrderType = 1; } // if we have opened positions we take care of them for(cnt = OrdersTotal(); cnt >= 0; cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); //---- if(OrderSymbol() == Symbol()) { if(OrderType() == OP_SELL) if(TrailingStop > 0) if(OrderOpenPrice() - Ask >= (TrailingStop + Pips)*Point) if(OrderStopLoss() > (Ask + Point*TrailingStop)) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point*TrailingStop, OrderClosePrice() - TakeProfit*Point - TrailingStop*Point, 800, Purple); return(0); } //---- if(OrderType() == OP_BUY) if(TrailingStop > 0) if(Bid - OrderOpenPrice() >= (TrailingStop + Pips)*Point) if(OrderStopLoss() < (Bid - Point*TrailingStop)) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point*TrailingStop, OrderClosePrice() + TakeProfit*Point + TrailingStop*Point, 800, Yellow); return(0); } } } Profit = 0; LastTicket = 0; LastType = 0; LastClosePrice = 0; LastLots = 0; //---- for(cnt = 0; cnt < OrdersTotal(); cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); //---- if(OrderSymbol() == Symbol()) { LastTicket = OrderTicket(); //---- if(OrderType() == OP_BUY) LastType = OP_BUY; //---- if(OrderType() == OP_SELL) LastType = OP_SELL; LastClosePrice = OrderClosePrice(); LastLots = OrderLots(); //---- if(LastType == OP_BUY) { if(OrderClosePrice() < OrderOpenPrice()) Profit = Profit - (OrderOpenPrice() - OrderClosePrice())*OrderLots() / Point; //---- if(OrderClosePrice() > OrderOpenPrice()) Profit = Profit + (OrderClosePrice() - OrderOpenPrice())*OrderLots() / Point; } //---- if(LastType == OP_SELL) { if(OrderClosePrice() > OrderOpenPrice()) Profit=Profit - (OrderClosePrice() - OrderOpenPrice())*OrderLots() / Point; //---- if(OrderClosePrice() < OrderOpenPrice()) Profit=Profit+(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point; } } } Profit = Profit*PipValue; text2 = "Profit: $" + DoubleToStr(Profit, 2) + " +/-"; //---- if(OpenOrders >= (MaxTrades - OrderstoProtect) && AccountProtection == 1) { if(Profit >= SecureProfit) { OrderClose(LastTicket, LastLots, LastClosePrice, slippage, Yellow); ContinueOpening = False; return(0); } } //---- if(!IsTesting()) { if(myOrderType == 3) text = "No conditions to open trades"; else text=" "; Comment("LastPrice=", LastPrice, " Previous open orders=", PreviousOpenOrders, "\nContinue opening=", ContinueOpening, " OrderType=", myOrderType, "\n", text2, "\nLots=", lotsi, "\n", text); } //---- if(myOrderType == 1 && ContinueOpening) { if((Bid - LastPrice) >= Pips*Point || OpenOrders < 1) { SellPrice = Bid; LastPrice = 0; //---- if(TakeProfit == 0) tp = 0; else tp = SellPrice - TakeProfit*Point; //---- if(InitialStop == 0) sl=0; else sl=SellPrice+InitialStop*Point; //---- if(OpenOrders != 0) { mylotsi=lotsi; //---- for(cnt = 1; cnt <= OpenOrders; cnt++) if(MaxTrades > 12) mylotsi = NormalizeDouble(mylotsi*1.5, 1); else mylotsi = NormalizeDouble(mylotsi*2, 1); } else mylotsi = lotsi; //---- if(mylotsi > 100) mylotsi = 100; OrderSend(Symbol(), OP_SELL, mylotsi, SellPrice, slippage, sl, tp, NULL, 0, 0, Red); return(0); } } //---- if(myOrderType == 2 && ContinueOpening) { if((LastPrice - Ask) >= Pips*Point || OpenOrders < 1) { BuyPrice = Ask; LastPrice = 0; //---- if(TakeProfit == 0) tp = 0; else tp = BuyPrice + TakeProfit*Point; //---- if(InitialStop == 0) sl = 0; else sl = BuyPrice - InitialStop*Point; //---- if(OpenOrders != 0) { mylotsi = lotsi; //---- for(cnt = 1; cnt <= OpenOrders; cnt++) { if(MaxTrades > 12) mylotsi = NormalizeDouble(mylotsi*1.5, 1); else mylotsi = NormalizeDouble(mylotsi*2, 1); } } else mylotsi = lotsi; //---- if(mylotsi > 100) mylotsi = 100; OrderSend(Symbol(), OP_BUY, mylotsi, BuyPrice, slippage, sl, tp, NULL, 0, 0, Blue); return(0); 10点3.mq4 請高手指教!!!關於修改程序!!! 請高手幫幫忙,急需中.... Script is not fully automated 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
请问以下程式在说什么?
这个程式的思路是什么?
if(PipValue == 0)
PipValue = 5;
//----
if(PreviousOpenOrders > OpenOrders)
{
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
mode = OrderType();
//----
if(OrderSymbol() == Symbol())
{
if(mode == OP_BUY)
OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Blue);
//----
if(mode == OP_SELL)
OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Red);
return(0);
}
}
}
PreviousOpenOrders = OpenOrders;
//----
if(OpenOrders >= MaxTrades)
ContinueOpening = False;
else
ContinueOpening = True;
//----
if(LastPrice == 0)
{
for(cnt = 0; cnt < OrdersTotal(); cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
mode = OrderType();
//----
if(OrderSymbol() == Symbol())
{
LastPrice = OrderOpenPrice();
//----
if(mode == OP_BUY)
myOrderType = 2;
//----
if(mode == OP_SELL)
myOrderType=1;
}
}
}
//----
if(OpenOrders < 1)
{
myOrderType = 3;
//----
if(iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN,1) >
iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 2))
myOrderType = 2;
//----
if(iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1) <
iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 2))
myOrderType=1;
//----
if(ReverseCondition == 1)
if(myOrderType == 1)
myOrderType = 2;
else
if(myOrderType == 2)
myOrderType = 1;
}
// if we have opened positions we take care of them
for(cnt = OrdersTotal(); cnt >= 0; cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
//----
if(OrderSymbol() == Symbol())
{
if(OrderType() == OP_SELL)
if(TrailingStop > 0)
if(OrderOpenPrice() - Ask >= (TrailingStop + Pips)*Point)
if(OrderStopLoss() > (Ask + Point*TrailingStop))
{
OrderModify(OrderTicket(), OrderOpenPrice(),
Ask + Point*TrailingStop,
OrderClosePrice() - TakeProfit*Point - TrailingStop*Point,
800, Purple);
return(0);
}
//----
if(OrderType() == OP_BUY)
if(TrailingStop > 0)
if(Bid - OrderOpenPrice() >= (TrailingStop + Pips)*Point)
if(OrderStopLoss() < (Bid - Point*TrailingStop))
{
OrderModify(OrderTicket(), OrderOpenPrice(),
Bid - Point*TrailingStop,
OrderClosePrice() + TakeProfit*Point + TrailingStop*Point,
800, Yellow);
return(0);
}
}
}
Profit = 0;
LastTicket = 0;
LastType = 0;
LastClosePrice = 0;
LastLots = 0;
//----
for(cnt = 0; cnt < OrdersTotal(); cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
//----
if(OrderSymbol() == Symbol())
{
LastTicket = OrderTicket();
//----
if(OrderType() == OP_BUY)
LastType = OP_BUY;
//----
if(OrderType() == OP_SELL)
LastType = OP_SELL;
LastClosePrice = OrderClosePrice();
LastLots = OrderLots();
//----
if(LastType == OP_BUY)
{
if(OrderClosePrice() < OrderOpenPrice())
Profit = Profit - (OrderOpenPrice() - OrderClosePrice())*OrderLots() / Point;
//----
if(OrderClosePrice() > OrderOpenPrice())
Profit = Profit + (OrderClosePrice() - OrderOpenPrice())*OrderLots() / Point;
}
//----
if(LastType == OP_SELL)
{
if(OrderClosePrice() > OrderOpenPrice())
Profit=Profit - (OrderClosePrice() - OrderOpenPrice())*OrderLots() / Point;
//----
if(OrderClosePrice() < OrderOpenPrice())
Profit=Profit+(OrderOpenPrice()-OrderClosePrice())*OrderLots()/Point;
}
}
}
Profit = Profit*PipValue;
text2 = "Profit: $" + DoubleToStr(Profit, 2) + " +/-";
//----
if(OpenOrders >= (MaxTrades - OrderstoProtect) && AccountProtection == 1)
{
if(Profit >= SecureProfit)
{
OrderClose(LastTicket, LastLots, LastClosePrice, slippage, Yellow);
ContinueOpening = False;
return(0);
}
}
//----
if(!IsTesting())
{
if(myOrderType == 3)
text = "No conditions to open trades";
else
text=" ";
Comment("LastPrice=", LastPrice, " Previous open orders=", PreviousOpenOrders,
"\nContinue opening=", ContinueOpening, " OrderType=", myOrderType, "\n",
text2, "\nLots=", lotsi, "\n", text);
}
//----
if(myOrderType == 1 && ContinueOpening)
{
if((Bid - LastPrice) >= Pips*Point || OpenOrders < 1)
{
SellPrice = Bid;
LastPrice = 0;
//----
if(TakeProfit == 0)
tp = 0;
else
tp = SellPrice - TakeProfit*Point;
//----
if(InitialStop == 0)
sl=0;
else
sl=SellPrice+InitialStop*Point;
//----
if(OpenOrders != 0)
{
mylotsi=lotsi;
//----
for(cnt = 1; cnt <= OpenOrders; cnt++)
if(MaxTrades > 12)
mylotsi = NormalizeDouble(mylotsi*1.5, 1);
else
mylotsi = NormalizeDouble(mylotsi*2, 1);
}
else
mylotsi = lotsi;
//----
if(mylotsi > 100)
mylotsi = 100;
OrderSend(Symbol(), OP_SELL, mylotsi, SellPrice, slippage, sl, tp, NULL, 0, 0, Red);
return(0);
}
}
//----
if(myOrderType == 2 && ContinueOpening)
{
if((LastPrice - Ask) >= Pips*Point || OpenOrders < 1)
{
BuyPrice = Ask;
LastPrice = 0;
//----
if(TakeProfit == 0)
tp = 0;
else
tp = BuyPrice + TakeProfit*Point;
//----
if(InitialStop == 0)
sl = 0;
else
sl = BuyPrice - InitialStop*Point;
//----
if(OpenOrders != 0)
{
mylotsi = lotsi;
//----
for(cnt = 1; cnt <= OpenOrders; cnt++)
{
if(MaxTrades > 12)
mylotsi = NormalizeDouble(mylotsi*1.5, 1);
else
mylotsi = NormalizeDouble(mylotsi*2, 1);
}
}
else
mylotsi = lotsi;
//----
if(mylotsi > 100)
mylotsi = 100;
OrderSend(Symbol(), OP_BUY, mylotsi, BuyPrice, slippage, sl, tp, NULL, 0, 0, Blue);
return(0);