Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Tools and utilities


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
  #141 (permalink)  
Old 08-30-2008, 08:51 AM
Brazenmichael's Avatar
Member
 
Join Date: Jul 2007
Location: Florida
Posts: 75
Brazenmichael is on a distinguished road
Is this possible to code?

Is it possible to code a Money Management advisor that when you manually buy/sell it will open say 4 identical trades? Having read and read many tyopes of money management on forex-tsd...i still find myself on the 5lot mm from ozfx. Is this type of advisor too much to ask for or can someone help me make it a reality?
__________________
Wanna know how to trade? K.I.S.S.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #142 (permalink)  
Old 09-04-2008, 03:20 AM
Brazenmichael's Avatar
Member
 
Join Date: Jul 2007
Location: Florida
Posts: 75
Brazenmichael is on a distinguished road
;et me be more specific.

I need help in coding an ea that after i open a trade for two lots the ea will close the first lot at "x" pips and the second lot at "y" pips.
__________________
Wanna know how to trade? K.I.S.S.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #143 (permalink)  
Old 09-05-2008, 01:55 AM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Spring)
Posts: 3,306
Blog Entries: 46
Linuxser has disabled reputation
Quote:
Originally Posted by Brazenmichael View Post
I need help in coding an ea that after i open a trade for two lots the ea will close the first lot at "x" pips and the second lot at "y" pips.
Take a look at the code of the EA on post 16 of this thread: Swiss Army EA (Automatic order management)
__________________
Elite Manual Trading | Portfolio | Calendar | Suggestions to improve the forum | My Blog

Remember: Signatures must have three lines as maximum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #144 (permalink)  
Old 09-05-2008, 05:11 AM
radatats's Avatar
Senior Member
 
Join Date: Feb 2006
Location: NY
Posts: 183
radatats is on a distinguished road
I find these two scripts to be the best way to manage my risk when trading manually. They allow me to place trades quickly with the exact size necessary for my risk level based on percentage of account equity. You can set it to a flat stop in pips or exact levels. You can place immediate and pending orders. Very simple and very accurate. No more time wasting calculations.

Steve
Attached Files
File Type: mq4 autosell.mq4 (2.3 KB, 79 views)
File Type: mq4 autobuy.mq4 (2.3 KB, 76 views)
__________________
Change everything till it works!!! Test, test, test...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #145 (permalink)  
Old 09-05-2008, 01:24 PM
Brazenmichael's Avatar
Member
 
Join Date: Jul 2007
Location: Florida
Posts: 75
Brazenmichael is on a distinguished road
i think that is what im looking for linux....thanks
__________________
Wanna know how to trade? K.I.S.S.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #146 (permalink)  
Old 09-05-2008, 04:53 PM
Brazenmichael's Avatar
Member
 
Join Date: Jul 2007
Location: Florida
Posts: 75
Brazenmichael is on a distinguished road
radatats...nices eas....working with the code now on them to covert to my original post.
__________________
Wanna know how to trade? K.I.S.S.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #147 (permalink)  
Old 09-27-2008, 04:17 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 358
Beno is on a distinguished road
Quote:
Originally Posted by seawolf View Post
I'm building a Position Sizing calculator as a function based on the "Kelly Formula"

(Win Rate-((1-Win Rate)/(Avg Win/Avg Loss)

I've got the over all code and calculations working with manual inputs (extern) for the required variables and am now trying to get the function working dynamically by calling certain account information (namely I want to calculate the Winning consistency rate (%), the avg # pips per winning trade, and the avg # pips per lossing trade)

I could use any and all help getting the three functions (WinRate AvgWin & AvgLoss) operating. I have been using the manual input variation for months and it works great. Here is the complete code for this (automated) version to this point... in testing I am getting no dynamic output, everything goes back to the default setting (50, 40, 20). I have this set up as it's own EA for testing and easy modularization into any existing EA. once attached to any chart, the output is printed in the log/expert tab. the use of fractals is intentional so that maximum account growth (or minimal loss) is exploited. as a note most Brokers offering the MT trader platform allow fractal trading for either mini or std lots. This will prove use full in the future with money management that can take off partial lot positions (ie: remove 25% of 1 Lot). anyway...

in order to collect the real time account info I need I am trying to...
1. count all trades
2. count trades that are profitable
etc. etc.

I may or may not be going about this the right way.


Thanks in advance for all the help...
SeaWolf







//+------------------------------------------------------------------+
//| KellyFormula.mq4 |
//+------------------------------------------------------------------+
#property copyright "seawolf"
#property link "seawolf"
//+------------------------------------------------------------------+
//| EXTERNAL INFORMATION INPUT |
//+------------------------------------------------------------------+
extern int MyAccount = 1001; //------>>>> Account ID
extern int ExpertID = 500001; //------>>>> Magic Number for this EA

extern double PipValue= 1.00; //------>>>> use for ALL calc's
extern double LotCost= 50.0; //------>>>> use for ALL calc's
extern double PercentMax= 24.0; //------>>>> max % account leveraged @ one time
extern int TradesMax= 3; //------>>>> max simultaniouse trades (example: 24%/3 trades = 8% per trade)

extern bool UseKelly= true; //------>>>> Manual overide toggle
extern double ManualLots= 1.0; //------>>>> # lots if "UseKelly" is false
extern double mWinRate= 50.00; //------>>>> winning consistancy in % (manual overide)
extern int mAvgWin= 40; //------>>>> avg # pips per winning trade (manual overide)
extern int mAvgLoss= 20; //------>>>> avg # pips per lossing trade (manual overide)


//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----

PositionSize();
{
Print("Lots=",PositionSize()," WinRate=",WinRate()," AvgWin=",AvgWin()," AvgLoss=",AvgLoss());
}

Comment("Current Time is ",TimeToStr(TimeCurrent(),TIME_MINUTES)," GMT ",TimeToStr(TimeCurrent(),TIME_DATE)," ... Win Rate= ",WinRate()," Avg Win= ",AvgWin()," Avg Loss= ",AvgLoss());

//----
return(0);
}
//----
//+------------------------------------------------------------------+
//| CALCULATE POSITION SIZE FOR ALL NEW TRADES |
//+------------------------------------------------------------------+
//------------------------>>>>
double PositionSize()
{
//------------------------>>>> DO NOT USE KELLY FORMULA, USE FLAT RATE
if(UseKelly == true)
{
double KelyForm = WinRate()-((1-WinRate())/(AvgWin()/AvgLoss()));
double PerTrade;
double Lots;

if(KelyForm > PercentMax)
{
PerTrade = (PercentMax/10)/TradesMax;
}
else if(KelyForm < PercentMax)
{
PerTrade = (KelyForm/10)/TradesMax;
}
else if(KelyForm == PercentMax)
{
PerTrade = (KelyForm/10)/TradesMax;
}
Lots = (PerTrade * AccountBalance()/LotCost);
return(MathRound(Lots)/10);
}
}

//+------------------------------------------------------------------+
//| COLLECT REAL TIME ACCOUNT INFO |
//+------------------------------------------------------------------+
//------------------------>>>>
double WinRate()
{
double Ticket;
double CountWins = 0;

for(Ticket=0;Ticket<OrdersTotal();Ticket++)
{
OrderSelect(Ticket,SELECT_BY_TICKET,MODE_HISTORY);
if(MyAccount==AccountNumber() && OrderSymbol()==Symbol() && OrderMagicNumber() == ExpertID)
{
//------>>>>
if(OrderType()==OP_BUY)
{
if(OrderClosePrice() >= OrderOpenPrice())
CountWins++;
}
else if(OrderType()==OP_SELL)
{
if(OrderClosePrice() <= OrderOpenPrice())
CountWins++;
}
}
}
if(CountWins > 0)
return(MathRound(CountWins/OrdersHistoryTotal())*10);
else
Print("Real Time WinRate not Available");
return(mWinRate);
}
//------>>>>
//------------------------>>>>
double AvgWin()
{
double Ticket;
double CountTrades = 0;
double CountPips = 0;

for(Ticket=0;Ticket<OrdersTotal();Ticket++)
{
OrderSelect(Ticket,SELECT_BY_TICKET,MODE_HISTORY);
if(MyAccount==AccountNumber() && OrderSymbol()==Symbol() && OrderMagicNumber() == ExpertID)
{
//------>>>>
if(OrderType()==OP_BUY && OrderClosePrice()>=OrderOpenPrice())
CountTrades++;
{
if(OrderProfit() >= 0)
CountPips++;
}
if(OrderType()==OP_SELL && OrderClosePrice()<=OrderOpenPrice())
CountTrades++;
{
if(OrderProfit() >= 0)
CountPips++;
}
}
}
if(CountPips > 0)
return(MathRound(CountPips/CountTrades)*10);
else
Print("Real Time AvgWin not Available");
return(mAvgWin);
}

//------>>>>
//------------------------>>>>
double AvgLoss()
{
double Ticket;
double CountTrades = 0;
double CountPips = 0;

for(Ticket=0;Ticket<OrdersTotal();Ticket++)
{
OrderSelect(Ticket,SELECT_BY_TICKET,MODE_HISTORY);
if(MyAccount==AccountNumber() && OrderSymbol()==Symbol() && OrderMagicNumber() == ExpertID)
{
//------>>>>
if(OrderType()==OP_BUY && OrderClosePrice()<OrderOpenPrice())
CountTrades++;
{
if(OrderProfit() < 0)
CountPips++;
}
if(OrderType()==OP_SELL && OrderClosePrice()>OrderOpenPrice())
CountTrades++;
{
if(OrderProfit() < 0)
CountPips++;
}
}
}
if(CountPips > 0)
return(MathRound(CountPips/CountTrades)*10);
else
Print("Real Time AvgLoss not Available");
return(mAvgLoss);
}

//---------------------------------------------------------------------+
Has any one managed to automate the kelly formular or intergrate it into their EA trading system
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #148 (permalink)  
Old 10-23-2008, 09:01 AM
Member
 
Join Date: Aug 2006
Posts: 35
f4mnect is on a distinguished road
Money management script

Would anybody have a script I could use for scalping that I can set a stop lose in and have both a buy and sell script that would automatically adjust the lot size when placing a order with the stop lose also set when it opens a trade.
__________________
The quickest way to double your money is to fold it in half and put it
back in your pocket.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #149 (permalink)  
Old 11-14-2008, 05:45 AM
jeffkerwin's Avatar
Junior Member
 
Join Date: Nov 2006
Location: New Zealand
Posts: 7
jeffkerwin is on a distinguished road
Quote:
Originally Posted by darkkiller View Post
who have MQ4 version for this LotCalculator?thanks
I applied this indicator but it gives a totally inaccurate figure. It may have something to do with my broker having an extra decimal place in their price.

For example normal brokers may display a price like: 1.1234
My broker displays: 1.12345

Would this have something to do with the wrong lot calculation?

I really want this tool to work as it will save lots of paper calculations, and save trees lol.

I realise it is only .ex4, but maybe the source code is out there somewhere. Or someone could knock a similar one up quickly as it is pretty simple I imagine.

Thx
Attached Files
File Type: ex4 LotCalculator v1.ex4 (4.4 KB, 11 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #150 (permalink)  
Old 11-14-2008, 07:36 AM
Senior Member
 
Join Date: Jun 2006
Posts: 314
chrisstoff is on a distinguished road
Quote:
Originally Posted by jeffkerwin View Post
I applied this indicator but it gives a totally inaccurate figure. It may have something to do with my broker having an extra decimal place in their price.

For example normal brokers may display a price like: 1.1234
My broker displays: 1.12345

Would this have something to do with the wrong lot calculation?

I really want this tool to work as it will save lots of paper calculations, and save trees lol.

I realise it is only .ex4, but maybe the source code is out there somewhere. Or someone could knock a similar one up quickly as it is pretty simple I imagine.

Thx
Hi Jeff,

I think this tool works well. You should put in the stop loss figure in pips and the pips are ten times larger if you use five decimals brokers. So, you should put in StopLoss = 200 instead of 20 in case of five decimals brokers.
Regards,

Chrisstoff
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
money management, money management code, moneymanagement

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
Help Needed Making Perfect Trailing Stop EA sbwent Expert Advisors - Metatrader 4 27 03-13-2008 05:30 AM
The perfect trader black ice General Discussion 9 11-14-2006 06:51 AM
10k lot size brokers kevmcfoster Suggestions for Trading Systems 12 10-07-2006 12:25 AM
Must have utility for MT coders who are not 100% perfect ycomp Tools and utilities 2 02-23-2006 11:45 PM


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



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