2附件嗨,
我有一個零分割錯誤的問題。
我正在研究一個簡單的EA,只是為了練習,
它編譯時沒有錯誤,但是當我在egy測試器中嘗試它時,我在日誌中不斷出現零除錯誤。
我添加了Getlasterror,其中包含打印錯誤的位置,顯示代碼中的行
正如您從附件中看到的那樣
The very last line before the Start return I put if(GetLastError()gt;0) Print(Line 137);
我在開始後的第一行結束了
if(GetLastError()gt; 0)Print(第53行);這就是錯誤發生的地方。
這意味著當它返回時沒有錯誤,但是在Start之後立即出現錯誤。
換句話說,在我的代碼之外!怎麼會發生這種情況?
是egy測試儀的問題還是我做了一些愚蠢的事情。
提前致謝
插入的代碼// --------------------------------------------- --------------------- /| HigherHi LowerLo.mq4 |/|基思|/| http://www.metaquotes.net |/ ----------------------------------------------- ------------------- #property copyright Keith #property鏈接http://www.metaquotes.net/---輸入參數extern int MagicNumber = 1; extern int StopLoss = 50; extern int TakeProfit = 100; extern int DecimalPip = 4; extern int MaxSlippage = 5; extern double RiskPerTrade = 1;雙點;/ ----------------------------------------------- ------------------- /|專家初始化功能|/ ----------------------------------------------- ------------------- int init(){//----/計算Pip decimal int decimal = 4; Pip = 1; for(int a = 1; alt; = DecimalPip; a ){Pip = Pip * 0.1; }/---- return(0); }/ ---------------------------------------------- -------------------- /|專家取消初始化功能|/ ----------------------------------------------- ------------------- int deinit(){//----/---- return(0); }/ ---------------------------------------------- -------------------- /|專家啟動功能|/ ----------------------------------------------- ------------------- int start(){//---- if(GetLastError()gt; 0)Print(第53行); if(高#91; 1#93; gt;高#91; 2#93;低#91; 1#93; gt;低#91; 2#93;)//購買信號串Signal = Buy; if(GetLastError()gt; 0)Print(第57行); if(高#91; 1#93; LT;高#91; 2#93;低#91; 1#93; LT;低#91; 2#93;)//賣出信號信號=賣出; if(GetLastError()gt; 0)Print(第61行);/----------------------------------檢查交易是否已經打開當前對int STicket = 0 ; int BTicket = 0; for(int x = OrdersTotal() - 1; xgt; = 0; x--){OrderSelect(x,SELECT_BY_POS,MODE_TRADES); if(OrderType()lt; = OP_SELL OrderMagicNumber()== MagicNumber)STicket = OrderTicket(); if(OrderType()lt; = OP_BUY OrderMagicNumber()== MagicNumber)BTicket = OrderTicket(); }/-----如果STicket gt; 0,賣出交易已開啟,如果BTicket gt; 0買入交易開啟,如果兩者均為0,則無當前交易//------------- -------------------新的交易? if(GetLastError()gt; 0)Print(第76行); if(STicket == 0 BTicket == 0)//沒有交易開放{if(信號==買入){double ask = MarketInfo(Symbol(),MODE_ASK);/獲取當前要價雙倍StopLoss = Ask - StopLoss * Pip;雙倍TakeProfit = Ask TakeProfit * Pip; if(GetLastError()gt; 0)Print(第86行);/----------------計算LotSize並檢查它是否超過經紀人允許的最小值Step = MarketInfo(Symbol(),MODE_LOTSTEP);雙LossLot = MathAbs(Ask-StopLoss)/MarketInfo(Symbol(),MODE_TICKSIZE)* MarketInfo(Symbol(),MODE_TICKVALUE); int Lot = AccountEquity()* RiskPerTrade100LossLotStep; double LotSize = Lot * Step; if(LotSize lt; MarketInfo(Symbol(),MODE_MINLOT))警報(Lotsize太小而無法交易); else OrderSend(Symbol(),OP_BUY,LotSize,Ask,MaxSlippage * PipPoint,StopLoss,TakeProfit * Pip,NULL,MagicNumber,0,0); } if(Signal == Sell){double bid = MarketInfo(Symbol(),MODE_BID);/獲取當前出價StopLoss = Bid StopLoss * Pip; TakeProfit = Bid -TakeProfit * Pip; if(GetLastError()gt; 0)Print(第106行);/----------------計算LotSize並檢查是否超過經紀人允許的最小值if(GetLastError()gt; 0)Print(第108行); Step = MarketInfo(Symbol(),MODE_LOTSTEP); LossLot = MathAbs(Bid-StopLoss)/MarketInfo(Symbol(),MODE_TICKSIZE)* MarketInfo(Symbol(),MODE_TICKVALUE); Lot = AccountEquity()* RiskPerTrade100LossLotStep; LotSize = Lot * Step; if(LotSize lt; MarketInfo(Symbol(),MODE_MINLOT))警報(Lotsize太小而無法交易);否則OrderSend(符號(),OP_SELL,LotSize,Bid,MaxSlippage * PipPoint,StopLoss,TakeProfit * Pip,NULL,MagicNumber,0,0); if(GetLastError()gt; 0)Print(第121行);/---------------------檢查是否需要關閉交易if(Signal == Buy STicketgt; 0)//開放賣出交易需要收盤{OrderSelect(STicket) ,SELECT_BY_TICKET); OrderClose(STicket,OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),50,Violet); } if(Signal == Sell BTicketgt; 0)//open buy trade needs closing {OrderSelect(BTicket,SELECT_BY_TICKET); OrderClose(BTicket,OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),50,Violet); } if(GetLastError()gt; 0)Print(第137行);/---- return(0); }/ ---------------------------------------------- --------------------
https://www.forex-pedia.com/attachme...8495297788.mq4
https://www.forex-pedia.com/cryptocu...notifiion.html