Helping with a simple RSI system

 

Hello there,

I really have tried to design this system, read the book and searched the code base, but i couldn't, so please guys, anyone can help me about it....

I want to make a system that

Buy lot 0.01 when RSI 14 Smoothed cross over 30

close the position with 10pips or when RSI 14 Smoothed cross over 70

That's it, and i think if someone helped me with i can modify it and develope it more....

Thanks guys

elbarck

 
elbarck:

Hello there,

I really have tried to design this system, read the book and searched the code base, but i couldn't, so please guys, anyone can help me about it....

I want to make a system that

Buy lot 0.01 when RSI 14 Smoothed cross over 30

close the position with 10pips or when RSI 14 Smoothed cross over 70

That's it, and i think if someone helped me with i can modify it and develope it more....

Thanks guys

elbarck


Start with:


int ticket;
if(iRSI(NULL,0,14,PRICE_CLOSE,0)>30)
{
ticket=OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}

Straight out of the documentation on this site.

 
mixtermind wrote >>

Start with:

Straight out of the documentation on this site.

I searched the documentation and that's all i could do....

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+

int ticket;
if(iRSI(NULL,0,14,PRICE_CLOSE,0)<30)
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}

if(iRSI(NULL,0,14,PRICE_CLOSE,0)>70)
{
OrderClose(order_id,1,Ask,3,Red);
return(0);
}

if(OrderSelect(order_id, SELECT_BY_TICKET)==true)
{
Print("order_id open price is ", OrderOpenPrice());
Print("order_id close price is ", OrderClosePrice());
}
else
Print("OrderSelect returned the error of ",GetLastError());


if(OrderSelect(12, SELECT_BY_POS)==true)
Print("Order #",OrderTicket()," profit: ", OrderTakeProfit());
else
Print("OrderSelect() returns error - ",GetLastError());

but it seems it doesn't work....

 
elbarck:

I searched the documentation and that's all i could do....

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+

int ticket;
if(iRSI(NULL,0,14,PRICE_CLOSE,0)<30)
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}

if(iRSI(NULL,0,14,PRICE_CLOSE,0)>70)
{
OrderClose(order_id,1,Ask,3,Red);
return(0);
}

if(OrderSelect(order_id, SELECT_BY_TICKET)==true)
{
Print("order_id open price is ", OrderOpenPrice());
Print("order_id close price is ", OrderClosePrice());
}
else
Print("OrderSelect returned the error of ",GetLastError());


if(OrderSelect(12, SELECT_BY_POS)==true)
Print("Order #",OrderTicket()," profit: ", OrderTakeProfit());
else
Print("OrderSelect() returns error - ",GetLastError());

but it seems it doesn't work....

You're order_id variable isn't defined. Best to use a for loop to search all open tickets for OP_BUY or OP_SELL and then close accordingly.

 

how can i do that,

may u modify teh code for me?

 

I've used a web-site to design it, but i still can't make it work, it do about 6 trades a month when it should make about 30 trades at least....

I still can't make it trade from 1GMT to 21GMT and to avoid opening trades on Friday....

Thanks

elbarck

Files:
test3.mq4  10 kb
Reason: