“Doesn't work” - these words do not say anything.
Look in the Terminal Log - there will be a description of the error. (tabs "Experts" and "Journal").
Hi guys,
New to algo trading still learning day by day :)
Thanks for stopping to have a look at this. the code works fine for most the securities I look at and investin with the
expection of the index UK100......why is that?
void OnInit() { //Test Alert("Expert Advisor has been launched"); //display message when robot is launched //Order Setup int MagicNumber=123456; //--- set MagicNumber for your orders identification trade.SetExpertMagicNumber(MagicNumber); int deviation=10; //--- set available slippage in points when buying/selling trade.SetDeviationInPoints(deviation); trade.SetTypeFilling(ORDER_FILLING_RETURN); //--- order filling mode, the mode allowed by the server should be used trade.LogLevel(1); //--- logging mode: it would be better not to declare this method at all, the class will set the best mode on its own trade.SetAsyncMode(true); //--- what function is to be used for trading: true - OrderSendAsync(), false - OrderSend() //Trading Critera int x = 0; if (x == 1){ HeraBuy(); } else{ HeraSell(); } }
Move that part from the OnInit() to the OnTick() :
void OnTick()
{
if (x == 1){
HeraBuy();
}
if (x == -1) {
HeraSell();
}
}
Use 1 for buy, -1 for sell, 0 for nothing (x == 0 is set during initialization)
then ... just set x in the direction you wish according to your strategy ; when you'll change it, don't forget to always reset it to 0 (neutral) otherwise it will continue buying/selling
the messages i am getting in my journal are:
" expert ExpertName (UK100,H1) loaded successfully "
" '50153015': failed market sell 0.10 UK100 sl: 7193.80 tp: 7192.60 [Invaild stops] "
the messages i am getting in my journal are:
" expert ExpertName (UK100,H1) loaded successfully "
" '50153015': failed market sell 0.10 UK100 sl: 7193.80 tp: 7192.60 [Invaild stops] "
TakeProfitLevel = Bid - (TakeProfit+SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL))*Point(); //0.0001 // Take Profit value defined StopLossLevel = Ask + (StopLoss+SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL))*Point(); // Stop loss value defined
On indexes there's often a minimum stop/freeze level you should respect : check the symbol properties.
You sell @ bid and buy @ ask take care of that when calculating your levels : when it'll hit the stop, it'll also be on a bid or ask price
You could also add the spread : SymbolInfoInteger(_Symbol,SYMBOL_SPREAD)
and a checking routine to avoid these errors if you plan to push the ea on the mql's market : the automatic validation is particularly bitchy with errors
On indexes there's often a minimum stop/freeze level you should respect : check the symbol properties.
You sell @ bid and buy @ ask take care of that when calculating your levels : when it'll hit the stop, it'll also be on a bid or ask price
You could also add the spread : SymbolInfoInteger(_Symbol,SYMBOL_SPREAD)
and a checking routine to avoid these errors if you plan to push the ea on the mql's market : the automatic validation is particularly bitchy with errors
That's a completely incorrect advice. You need to check the STOPS_LEVEL but not include them in the SL/TP.
And both SL/TP have to be calculated from the same price.
See the above link to learn how it works.

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
New to algo trading still learning day by day :)
Thanks for stopping to have a look at this. the code works fine for most the securities I look at and investin with the
expection of the index UK100......why is that?