| New signals service! | |
|
|||||||
| 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 |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Code Block for MM for EA
Ok....like to share code block for MM
Code:
extern string MM_Parameters = " MoneyManagement by L.Williams ";
extern bool MM = true; // ΜΜ Switch
extern double MaxRisk = 0.04; // Risk Factor
extern double LossMax = 0; // Maximum Loss by 1 Lot
<------------------------------------------------------
double MoneyManagement()
{
double lot_min =MarketInfo(Symbol(),MODE_MINLOT);
double lot_max =MarketInfo(Symbol(),MODE_MAXLOT);
double lot_step=MarketInfo(Symbol(),MODE_LOTSTEP);
double contract=MarketInfo(Symbol(),MODE_LOTSIZE);
double vol;
//--- check data
if(lot_min<0 || lot_max<=0.0 || lot_step<=0.0)
{
Print("CalculateVolume: invalid MarketInfo() results [",lot_min,",",lot_max,",",lot_step,"]");
return(0);
}
if(AccountLeverage()<=0)
{
Print("CalculateVolume: invalid AccountLeverage() [",AccountLeverage(),"]");
return(0);
}
//--- basic formula
if ( MM )
{
vol=NormalizeDouble(AccountFreeMargin()*MaxRisk*AccountLeverage()/contract,2);
Print("Margin=",AccountFreeMargin()," r=",MaxRisk," lev=",AccountLeverage()," cont=",contract);
}
else
vol=Lots;
//--- check min, max and step
vol=NormalizeDouble(vol/lot_step,0)*lot_step;
if(vol<lot_min) vol=lot_min;
if(vol>lot_max) vol=lot_max;
//---
return(vol);
}
<------------------------------------------
then use it like example below
OrderSend(Symbol(),OP_SELL,MoneyManagement(),Bid,3,SL,TP,KOMEN,MAGICNO,0,Red);
![]() |
|
|||
|
This is a great little test to see whether the current bar meets or exceeds your buy or sell condition on the current bar right near the close of the current bar.
Without this test the condition may have been met earlier in the current bar and is already reversing in the wrong direction by the close of the current bar. To wait for the next bar may result in a rapid gap up or down in the desired direction leaving you behind in the dust or rapid gapping up or down in the undesired direction! Dave Have a Blessed Day in the Lord! Last edited by Dave137; 02-28-2008 at 04:21 AM. |
|
|||
|
I would have to think about that - Very limited time on my hands, and I am still struggling to find or create a ea system that works reliably. I used the Best ea's recently listed on this forum along with my own creation ea and both got beat up last night in demo trading.
Dave |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Something interesting please post here | newdigital | Indicators - Metatrader 4 | 774 | 12-02-2008 03:06 AM |
| Can someone please post HMA_v2.mq4 please? | increase | General Discussion | 4 | 09-19-2007 08:33 AM |
| hello, I'm new here and this's my first post | StrawberryCheezeCake | General Discussion | 1 | 03-31-2007 01:02 AM |
| Post on a Forum | fulfab | Metatrader 4 | 0 | 11-12-2006 02:06 PM |