Please edit your post and Use the code button when pasting code (alt+ S)
double currentprice= Open[0] double MA200=iMA(Symbol(),0,200,0,0,0,0) <------ double RSI1CUSTOM=iRSI(NULL,0,period,applied_price,barshift); <------
These should all be inside OnTick()
Please edit your post and Use the code button when pasting code (alt+ S)
These should all be inside OnTick()
Thanks but I don't understand why it gives me 3 errors again
{ if ((currentprice<MA200)&&(RSI1CUSTOM==70)&&(currentprice<lastPrice))
{int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,StopLoss,TakeProfit,NULL,0,0,Red);}
else ((currentprice>MA200)&&(RSI1CUSTOM==30)&&(currentprice>lastPrice))
{int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Bid,0,StopLoss,TakeProfit,NULL,0,0,Green);}}
'}' - expressions are not allowed on a global scope dado.mq4 53 94
Please edit your post and Use the code button when pasting code (alt+ S)
Was there something that you did not understand?
Was there something that you did not understand?
yes, I'm not able to do this
Was there something that you did not understand?
Can you help me please? There is an error but I don't know where
It gives me " 'if' - expressions are not allowed on a global scope "
void OnTick()
Can you help me please? There is an error but I don't know where
It gives me " 'if' - expressions are not allowed on a global scope "
void OnTick()
i have corrected the code for you
#property copyright "" #property link "" #property version "1.00" #property strict extern int period = 200; extern int applied_price = 0; extern int barshift = 1; extern int TakeProfit=120; extern int StopLoss=150; extern double Lots=1; int ticket=0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double currentprice= Open[0]; double MA200=iMA(Symbol(),0,200,0,0,0,0); double RSI1CUSTOM=iRSI(NULL,0,period,applied_price,barshift); //--- if((currentprice<MA200)&&(RSI1CUSTOM==70)) ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Bid+StopLoss*Point,Bid-TakeProfit*Point,NULL,0,0,Red); //--- if((currentprice>MA200)&&(RSI1CUSTOM==30)) ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Ask-StopLoss*Point,Ask+TakeProfit*Point,NULL,0,0,Green); return; } //+------------------------------------------------------------------+
i have corrected the code for you
check these...you should use > or >= for 70 and < or <= for 30
if((currentprice<MA200)&&(RSI1CUSTOM==70)) ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Bid+StopLoss*Point,Bid-TakeProfit*Point,NULL,0,0,Red); //--- if((currentprice>MA200)&&(RSI1CUSTOM==30)) ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Ask-StopLoss*Point,Ask+TakeProfit*Point,NULL,0,0,Green);
Here you go, i fixed it all for you ;)
#property copyright "" #property link "" #property version "1.00" #property strict int Magic=1234; extern int period = 200; extern int applied_price = 0; extern int barshift = 1; extern int TakeProfit=120; extern int StopLoss=150; extern double Lots=1.0; int ticket=0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double currentprice= Open[0]; double MA200=iMA(Symbol(),0,200,0,0,0,0); double RSI1CUSTOM=iRSI(NULL,0,period,applied_price,barshift); //--- if(positions()==0) { if((currentprice<MA200)&&(RSI1CUSTOM>=70)) ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Bid+StopLoss*Point,Bid-TakeProfit*Point,NULL,Magic,0,Red); //--- if((currentprice>MA200)&&(RSI1CUSTOM<=30)) ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Ask-StopLoss*Point,Ask+TakeProfit*Point,NULL,Magic,0,Green); } return; } //+------------------------------------------------------------------+ int positions() { int pos=0; for(int k = OrdersTotal() - 1; k >= 0; k--) { if(!OrderSelect(k, SELECT_BY_POS)) break; if(OrderSymbol()!=Symbol()&&OrderMagicNumber()!=Magic) continue; if(OrderCloseTime() == 0 && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { if(OrderType() == OP_BUY) pos = 1; //Long position if(OrderType() == OP_SELL) pos = -1; //Short positon } } return(pos); } //+------------------------------------------------------------------+

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The system gives me 5 errors but I don't know why. Someone hepls me pleeaaseee?!?!
extern int period = 200;
double RSI1CUSTOM=iRSI(NULL,0,period,applied_price,barshift); <------
void OnTick()
{
{ if ((currentprice<MA200)&&(RSI1CUSTOM==70)) <------
{int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,StopLoss,TakeProfit,NULL,0,0,Red);}
if ((currentprice>MA200)&&(RSI1CUSTOM==30))
{int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Bid,0,StopLoss,TakeProfit,NULL,0,0,Green);}
}
}