Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-15-2006, 09:21 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Question Calling Programmers/Coders...

Not all mini accounts are created equal...

This same EA is running in two different accounts. Attached are the reports from each one. Also attached is the EA itself. I would like to make the account which is doing orders in the .75 range give orders in the 7.50 range. How can I make this happen.

Here is some of the code from the EA I think this is the part that could be changed? I'm not really a program coder, I'm just learning...please assist..


double LotSize()
{
double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;

if(AccountIsMicro==false) //normal account
{
if (lotMM < 0.1) lotMM = Lots;
if ((lotMM > 0.5) && (lotMM < 1)) lotMM=0.5;
if (lotMM > 1.0) lotMM = MathCeil(lotMM);
if (lotMM > 100) lotMM = 100;
}
else //micro account
{
if (lotMM < 0.01) lotMM = Lots;
if (lotMM > 1.0) lotMM = MathCeil(lotMM);
if (lotMM > 100) lotMM = 100;
}

return (lotMM);

p.s. someone tell me how to post large code in a insert window with a slider bar on the side. I've seen that done but don't know how to do it.
Attached Files
File Type: htm EMA_CROSSmodv2kreport.htm (9.8 KB, 22 views)
File Type: htm EMA_CROSSmodv2k report.htm (76.8 KB, 27 views)
File Type: mq4 EMA_CROSSmodv2k.mq4 (10.9 KB, 26 views)

Last edited by Aaragorn; 06-15-2006 at 09:31 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-15-2006, 10:08 PM
Senior Member
 
Join Date: May 2006
Posts: 213
Morpheus is on a distinguished road
If it was me, I'd probably delete the whole function and put

Code:
lotMM=Lots;
Just not a fan of the whole money management thing since most of the time, our trades won't last more than a week anyway.

to post code, use

"[" "code" "] "

but without the quotations. Had to do it like that or it would think I wanted to use it.

Last edited by Morpheus; 06-15-2006 at 10:15 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-15-2006, 10:29 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
it's not workin it tells me that I have exceeded the character limit. so the [] thing,...I must not be doing it right. could you explain it again more specifically?
this is what i'm doing...


[
//+------------------------------------------------------------------+
//| EMA_CROSS_2.mq4 |
//| Coders Guru |
//| http://www.forex-tsd.com |
//+------------------------------------------------------------------+
// ultima versiune cu micro lots! H1 si D1

#property copyright "Coders Guru"
#property link "http://www.forex-tsd.com"

//---- Trades limits
extern double
TakeProfit = 15,
TrailingStop = 20,
StopLoss = 20;
extern bool
UseStopLoss = false;

//---- EMAs paris
extern int
ShortEma = 2,
LongEma = 5;

//---- Crossing options
extern bool
immediate_trade = true, //Open trades immediately or wait for cross.
reversal = false, //Use the originally reversal crossing method or not
ConfirmedOnEntry = false;

//---- Money Management
extern double
Lots = 1;
extern bool
MM = true, //Use Money Management or not
AccountIsMicro = true; //Use Micro-Account or not
extern int
Risk = 10; //10%

extern int
MAGICMA = 20060301;
extern bool
Show_Settings = true;

//---- Global varaibles
static int
TimeFrame = 0;
datetime
CheckValueTime;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
if(Show_Settings) Print_Details();
else Comment("");
return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
TimeFrame=Period(); //Prevent counting the cross while the user changing the timeframe
return(0);
}

bool isNewSumbol(string current_symbol)
{
//loop through all the opened order and compare the symbols
int total = OrdersTotal();
for(int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
string selected_symbol = OrderSymbol();
if (current_symbol == selected_symbol)
return (False);
}
return (True);
}

int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_direction = 0;

if(TimeFrame!=Period())
{
TimeFrame=Period();
return (0);
}

if(line1>line2)current_direction = 1; //up
if(line1<line2)current_direction = 2; //down

if(immediate_trade==false)
{
if(last_direction == 0) //first use
{
last_direction = current_direction;
return(0);
}
}

if(current_direction != last_direction) //changed
{
last_direction = current_direction;
return (last_direction);
}
else
{
return (0); //not changed
}
}

//--- Bassed on Alex idea! More ideas are coming
double LotSize()
{
double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;

if(AccountIsMicro==false) //normal account
{
if (lotMM < 0.1) lotMM = Lots;
if ((lotMM > 0.5) && (lotMM < 1)) lotMM=0.5;
if (lotMM > 1.0) lotMM = MathCeil(lotMM);
if (lotMM > 100) lotMM = 100;
}
else //micro account
{
if (lotMM < 0.01) lotMM = Lots;
if (lotMM > 1.0) lotMM = MathCeil(lotMM);
if (lotMM > 100) lotMM = 100;
}

return (lotMM);
}

string BoolToStr ( bool value)
{
if(value) return ("True");
else return ("False");
}
void Print_Details()
{
string sComment = "";
string sp = "----------------------------------------\n";
string NL = "\n";

sComment = sp;
sComment = sComment + "TakeProfit=" + DoubleToStr(TakeProfit,0) + " | ";
sComment = sComment + "TrailingStop=" + DoubleToStr(TrailingStop,0) + " | ";
sComment = sComment + "StopLoss=" + DoubleToStr(StopLoss,0) + " | ";
sComment = sComment + "UseStopLoss=" + BoolToStr(UseStopLoss) + NL;
sComment = sComment + sp;
sComment = sComment + "immediate_trade=" + BoolToStr(immediate_trade) + " | ";
sComment = sComment + "reversal=" + BoolToStr(reversal) + NL;
sComment = sComment + sp;
sComment = sComment + "Lots=" + DoubleToStr(Lots,0) + " | ";
sComment = sComment + "MM=" + BoolToStr(MM) + " | ";
sComment = sComment + "Risk=" + DoubleToStr(Risk,0) + "%" + NL;
sComment = sComment + sp;

Comment(sComment);
}

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int cnt, ticket, total;
double SEma, LEma, SEmaLAST, LEmaLAST;

string comment = "";
if(reversal==true) comment = "EMA_CROSS_Counter-Trend";
if(reversal==false) comment = "EMA_CROSS_Trend-Following";

if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}

static int isCrossed = 0;

if(ConfirmedOnEntry)
{
if(CheckValueTime==iTime(NULL,TimeFrame,0)) return(0); else CheckValueTime = iTime(NULL,TimeFrame,0);

SEma = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
LEma = iMA(NULL,0,LongEma ,0,MODE_EMA,PRICE_CLOSE,1);
SEmaLAST = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
LEmaLAST = iMA(NULL,0,LongEma ,0,MODE_EMA,PRICE_CLOSE,2);

if(SEmaLAST<LEmaLAST && SEma>LEma) isCrossed = 1;
if(SEmaLAST>LEmaLAST && SEma<LEma) isCrossed = 2;
}
else
{
SEma = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,0);
LEma = iMA(NULL,0,LongEma ,0,MODE_EMA,PRICE_CLOSE,0);

isCrossed = Crossed (LEma,SEma);
}

if(reversal==false)
{
if(isCrossed==1) isCrossed = 2;
else if(isCrossed==2) isCrossed = 1;
}

if(MM==true) Lots = LotSize(); //Adjust the lot size

total = OrdersTotal();

// TRAILING STOP
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
.....
]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-15-2006, 10:45 PM
Senior Member
 
Join Date: May 2006
Posts: 213
Morpheus is on a distinguished road
Do you want money management? Or just fixed lots ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-15-2006, 10:47 PM
Senior Member
 
Join Date: May 2006
Posts: 213
Morpheus is on a distinguished road
Ahhhh

I think you should set AccountisMicro=false;

//

You need to actually type "code" and brackets, too. Sorry for the confusion.
.

Last edited by Morpheus; 06-15-2006 at 10:51 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-15-2006, 11:30 PM
Senior Member
 
Join Date: May 2006
Posts: 213
Morpheus is on a distinguished road
I've uploaded a modification of his EA. This one uses fixed lots. No moneymanagement whatsoever. It appears to still backtest well. Whatever you want the lots to be, just enter it in the code where it says "LOts = " and it will be the same lots throughout and then when you want to change it, go in an change it same way again. Try it. It appears to me, though, that the money management in this EA is kind of important since it's like a hedging strategy so use this one at your own risk.

You could also just increase the risk % . It looks like you have it at 10 % . Increase to 40 % . Or something and see what that does. It should increase your lots.
Attached Files
File Type: mq4 EMA_CROSSmodv2k fixed lots.mq4 (10.3 KB, 21 views)

Last edited by Morpheus; 06-15-2006 at 11:38 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-16-2006, 12:16 AM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
i'm sorry the obvious has escaped me once again...

everything I wanted to fix isn't in fact broken I just didn't look at the bottom of the inputs window when attaching it to the chart... all i have to do is change the lot parameter when i use it and that handles it.

i didn't use the slider bar on the inputs window and didn't see all the additional parameters which i could change...that's WHY the program was built with the option!!!

I still havn't figured out how to do the post code in window thing either...

fyi I'm going live with this now using a small lot size to see if it performs as expected and if so I'll increase the lot size as I feel more confident with it.

sometimes I'm amazed by the size of my own skitomas.

Last edited by Aaragorn; 06-16-2006 at 12:21 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 06-16-2006, 12:54 AM
Senior Member
 
Join Date: May 2006
Posts: 213
Morpheus is on a distinguished road
I'm live on the demo with it. It booked a win already but I still have an open trade going.

Can someone explain how it works? Kind of complicated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 06-16-2006, 02:54 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
all I know is that it executes on the cross signal of the two moving averages.

the fact that it hedges with an opposing position which I bets on closing on the retracement is a hedging strategy. I am also running this in demo and have run numerous strategy tests on various settings. It appears to run as well in the 5m as the 15m TF. I think the key to making this really work is scale/stepping the opposing position with some kind of probability curve. If you put a 2period EMA and a 5period EMA on a chart and watch them cross that's what is driving the signal as I have it configured.

The other factor is the TP. According to my tests the 15TP gives the greatest net profit.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 06-18-2006, 04:12 PM
Junior Member
 
Join Date: May 2006
Posts: 6
cebu is on a distinguished road
EMa crossed

my programming language before is different. Im trying to learn mql4 fast. but i find it a little adjustment.

EMA cross is a good start.

Thanks for the information guys. I ow this new knowledge to you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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 Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling All Masterminds, Programmers, And Coders!!! FX-Hedger Indicators - Metatrader 4 65 01-28-2008 04:58 PM
HMA - Calling All Programmers!! secxces Indicators - Metatrader 4 58 01-26-2008 09:19 PM
Calling All Coders And Specialists jwoger Indicators - Metatrader 4 11 08-01-2006 05:19 AM
Custom Chart Request-calling all programmers Aaragorn Metatrader 4 6 06-16-2006 12:18 AM
Coders Guru Please Help Us sisi Metatrader 4 1 06-08-2006 01:10 PM


All times are GMT. The time now is 05:42 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.