0
EA를 코딩하려고합니다. 가까운 조건이 충족되는 경우 EA에서 모든 공개 거래를 닫고 싶습니다. 잠재적으로 1 개 이상의 공개 거래가 있습니다).MetaTrader Terminal 4 전략 테스터에서 공개 거래를 닫을 수 없습니다
여기는 폐업 관련 섹션 코드이며 Strategy Tester를 통해 실행하면 내 거래를 종료하지 않는 것으로 나타났습니다.
Total=0; // Amount of orders
for(int i=1; i<=OrdersTotal(); i++) // Loop through orders
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If there is the next one
{ // Analyzing orders:
if (OrderSymbol()!=Symb)continue; // Another security
Total++; // Counter of market orders
}
}
while(true) // Loop of closing orders
{
if (OrderType()==0 && Close_Buy_Condition==true) // Order Buy is opened & Close Buy Condition is true
{
for (c=Total-1; c>=0; c--)
{
RefreshRates(); // Refresh rates
Ans=OrderClose(OrderTicket(),Lot,Bid,Slippage); // Closing Buy
}
}
if (OrderType()==1 && Close_Sell_Condition==true) // Order Sell is opened & Close Sell Condition is true
{
for (d=Total-1; d>=0; d--)
{
RefreshRates(); // Refresh rates
Ans=OrderClose(OrderTicket(),Lot,Ask,Slippage); // Closing Sell
}
}
break; // Exit while
}
입니다. 안녕하세요. 그것은 루프에 갇혀있는 것 같습니다. 어딘가에서 누락 된 선이 있습니까? 고맙습니다. – chweet
OrdersTotal()이 0 일 때 루프가 멈추게됩니다. 보류중인 주문을 닫지 않으면 OrdersTotal()이 열린 + 보류 위치의 수를 반환합니다. OrdersTotal()은> 0이 될 것이므로 조건을 변경해야합니다 약간. – Hadu
도움을 주셔서 감사합니다. – chweet