#include <Trade/Trade.mqh>
CTrade trade;
....trade.Sell(0.1,_Symbol, Bid, Bid+20*_Point, Bid-60*_Point, NULL);
}
}
That's my EA, it compile, it has no error but it shows nothing
It is not doing the simulation
it run the simulation, it shows the number os bars used, but it seems like it didnt executed any order
- Please usr the code formate (</> from editor's headline here or Alt+S).
- Use the Debugger (Editor => Debug => hist. Data) and check all your ifs and values of your variables - it is made for this.
-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor -
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014) -
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010) -
trade.Buy(0.1,_Symbol, Ask, Ask-20*_Point, Ask+60*_Point, NULL); ⋮ trade.Sell(0.1,_Symbol, Bid, Bid+20*_Point, Bid-60*_Point, NULL);
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).
-
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
#include <Trade/Trade.mqh>
CTrade trade;
/*Manejadores*/
int ma_9_h = 0;
int ma_15_h = 0;
/*Arrays */
double ma_9_array [];
double ma_15_array [];
int OnInit(){
ma_9_h = iMA(_Symbol,_Period,9,0,MODE_EMA,PRICE_CLOSE);
ma_15_h = iMA(_Symbol,_Period,15,0,MODE_SMA,PRICE_CLOSE);
return(INIT_SUCCEEDED);
}
void OnTick(){
CopyBuffer(ma_9_h,0,1,3,ma_9_array);
CopyBuffer(ma_9_h,0,1,3,ma_15_array);
double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
if(ma_9_array[1] < ma_15_array[0] && ma_9_array[1] > ma_15_array[0]){
trade.Buy(0.1,_Symbol, Ask, Ask-20*_Point, Ask+60*_Point, NULL);
} else if(ma_9_array[1] > ma_15_array[0] && ma_9_array[1] < ma_15_array[0]){
trade.Sell(0.1,_Symbol, Bid, Bid+20*_Point, Bid-60*_Point, NULL);
}
}
That's my EA, it compile, it has no error but it shows nothing
It is not doing the simulation
it run the simulation, it shows the number os bars used, but it seems like it didnt executed any order