You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
My pleasure! And thanks for letting me know it's working for you, I appreciate the feedback. Not sure what went awry with the earlier code. May well have been a bug of some sort that I unwittingly corrected between revisions.
I'll probably have an updated version within a week or two that will have some fallback features for use with backtesting in MT4 on cross-currency pairs. Right now if you try and backtest a cross-pair while using my lot-size code your backtest will bomb because the backtester can't access the market prices for the requisite counter and base pairs. (this isn't an issue in live or forward testing, purely a backtester limitation of MT4)
I'll post up the code when I cross that bridge perchance you or others find it helpful.
Have a good weekend,
- Phil
Hello 1005phillip:
I have been reading this thread. I am interested in testing / using your code, if it is still available.
Are the most current files on page 1, or do you offer them privately?
Regards,
spgandau
... and the crowd was loudly hoarding: (LOL string) "Phillip, Phillip, Phillip!" (LOL string END)
Jussst to sssay a BIG THANK YOU, Phillip (, Phillip, Phillip!).
Can't ssssay the code works for me, I got same "Error occurred while identifying SymbolType(), calculated SymbolType() = 6" error as folks before me, when backtesting. Guess I will have to forward test.
Have already sent Santa Clause a big letter for Christmas gift 2013:
"Dear Santa Clause!
I have washed behind my ears 4 times this year. So, since I have been extremely good boy, I wish I had a brain like Phillip, the most generous mql4 coder on this planet. Please, dear Santa, include his mql4 coding capabilities!
Thank you, Phillip, sorry, Santa."
Best regards,
Have fun,
Simon
Glad to hear it Shawn!
I am continuously tinkering with the codes, if you'd like a more recent version (there are no bugs in the ones you have) I'd be more than happy to share it.
The changes mostly center around making the include file easier to integrate and use with your existing EA. Since you've already managed to get the other one implemented it might not make any difference to you now.
good day
i need help with coding an ea. or at least getting the mq for this particular indicator
good day
i need help with coding an ea. or at least getting the mq for this particular indicator
Hi All, back again to nag you. :-) Would anyone have a handy-dandy little MQL4 function that automatically calculates lot size (for any symbol) based on how much % risk of my available equity, and my desired stoploss size in pips?
Thanks!
Shawn
//+------------------------------------------------------------------+
//| Market Info analyse |
//+------------------------------------------------------------------+
bool GetMarketInfo()
{
minSLTPdstnc = MarketInfo(Symbol(), MODE_STOPLEVEL);
if (Risk_Percentage>100 || Risk_Percentage<0 ) Risk_Percentage=10;
Margin_Required=MarketInfo(Symbol(), MODE_MARGINREQUIRED);
lotmin=MarketInfo(Symbol(), MODE_MINLOT);
lotmax=MarketInfo(Symbol(), MODE_MAXLOT);
Lot_Step=MarketInfo(Symbol(), MODE_LOTSTEP);
Lot_Size=MarketInfo(Symbol(), MODE_LOTSIZE);
Tick_Value=MarketInfo(Symbol(), MODE_TICKVALUE);
Spread=MarketInfo(Symbol(), MODE_SPREAD);
return(true);
}
//+------------------------------------------------------------------+
//| Measure Orders Lot |
//+------------------------------------------------------------------+
double CheckLots (int risk_percent,double sl_size, double Static_Lot) {
if (risk_percent<=0) return (Static_Lot);
double lots=0;
lots=NormalizeDouble( (AccountBalance()*Risk_Percentage/100) / (Tick_Value*sl_size), 2 );
if (lots*Margin_Required>AccountFreeMargin()) {
error("Not enough money to take " + DoubleToStr(lots,2) +" lots.");
lots=AccountFreeMargin()/Margin_Required;
}
lots=MathFloor(lots/Lot_Step + 0.5)* Lot_Step;
if ( lots < lotmin ) lots=lotmin;
if ( lots > lotmax ) lots=lotmax;
if ( lots > MaxLot) lots = MaxLot;
return(lots);
}
Forum on trading, automated trading systems and testing trading strategies
General rules and best practices of the Forum.
When you post code please use the SRC button !
Hello,
Please EDIT your post and use the CODE button when you post code.
Thank you.Hi, it is posibble to count the lotsize based from last losses in money to cover the uncounted loss cause of slipage or gap price