help me out to make this EA - page 2

 

Hi Thanks for your reply

sorry for my late reply as i was not well.

the strategy is about rsi only

i need that rsi is above 85 then sell

abd below 20 buy order.

condition

if rsi is above 85 do not buy if it will around 60 to 85 range it should be buy only if this 85 comes after 30-45-60 and 85 sell not like 65-50-70-75-80-70-85 so not sell same for but also

not buy if RSIi is around 20 like 15-20-10-15-30-20-22 but buy if rsi is continue to go below like 70-60-40-20 then buy.

can you please make this EA for me

 

Edit - MyfirstEA and add the following control(s) concept as needed

Your code would look something like and written for clarity.

static bool AllowBuy = true ;

if ( Buytrigger()==true && AllowBuy==true ) 
  {
   OpenBuy();
   AlowBuy=false ;
  } // no more buy trades until
  
if ( BuyTrigger()==false )
  { 
   AlowBuy=true ;
  }

Keep Actions as functions and control as separate parts.

 

Find code


#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables
extern double BuyLots5 = 0.1;
extern int BuyStoploss5 = 20;
extern int BuyTakeprofit5 = 30;


// local variables
double PipValue=1;    // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n";  // use this in custom or utility blocks where you need line feeds
int NDigits = 4;   // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0;  // count of all objects created on the chart, allows creation of objects with unique names
int current = 0;

int  rsi15;
int  rsi10;
int  rsi80;
int  rsi42;
int  rsi62;


int init()
{
    NDigits = Digits;
    
    if (false) ObjectsDeleteAll();      // clear the chart
    
    
    
    
    Comment("");    // clear the chart
}

// Expert start
int start()
{
    if (Bars < 10)
    {
        Comment("Not enough bars");
        return (0);
    }
    if (Terminated == true)
    {
        Comment("EA Terminated.");
        return (0);
    }
    
    OnEveryTick7();
    
}

void OnEveryTick7()
{
    if (true == false && false) PipValue = 10;
    if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;
    
    IfOrderDoesNotExist8();
    
}

void IfOrderDoesNotExist8()
{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }
    
    if (exists == false)
    {
        CustomCode9();
        
    }
}

void CustomCode9()
{
    if (iRSI(NULL, NULL,4,PRICE_CLOSE,0) < 15)
    {
        rsi15  = 15;
                
    }else
    if(iRSI(NULL, NULL,4,PRICE_CLOSE,0) < 80) || (iRSI(NULL, NULL,4,PRICE_CLOSE,0) >78)
    {
        rsi80  = 80;
                
    }else
    if(iRSI(NULL, NULL,4,PRICE_CLOSE,0) > 80) 
    {
        rsi80  = 90;
                
    }
    else
    if(iRSI(NULL, NULL,4,PRICE_CLOSE,0) < 44) || (iRSI(NULL, NULL,4,PRICE_CLOSE,0) > 42)
    {
        rsi42  = 42;
                
    }else
    if(iRSI(NULL, NULL,4,PRICE_CLOSE,0) < 64) || (iRSI(NULL, NULL,4,PRICE_CLOSE,0) >62)
    {
        rsi62  = 62;
                
    }else
    if(iRSI(NULL, NULL,4,PRICE_CLOSE,0) < 10) 
    {
        rsi10  = 10;
               
    }else
    if(iRSI(NULL, NULL,4,PRICE_CLOSE,0) < 80) 
    {
        rsi80  = 80;
                
    }
    CustomIf6();
    
}

void CustomIf6()
{
    if (if(rsi15 || rsi42))
    {
        BuyOrder5();
        
    }
}

void BuyOrder5()
{
    double SL = Ask - BuyStoploss5*PipValue*Point;
    if (BuyStoploss5 == 0) SL = 0;
    double TP = Ask + BuyTakeprofit5*PipValue*Point;
    if (BuyTakeprofit5 == 0) TP = 0;
    int ticket = -1;
    if (true)
    ticket = OrderSend(Symbol(), OP_BUY, BuyLots5, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
    else
    ticket = OrderSend(Symbol(), OP_BUY, BuyLots5, Ask, 4, SL, TP, "My Expert", 1, 0, Blue);
    if (ticket > -1)
    {
        if (true)
        {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
            
    }
    else
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }
}



int deinit()
{
    if (false) ObjectsDeleteAll();
    
    
    
    
}

now it is ok? i m trying this in forex ea generator with custom code but not succeed pls help

 
adityakhanna:

Find code

now it is ok? i m trying this in forex ea generator with custom code but not succeed pls help

If you can explain how this line of code males sense I'll help you.

if (true == false && false) PipValue = 10;
 

it is for 5 digit broker to count pipvalue

that if not 5 digit than pip value is 10 other wise pipvalue is 1 (in 5 digit)

 
adityakhanna - in your own words could you desribe how the if ( condition ) action statement works? Also why does the if statment, RaptorUK mentions, would it do as you expect it to?
 

Ok Forget above code,

pls make EA based on this rule:

Buy: Below 20 RSI but it must come from above 50

Sell : Above 80 RSI but it should come from below 50

not TP/SL but close above 20$ and Close below20$

Lot size : External

Means if we drag EA on chart and RSI is now 20 so dont buy but once rsi go to above 50 and comes again 20 then buy

same for sell condition suppose after TP/SL or new drag on chart if RSi is around 80 do not sell but it has come below 50 and then 80 so sell order placed

Every time above 50 and below 50 condition must be match.

can you please make this EA for me

Thanks

Aditya Khanna

 

One can write it but you wouldn't know if there was a logical error in the code or not only from the way it behaves. Which is why we ask you to understand the code you are looking at.

Break the problem down into separate parts. First concentratate on just the code and the conditions for the Buy.

You know the easy part.

1 check the syntax and parameters of the iRSI() technical indicater found in the documentation

double iRSI( string symbol, int timeframe, int period, int applied_price, int shift)
2 fill the parameters in so you can read and undersand what its doing

LastBarRSI = iRSI(Symbol(),Period(),PIRCE_CLOSE,Shift)

3 The final part of the Buy trigger will be

if(LastBarRSI<RSIEntryValue) SendBuy() ;

4) by incrementing the shift value we can look at other past values of the RSI and test to see if it is following the pattern for entry.

or

4a) we can record the event in a static variable if ( iRSI(Symbol(),Period(),PIRCE_CLOSE,Shift)<50 && iRSI(Symbol(),Period(),PIRCE_CLOSE,Shift+1>50) ) Movebelow=true ;