i have a problem with my expert

 

I have a problem with my expert, I created a very simple scalping to try but it doesn't work. very simple RSI> MACD = BUY / MACD> RSI = SELL.
very simple just for testing, but it just makes me BUY in all cases in the test. what should I do?

I put the code below, if I made any mistakes, I am learning

""

extern int MagicNumber=10001; extern double Lots =0.01; extern double StopLoss=5; extern double TakeProfit=5; extern int TrailingStop=50; extern int Slippage=3; //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; if((iRSI(NULL,0,14,PRICE_CLOSE,1)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1))) // Here is your open buy rule { result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; OrderSelect(result,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } if((iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1)>iRSI(NULL,0,14,PRICE_CLOSE,1))) // Here is your open Sell rule { result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint; OrderSelect(result,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } for(int cnt=0;cnt<OrdersTotal();cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) { if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green); return(0); } } } } else { if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } int TotalOrdersCount() { int result=0; for(int i=0;i<OrdersTotal();i++) { OrderSelect(i,SELECT_BY_POS ,MODE_TRADES); if (OrderMagicNumber()==MagicNumber) result++; } return (result); } ""

 
Please edit your post and

use the code button (Alt+S) when pasting code.

I am sure that you didn't write the code in such a jumbled mess. Please make sure that it is readable.

 
  1. 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.05.06
              Messages Editor

  2. “Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
         How To Ask Questions The Smart Way. 2004
              When asking about code

 
Simone Daggianti:

I have a problem with my expert, I created a very simple scalping to try but it doesn't work. very simple RSI> MACD = BUY / MACD> RSI = SELL.
very simple just for testing, but it just makes me BUY in all cases in the test. what should I do?

I put the code below, if I made any mistakes, I am learning

I think you are wrong to compare RSI and MACD. The number of RSI are between 0 and 100, usually say 10 and upper, while MACD is always below 1. So it is clear that  RSI > MACD and never MACD > RSI.
You can try to debug your code.