How to code? - page 158

 
PEDCORD:
Hi,

who can help me put sound in AFStar Indicator wen the arrows apears, I have very good results in time frame 15 and 30. For me this indicator is very, very good.

Here is an MTF version I did for you with alert

Files:
 

Programing Help?

Hi All,

Been ages since I have been on the board or done any trading but am currently working on a new EA and need some help.

Right now I am setting the LotsValue in the EA as follows:

extern double LotsValue = 1;

and the order is sent as follows:

int Ticket = OrderSend(Symbol(), Type, LotsValue, Price, Spread, 0, 0, Currency, Magic, 0, ArrowColor);

What I would like to do is set the number of lots based on a percentage of equity ~vs~ balance as the EA trades multiple pairs simultaneously.

Any help or suggestions would be greatly appreciated.

Also, if anyone can recommend a professional programer (MQL4) please let me know as I have lost contact with the one I was working with in China (I am in the USA).

Regards to all,

CajunFX

 

CajunFx,

Here's a simple Lot Size calculator from one of my EA's.

double GetLotSize()

{

double LotSize = ManualLots;

double MaxLots = MarketInfo( Symbol(), MODE_MAXLOT );

double MinLots = MarketInfo( Symbol(), MODE_MINLOT );

double LotStep = MarketInfo( Symbol(), MODE_LOTSTEP );

int LotDigits = 1;

if (LotStep == 0.01) LotDigits = 2;

bool MicroLotsAllowed = False;

bool MicroLotStepsAllowed = False;

if( MinLots == 0.01 ) MicroLotsAllowed = true;

if( LotStep == 0.01 ) MicroLotStepsAllowed = true;

if( UseMoneyManagement )

LotSize = MMPercent * AccountBalance() / ( MarketInfo( Symbol(), MODE_TICKVALUE ) / Point * PipPoint ) / 10000;

if( MicroLotsAllowed )

LotSize = NormalizeDouble( LotSize, 2 );

else if( MicroLotStepsAllowed && LotSize > 0.1 )

LotSize = NormalizeDouble( LotSize, 2 );

else if( MinLots < 0.5 )

LotSize = NormalizeDouble( LotSize, 1 );

else

LotSize = NormalizeDouble( LotSize, 0 );

LotSize = MathMin(LotSize,MaxLots);

LotSize = MathMax(LotSize,MinLots);

return( LotSize );

}

Note:

UseMoneyManagement is an setting built into the options section of the EA.

I generally set these three options to work in conjuction with the LotSizing Function.

extern string MM = "===== MONEY MANAGEMENT =====";

extern double ManualLots = 0.1;

extern bool UseMoneyManagement = False;

extern double MMPercent = 3;

If you want to use Equity instead of balance, then simply change the reference in the code from AccountBalance() to AccountEquity().

Hope this helps.

Cheers,

Hiachiever

 

Gents,

Thanks for the help. Not being a programmer I am lost on the first code snipet (sorry hiachiever, no offense).

I tried the second snipet and it worked after I removed the /STOPLOSS (EA uses a dynamic SL) and added a few more zeros but now getting an OrderSend error 4051 invalid lots amount. Believe this is because previously I was using a whole value for LotsValue and now it is wanting to send fractional LotsValue... eg; 1 ~vs 1.3.

Looks like I am on the right track though so will keep plugging away at it.

BTW... signed up for the Build An Expert Advisor course... maybe this will help me to get a handle on things.

Thanks,

CajunFX

 

Here's a simple way to do it...

// money management

if(LOTS == 0)LOTS = (AccountFreeMargin()*RISK/100.0)/STOPLOSS;

Hope that helps.

Lux

 

Rectangle tool which counts number of candles contained within

Hello chaps,

I'm wondering if any of you fine fellows knows how to re=program the rectangle tool so that it counts how many candles periods are contained within it. Reasoning behind this is that during a range, the longer it continues, the greater and stronger the breakout.

Anyone have this or can let me know how to program this?

Thanks all!

~J

 

MTF_AFStar

Hi increase,

Thank you very much. I have very good results in 15 and 30 time frame USDJPY.

Thank you.

 

MTF_AFStar

Hi increase,

Thank you very much for your work in my favorit indicator. Now I will be able to take more and more pips much easy.

In my opinion this indicator is very, very good, with stop loss 15pips in time frame 15.

Try it too.

Thank you very much.

 

How to select the biggest lost?

is there a way to select the biggest losing trade?

i need it to modify my MM strategy thanks!!!

Andrea

 

sorry i was meaning the biggest lost in history

Reason: