Hi, tired of trying to make working EA. Wish to have RSI EA which opens position on particular time. It initializes, no errors are found, but it does not open position. Loaded code on EUR/JPY at 2pm and RIS was at around 50 in 5min chart. What is the problem with that code: extern int RSI_Period = 14; extern int TP = 25; extern int SL = 15; extern double Lots = 0.01; extern double RSI_BuyB = 20; extern double RSI_SellB = 70; extern int timeA = 10; extern int timeB = 23; #define LAST_BAR 1 //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- Print(TimeCurrent()); //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- double rsi.Now = iRSI(Symbol(),Period(),RSI_Period,PRICE_CLOSE,LAST_BAR); bool bullish = rsi.Now > RSI_BuyB; bool bearish = rsi.Now < RSI_SellB; int Cur_Hour=Hour(); // Server time in hours bool trading_time = Cur_Hour >= timeA && Cur_Hour<timeB; if (trading_time) { if (bullish) OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-SL*Point,Bid+TP*Point); if (bearish) OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+SL*Point,Ask-TP*Point); } return(0); }
Hi, tired of trying to make working EA. Wish to have RSI EA which opens position on particular time. It initializes, no errors are found, but it does not open position. Loaded code on EUR/JPY at 2pm and RIS was at around 50 in 5min chart. What is the problem with that code:
Print out your variables to make sure that they're the values you expect.
Print within if(){ Print(......); } conditions to make sure the body of conditions execute.
Check your Logs for any Error# or Messages.
That's also the problem. Tried to print RSI or time. But even Print function does not work. Tired to put in init just to show current time and do not get any pop-up window each 5min when i put that command under 'allert'...
Print out your variables to make sure that they're the values you expect.
Print within if(){ Print(......); } conditions to make sure the body of conditions execute.
Check your Logs for any Error# or Messages.
what info is this giving you ??
int init() { //---- Print(TimeCurrent()); //---- return(0); }
what is it doing ??? what output do you get ?? how often ??
can you explain why you get that result ??
If you want to print the time every tick then how to do that ??
.
See also.....
Special functions
In MQL4, there are three special functions in total. They have predefined names: init(), start(), and deinit(). These may not be used as the names of any other functions. A detailed consideration of special functions is given in Special functions.
From a quick glance at your code, it seems that you consider RSI above 20 to be bullish and below 70 to be bearish.
That means that all RSI values above 20 and below 70 are both bullish and bearish??
deVries, wrote that simplest time function into metaeditor. dragged it into chart, it was loaded successfully. I was using 1M chart. And NOTHING. waited for 5 min and haven;t got any msg about that server time....
int init() { //---- Print(TimeCurrent()); //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- //---- return(0); }
------------------------------------
deVries, wrote that simplest time function into metaeditor. dragged it into chart, it was loaded successfully. I was using 1M chart. And NOTHING. waited for 5 min and haven;t got any msg about that server time....
------------------------------------
if you do it again attach it to chart or change timeframe ....
then check inside 'terminal' coloms 'journal' and 'experts' if you find there the message that has to come from your EA or indicator, script......
print output will not be displayed on chart your program is attached
extern int SL = 15;
if (bullish) OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-SL*Point,Bid+TP*Point); if (bearish) OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+SL*Point,Ask-TP*Point);
If your broker uses the extra digit, then 15 points is 1.5 Pips. This is usually too close to the current price and the OrderSend will fail.
But as you have no error checking code in place, you don't know.
- 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, tired of trying to make working EA. Wish to have RSI EA which opens position on particular time. It initializes, no errors are found, but it does not open position. Loaded code on EUR/JPY at 2pm and RIS was at around 50 in 5min chart. What is the problem with that code: