RSI Automated

To add comments, please log in or register
Henri9323
70
Henri9323  

After some search, i would like to open an order zith a RSI of 70 and a stop lost of 2 and TP of 2
That's my code, but it's do not work .

can you help me

Regards, 

Henri

extern int MagicNumber=10001;

extern double Lots =0.1;

 

//+------------------------------------------------------------------+

//    expert start function

//+------------------------------------------------------------------+

int start()

{

  double MyPoint=Point;

  if(Digits==3 || Digits==5) MyPoint=Point*1;

 

  if( TotalOrdersCount()==0 )

  {

     int result=0;

     if(iRSI(NULL,0,14,PRICE_CLOSE,2)<25) // Achat

     {

        result=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,2,2,MagicNumber,0,Green);

        if(result>0)

        {

         OrderSelect(result,SELECT_BY_TICKET);

         OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);

        }

        return(0);

     }

     if(iRSI(NULL,0,14,PRICE_CLOSE,2)>70)) // Vente

     {

        result=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,2,2,MagicNumber,0,Red);

        if(result>0)

        {

         OrderSelect(result,SELECT_BY_TICKET);

         OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);

        }

        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++;

 

   }

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Helvetica; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}

  return (result);

Mohamad Zulhairi Baba
15983
Mohamad Zulhairi Baba  
Henri9323:

After some search, i would like to open an order zith a RSI of 70 and a stop lost of 2 and TP of 2

what is stoploss at 2 and TP of 2??

result=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,2,2,MagicNumber,0,Green);

this is obviously wrong.
please read the documentation

OrderSend - Trade Functions - MQL4 Reference
OrderSend - Trade Functions - MQL4 Reference
  • docs.mql4.com
Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function. At opening of a market order (OP_SELL or OP_BUY), only the latest prices of Bid (for selling) or Ask (for buying) can be used as open price. If operation is performed with a...
Henri9323
70
Henri9323  
Mohamad Zulhairi Baba:

what is stoploss at 2 and TP of 2??

this is obviously wrong.
please read the documentation

thank you for tour reply muhamad.

i tried with 20 ( 20 for 2 pips) but is not working..

I don't understand?


is it due to ?


  if(Digits==3 || Digits==5) MyPoint=Point*1;
Carl Schreiber
Moderator
7130
Carl Schreiber  

Henri,

before you try to code search first as there is practically nothing that has not been programmed for MQ4/5 yet!

Just search for RSI EA (the lens top right) and you'll have your EA a lot faster!

Carl Schreiber
Moderator
7130
Carl Schreiber  
Don't double post! I deleted your other post!
To add comments, please log in or register