谁懂,不能运行,是什么原因
//+------------------------------------------------------------------+//| 01.mq4 |
//| Copyright 2023, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#propertycopyright"MetaQuotesLtd."
#propertylink "https://www.mql5.com"
#propertyversion "1.00"
#propertystrict
//Inputparameters
inputdoubleLotSize=0.1;
inputintStopLoss=500;
inputintTakeProfit=5000;
intOnInit()
{
//---
return(INIT_SUCCEEDED);
}
voidOnDeinit(constintreason)
{
//---
}
voidOnTick()
{
doublema20=iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0);
doubleangle=MathArctan((iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0)-iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1))/1)*(180/MathPi);
if(angle>30&&Close>ma20&&Close>ma20&&Close>ma20)
{
if(OrdersTotal()==0)
{
//Openlongposition
OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,Bid-StopLoss*Point,Bid+TakeProfit*Point);
}
}
elseif(angle<-30&&Close<ma20&&Close<ma20&&Close<ma20)
{
if(OrdersTotal()==0)
{
//Openshortposition
OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,Ask+StopLoss*Point,Ask-TakeProfit*Point);
}
}
elseif(Close<ma20&&Close>ma20)
{
//Closelongposition
CloseOrder(OP_BUY);
}
elseif(Close>ma20&&Close<ma20)
{
//Closeshortposition
CloseOrder(OP_SELL);
}
}
voidCloseOrder(intorderType)
{
inttotal=OrdersTotal();
for(inti=total-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==orderType)
{
OrderClose(OrderTicket(),OrderLots(),Bid,Slippage);
}
}
}
}
//+------------------------------------------------------------------+
//| 01.mq4 |
//| Copyright 2023, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#propertycopyright"MetaQuotesLtd."
#propertylink "https://www.mql5.com"
#propertyversion "1.00"
#propertystrict
//Inputparameters
inputdoubleLotSize=0.1;
inputintStopLoss=500;
inputintTakeProfit=5000;
input int SlipPage=2;// Slippage
input int MathPi=2;// MathPi
intOnInit()
{
//---
return(INIT_SUCCEEDED);
}
voidOnDeinit(constintreason)
{
//---
}
voidOnTick()
{
doublema20=iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0);
doubleangle=MathArctan((iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0)-iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1))/1)*(180/MathPi);
if(angle>30&&Close>ma20&&Close>ma20&&Close>ma20)
{
if(OrdersTotal()==0)
{
//Openlongposition
OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,Bid-StopLoss*Point,Bid+TakeProfit*Point);
}
}
elseif(angle<-30&&Close<ma20&&Close<ma20&&Close<ma20)
{
if(OrdersTotal()==0)
{
//Openshortposition
OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,Ask+StopLoss*Point,Ask-TakeProfit*Point);
}
}
elseif(Close<ma20&&Close>ma20)
{
//Closelongposition
CloseOrder(OP_BUY);
}
elseif(Close>ma20&&Close<ma20)
{
//Closeshortposition
CloseOrder(OP_SELL);
}
}
voidCloseOrder(intorderType)
{
inttotal=OrdersTotal();
for(inti=total-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==orderType)
{
OrderClose(OrderTicket(),OrderLots(),Bid,SlipPage);
}
}
}
}
问题就是你没有声明slippage和MathPi 张寒轩 发表于 2023-11-11 10:00
问题就是你没有声明slippage和MathPi
大哥 你好厉害 支持下 顶下
页:
[1]