how to set the lot size as a formula

[Deleted]  

I have an EA that I am working on and it uses simple inputs:

extern double Lots = 0.1;

extern double StopLoss = 20;

extern double TakeProfit = 15;

extern int Slippage = 3;

What I wish to do is set the lot size to be a formula including the current value of an indicator - ADX for example. ADX has +DI and -DI. What I am trying to do is set this to work like this:

- if the EA is going to go long the lot size will be calculated 2* +DI value of ADX

-if the EA is going to go short the lot will be 2* -DI value of ADX

Can anyone let me know how this can be done?

Much appreciated!

Roman Sokolowski
651
Roman Sokolowski  
blank_jack:

I have an EA that I am working on and it uses simple inputs:

extern double Lots = 0.1;

extern double StopLoss = 20;

extern double TakeProfit = 15;

extern int Slippage = 3;

What I wish to do is set the lot size to be a formula including the current value of an indicator - ADX for example. ADX has +DI and -DI. What I am trying to do is set this to work like this:

- if the EA is going to go long the lot size will be calculated 2* +DI value of ADX

-if the EA is going to go short the lot will be 2* -DI value of ADX

Can anyone let me know how this can be done?

Much appreciated!

hey


i'm not sure what are you asking about, because you wrote algorithm for calculating lot size (and the rest should be easy). You can do this like that:

if (conditions for buy)

{

     Lots=NormalizeDouble(2*DI,2);

     OrderSend(Symbol(), OP_BUY, Lots, Ask, slippage, stoploss, takeprofit, TradeComment, MagicNumber, 0, Green);

}

Digits number in NormalizeDouble function depends on what kind of lot sizing is allowed with your broker - mini lots or micro lots.

i think you should write with which part of coding this you have a problem, maybe then i will be able to help you better.

regards