I need help with this code. It'll sell fine but it won't buy.
There's no errors or warnings.
Code is.
***
Please insert the code correctly: when editing a post, use the button - when the popup appears, paste your code into that popup.
input int MA_Period = 14; input double indicator_level1 = 30; input double indicator_level2 = 70; input ENUM_APPLIED_PRICE MA_Price = PRICE_CLOSE; int OnInit() { RSI = iRSI(NULL,0,MA_Period,MA_Price); if(RSI==INVALID_HANDLE) { Print(" Failed to get the handle of the iRSI indicator"); return(INIT_FAILED); } //--- initialization end return(INIT_SUCCEEDED); } //IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { if(reason==REASON_REMOVE) return; } //IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //+------------------------------------------------------------------+ double rsi1[] ;CloseOrders(); double RSIMA = MA_Period; double Ask = (SymbolInfoDouble(_Symbol, SYMBOL_ASK); double Bid = (SymbolInfoDouble(_Symbol, SYMBOL_BID); //+------------------------------------------------------------------+ if(CopyBuffer(RSI,0,0,3,rsi1)<=0)return; //+------------------------------------------------------------------+ { Buy=( RSIMA > rsilevel1); Sell=(RSIMA < rsilevel2) } //+------------------------------------------------------------------+
Hi,
1. please use #property strict at the top of your source file.
2. then you will see, that some vars are not declared and some parts of
our code make no sense.
3. in my opinion your code should look like this:
void OnTick() { ... bool Buy = false; bool Sell = false; double RSIValue; RSIValue = iRSI(NULL, 0, MA_Period, MA_Price, 0); if (RSIValue > indicator_level1) Buy = true; if (RSIValue < indicator_level2) Sell = true;
I hope, this will help you.
Best regards
Hi Keith,
can you tell me, how you identfy the code as MQL5 code?
RSI = iRSI(NULL,0,MA_Period,MA_Price); if(RSI==INVALID_HANDLE) { Print(" Failed to get the handle of the iRSI indicator"); return(INIT_FAILED); }
You don't create a handle in OnInit for iRSI in MQL4. You just get the RSI value direct without using CopyBuffer.
You don't create a handle in OnInit for iRSI in MQL4. You just get the RSI value direct without using CopyBuffer.
only way to compile it wihtout errors as he wrote - maybe I'm wrong ...
Because it can be seen in @mmee55 code that he is initialising Indicator handles in OnInit(). That is an MQL5 functionality, not MQL4! He is also using "CopyBuffer()" which is an MQL5 function which MQL4 does not have.
And yes, his code does have many compile errors!
EDIT: Oops! Looks like Keith answered before I finished my post! No worries!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I need help with this code. It'll sell fine but it won't buy.
There's no errors or warnings.
Code is.
***