Go Back   BabyPips.com Forex Forum > "The Holy Grails" > Free Forex Trading Systems
Free Forex Trading Systems Got the "Holy Grail" system? Want to share it for free and become everyone's hero? This is the place to do it. (No advertisers please!) Also, follow along as our very own Pip Surfer posts daily updates from his Cowabunga System in the Pip My System Forex Blog.

Welcome to the BabyPips.com forum!

You are currently viewing our boards as a guest which allows you to view the discussions, but prevents you from contributing. By joining our FREE community you will be able to do all of the following:

  • Post topics & responses to other discussions
  • Communicate privately with other members (PM)
  • Respond to polls
  • Upload content
  • Post comments on our blogs
  • Contribute on our Forexpedia

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.



Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-18-2008, 11:29 PM
Senior Member
 

Join Date: Mar 2008
Location: Montana
Posts: 122
Send a message via Skype™ to mtandk0614
Default Please Help edit an EA

Hello Everybody,
I am using an EA that I like alot. It simply places a sell order when the RSI goes above 80, and a buy order when it goes below 20.

Here are the lines of code that are currently being used to perform those actions....

double diRSI0=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,0);
double diRSI1=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,0);

if ((diRSI0>80)){
OpenSell();
return(0);
}

if ((diRSI1<20)){
OpenBuy();
return(0);
}


I would like to to these indicators...Using the default Bollinger Bands, I would like to to work as follows....

If RSI > 80 & the last bar closed above the top BB line, Sell
If RSI < 20 & the last bar closed below the bottom BB line, Buy

Would anybody be able to assit w/ the lines of code I need to add ?

What "double" lines do I need, and how to I make it ensure both "double" lines are true for it to activate the buy/sell ??

Thank you for any feedback.
Reply With Quote
  #2 (permalink)  
Old 03-19-2008, 01:24 AM
Sweet Pip's Avatar
Superior Master Contributor and Member
 

Join Date: Nov 2007
Location: BC, Canada
Posts: 747
Default

How much coding have you done before? And is that EA going to be used with MT4?

Reply With Quote
  #3 (permalink)  
Old 03-19-2008, 01:48 AM
Senior Member
 

Join Date: Mar 2008
Location: Montana
Posts: 122
Send a message via Skype™ to mtandk0614
Default

Zero Coding using this program.

I do have coding experiance with non-related scripting.

and this is being used in mt4 (already running, just want a little additional cushion...I like the idea of very few trades, but high % chance of ending in a positive result...hence trading at the high and lows of RSI)
Reply With Quote
  #4 (permalink)  
Old 03-19-2008, 02:06 AM
Senior Member
 

Join Date: Mar 2008
Location: Montana
Posts: 122
Send a message via Skype™ to mtandk0614
Default Copy of the EA

Here is a copy of the EA that I am working with.

I downloaded it free form forex-tsp/forums.

Very effective and simple to use, I just want to add the BB...or any other suggestions an more experianced trader may have to go with the goal of fewer trades for high % profit. I dont know how to save it as attachment...so here it is.

#property copyright "newdigital"
#property link "http://www.forex-tsd.com"
#define MAGIC 751518

extern double lStopLoss = 200;
extern double sStopLoss = 200;
extern double lTakeProfit = 400;
extern double sTakeProfit = 400;
extern double lTrailingStop = 10;
extern double sTrailingStop = 10;
extern color clOpenBuy = Blue;
extern color clCloseBuy = Aqua;
extern color clOpenSell = Red;
extern color clCloseSell = Violet;
extern color clModiBuy = Blue;
extern color clModiSell = Red;
extern string Name_Expert = "RSI";
extern int Slippage = 4;
extern bool UseHourTrade = false;
extern int FromHourTrade = 9;
extern int ToHourTrade = 17;
extern bool UseSound = false;
extern string NameFileSound = "alert.wav";
extern double Lots = 0.01;
extern int RSIPeriod=14;


void deinit() {
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start(){
if (UseHourTrade){
if (!(Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {
Comment("Time for trade has not come else!");
return(0);
} else Comment("");
}else Comment("");
if(Bars<100){
Print("bars less than 100");
return(0);
}
if(lStopLoss<10){
Print("StopLoss less than 10");
return(0);
}
if(lTakeProfit<10){
Print("TakeProfit less than 10");
return(0);
}
if(sStopLoss<10){
Print("StopLoss less than 10");
return(0);
}
if(sTakeProfit<10){
Print("TakeProfit less than 10");
return(0);
}

double diRSI0=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,0);
double diRSI1=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,0);

if(AccountFreeMargin()<(1000*Lots)){
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (!ExistPositions()){

if ((diRSI0>80)){
OpenSell();
return(0);
}

if ((diRSI0>90)){
OpenSell();
return(0);
}

if ((diRSI1<20)){
OpenBuy();
return(0);
}

if ((diRSI1<10)){
OpenBuy();
return(0);
}

}
TrailingPositionsBuy(lTrailingStop);
TrailingPositionsSell(sTrailingStop);
return (0);
}

bool ExistPositions() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
return(True);
}
}
}
return(false);
}
void TrailingPositionsBuy(int trailingStop) {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
if (OrderType()==OP_BUY) {
if (Bid-OrderOpenPrice()>trailingStop*Point) {
if (OrderStopLoss()<Bid-trailingStop*Point)
ModifyStopLoss(Bid-trailingStop*Point);
}
}
}
}
}
}
void TrailingPositionsSell(int trailingStop) {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
if (OrderType()==OP_SELL) {
if (OrderOpenPrice()-Ask>trailingStop*Point) {
if (OrderStopLoss()>Ask+trailingStop*Point || OrderStopLoss()==0)
ModifyStopLoss(Ask+trailingStop*Point);
}
}
}
}
}
}
void ModifyStopLoss(double ldStopLoss) {
bool fm;
fm = OrderModify(OrderTicket(),OrderOpenPrice(),ldStopL oss,OrderTakeProfit(),0,CLR_NONE);
if (fm && UseSound) PlaySound(NameFileSound);
}

void OpenBuy() {
double ldLot, ldStop, ldTake;
string lsComm;
ldLot = GetSizeLot();
ldStop = GetStopLossBuy();
ldTake = GetTakeProfitBuy();
lsComm = GetCommentForOrder();
OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldSto p,ldTake,lsComm,MAGIC,0,clOpenBuy);
if (UseSound) PlaySound(NameFileSound);
}
void OpenSell() {
double ldLot, ldStop, ldTake;
string lsComm;

ldLot = GetSizeLot();
ldStop = GetStopLossSell();
ldTake = GetTakeProfitSell();
lsComm = GetCommentForOrder();
OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldSt op,ldTake,lsComm,MAGIC,0,clOpenSell);
if (UseSound) PlaySound(NameFileSound);
}
string GetCommentForOrder() { return(Name_Expert); }
double GetSizeLot() { return(Lots); }
double GetStopLossBuy() { return (Bid-lStopLoss*Point);}
double GetStopLossSell() { return(Ask+sStopLoss*Point); }
double GetTakeProfitBuy() { return(Ask+lTakeProfit*Point); }
double GetTakeProfitSell() { return(Bid-sTakeProfit*Point); }
Reply With Quote
  #5 (permalink)  
Old 03-19-2008, 02:30 AM
Sweet Pip's Avatar
Superior Master Contributor and Member
 

Join Date: Nov 2007
Location: BC, Canada
Posts: 747
Default

Quote:
Originally Posted by mtandk0614 View Post
Hello Everybody,
I am using an EA that I like alot. It simply places a sell order when the RSI goes above 80, and a buy order when it goes below 20.

Here are the lines of code that are currently being used to perform those actions....

double diRSI0=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,0);
double diRSI1=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,0);




double mBBL = iBands(NULL,RSIPERIOD,20,2,0,PRICE_CLOSE,MODE_LOWE R,0);
double mBBU = iBands(NULL,RSIPERIOD,20,2,0,PRICE_CLOSE,MODE_UPPE R,0);


if ((diRSI0>80 && Close[1] > mBBU )){
OpenSell();
return(0);
}

if ((diRSI1<20 && Close[1] < mBBL )){
OpenBuy();
return(0);
}


I would like to to these indicators...Using the default Bollinger Bands, I would like to to work as follows....

If RSI > 80 & the last bar closed above the top BB line, Sell
If RSI < 20 & the last bar closed below the bottom BB line, Buy

Would anybody be able to assit w/ the lines of code I need to add ?

What "double" lines do I need, and how to I make it ensure both "double" lines are true for it to activate the buy/sell ??

Thank you for any feedback.
I think the code noted in red should work. I put the RSIPERIOD in with the BBands as they would probably be using the same period as the RSI I would think...and that variable is defined somewhere else in the code I presume.

Oh, and after previewing my post, it looks like this forum's text editor put a "space" in the word Lower (LOWE R), so just in case it looks like that to you, there shouldn't be one.

Hope that helps
Reply With Quote
  #6 (permalink)  
Old 03-19-2008, 02:36 AM
Sweet Pip's Avatar
Superior Master Contributor and Member
 

Join Date: Nov 2007
Location: BC, Canada
Posts: 747
Default

Oops...that RSIPERIOD should be RSIPeriod...I was just copying & pasting from one of my EA's... ...and somethings are very "case sensitive".
Reply With Quote
Reply



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -4. The time now is 03:23 PM.
Content Relevant URLs by vBSEO 3.2.0
"The definition of insanity is doing the same thing over and over and expecting different results."
Albert Einstein