Alain Verleyen: Error is 10030, invalid. Please do some researches and fix your code.
i will do that, i hope it could help as actually it isn't my code, i shifted to MT5 recently and i am only testing default EA found in the MT5 and with the by default settings.
i will do that, i hope it could help as actually it isn't my code, i shifted to MT5 recently and i am only testing default EA found in the MT5 and with the by default settings.
I see, you can learn to fix it or ask someone to do it for you. If you post the code of an EA maybe someone will help you.
//+------------------------------------------------------------------+//| ADX System(barabashkakvn's edition).mq5 |//| System |//| work_a@ukr.net |//+------------------------------------------------------------------+#property copyright"System"#property link"work_a@ukr.net"#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
CPositionInfo m_position; // trade position object
CTrade m_trade; // trading object
CSymbolInfo m_symbol; // symbol info object
CAccountInfo m_account; // account info wrapperinputushort InpTakeProfit = 15; // TakeProfitinputdouble Lots = 1; // Lotinputushort InpTrailingStop = 20; // TrailingStopinputushort InpStopLoss = 100; // StopLoss//---ulong m_magic = 16384;
double ExtTakeProfit = 0.0;
double ExtTrailingStop = 0.0;
double ExtStopLoss = 0.0;
int handle_iADX; // variable for storing the handle of the iADX indicator //+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//SetMarginMode();//if(!IsHedging())// {// Print("Hedging only!");// return(INIT_FAILED);// }//---
m_symbol.Name(Symbol()); // sets symbol nameif(!RefreshRates())
{
Print("Error RefreshRates. Bid=",DoubleToString(m_symbol.Bid(),Digits()),
", Ask=",DoubleToString(m_symbol.Ask(),Digits()));
return(INIT_FAILED);
}
//---
m_trade.SetExpertMagicNumber(m_magic); // sets magic number//--- tuning for 3 or 5 digitsint digits_adjust=1;
if(m_symbol.Digits()==3 || m_symbol.Digits()==5)
digits_adjust=10;
ExtTakeProfit = InpTakeProfit * digits_adjust;
ExtTrailingStop = InpTrailingStop * digits_adjust;
ExtStopLoss = InpStopLoss * digits_adjust;
//--- create handle of the indicator iADX
handle_iADX=iADX(Symbol(),Period(),14);
//--- if the handle is not created if(handle_iADX==INVALID_HANDLE)
{
//--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iADX indicator for the symbol %s/%s, error code %d",
Symbol(),
EnumToString(Period()),
GetLastError());
//--- the indicator is stopped early return(INIT_FAILED);
}
if(Bars(Symbol(),Period())<100)
{
Print("bars less than 100");
return(INIT_FAILED);
}
if(ExtTakeProfit<10)
{
Print("ExtTakeProfit less than 10");
return(INIT_FAILED); // check ExtTakeProfit
}
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
double ADXP,ADXC,ADXDIPP;
double ADXDIPC,ADXDIMP,ADXDIMC;
ADXP = iADXGet(MAIN_LINE, 2);
ADXC = iADXGet(MAIN_LINE, 1);
ADXDIPP = iADXGet(PLUSDI_LINE, 2);
ADXDIPC = iADXGet(PLUSDI_LINE, 1);
ADXDIMP = iADXGet(MINUSDI_LINE, 2);
ADXDIMC = iADXGet(MINUSDI_LINE, 1);
int total=0;
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positionsif(m_position.SelectByIndex(i))
if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
total++;
if(total==0)
{
//--- no opened positions identifiedif(m_account.FreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",m_account.FreeMargin());
return;
}
//--- check for long position (BUY) possibilityif((ADXP<ADXC) && (ADXDIPP<ADXP) && (ADXDIPC>ADXC))
{
if(!RefreshRates())
return;
if(m_trade.Buy(Lots,m_symbol.Name(),m_symbol.Ask(),m_symbol.Bid()-ExtStopLoss*Point(),
m_symbol.Ask()+ExtTakeProfit*Point(),"adx sample"))
{
Print("BUY order opened : ",m_trade.ResultPrice());
}
else
{
Print("Error opening BUY. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription(),
", ticket of deal: ",m_trade.ResultDeal());
return;
}
}
//--- check for short position (SELL) possibilityif((ADXP<ADXC) && (ADXDIMP<ADXP) && (ADXDIMC>ADXC))
{
if(!RefreshRates())
return;
if(m_trade.Sell(Lots,m_symbol.Name(),m_symbol.Bid(),m_symbol.Ask()+ExtStopLoss*Point(),
m_symbol.Bid()-ExtTakeProfit*Point(),"adx sample"))
{
Print("SELL order opened : ",m_trade.ResultPrice());
}
elsePrint("Error opening Sell. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription(),
", ticket of deal: ",m_trade.ResultDeal());
return;
}
return;
}
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positionsif(m_position.SelectByIndex(i))
if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
{
if(m_position.PositionType()==POSITION_TYPE_BUY) // long position is opened
{
if(ADXP>ADXC && ADXDIPP>ADXP && ADXDIPC<ADXC)
{
m_trade.PositionClose(m_position.Ticket()); // close positionreturn; // exit
}
if(ExtTrailingStop>0)
{
if(!RefreshRates())
return;
if(m_symbol.Bid()-m_position.PriceOpen()>Point()*ExtTrailingStop)
{
if(m_position.StopLoss()<m_symbol.Bid()-Point()*ExtTrailingStop)
{
m_trade.PositionModify(m_position.Ticket(),m_symbol.Bid()-Point()*ExtTrailingStop,
m_position.TakeProfit());
return;
}
}
}
}
else
{
if(ADXP>ADXC && ADXDIMP>ADXP && ADXDIMC<ADXC)
{
m_trade.PositionClose(m_position.Ticket()); // close positionreturn; // exit
}
if(ExtTrailingStop>0)
{
if(!RefreshRates())
return;
if((m_position.PriceOpen()-m_symbol.Ask())>(Point()*ExtTrailingStop))
{
if((m_position.StopLoss()>(m_symbol.Ask()+Point()*ExtTrailingStop)) ||
(m_position.StopLoss()==0))
{
m_trade.PositionModify(m_position.Ticket(),m_symbol.Ask()+Point()*ExtTrailingStop,
m_position.TakeProfit());
return;
}
}
}
}
}
return;
}
//+------------------------------------------------------------------+//| Refreshes the symbol quotes data |//+------------------------------------------------------------------+boolRefreshRates()
{
//--- refresh ratesif(!m_symbol.RefreshRates())
return(false);
//--- protection against the return value of "zero"if(m_symbol.Ask()==0 || m_symbol.Bid()==0)
return(false);
//---return(true);
}
//+------------------------------------------------------------------+//| Get value of buffers for the iADX |//| the buffer numbers are the following: |//| 0 - iADXBuffer, 1 - DI_plusBuffer, 2 - DI_minusBuffer |//+------------------------------------------------------------------+double iADXGet(constint buffer,constint index)
{
double ADX[];
ArraySetAsSeries(ADX,true);
//--- reset error code ResetLastError();
//--- fill a part of the iADXBuffer array with values from the indicator buffer that has 0 index if(CopyBuffer(handle_iADX,buffer,0,index+1,ADX)<0)
{
//--- if the copying fails, tell the error code PrintFormat("Failed to copy data from the iADX indicator, error code %d",GetLastError());
//--- quit with zero result - it means that the indicator is considered as not calculated return(0.0);
}
return(ADX[index]);
}
//+------------------------------------------------------------------+
Maybe the downloaded history is not enough
i changed the period to be from 1st of march, now it is giving me these errors, what to do please ?
i changed the period to be from 1st of march, now it is giving me these errors, what to do please ?
Which errors?
these errors, circled in red.
these errors, circled in red.
Maybe in your orderSend() function
i appreciate your help, thank you.
i changed the period to be from 1st of march, now it is giving me these errors, what to do please ?
Error is 10030, invalid. Please do some researches and fix your code.
i will do that, i hope it could help as actually it isn't my code, i shifted to MT5 recently and i am only testing default EA found in the MT5 and with the by default settings.
i will do that, i hope it could help as actually it isn't my code, i shifted to MT5 recently and i am only testing default EA found in the MT5 and with the by default settings.
Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.

Thank you.