limit the volume

Created at 08 Jul 2013, 17:43
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
EL

elodie

Joined 07.06.2013

limit the volume
08 Jul 2013, 17:43


hello
on the robot;alembex

/algos/robots/show/251
I would like a formula to limit the volumes
eg 800k (0.8m) max
thank you very much.

élodie


@elodie
Replies

elodie
23 Jul 2013, 17:00

RE:
elodie said:

hello
on the robot;alembex

/algos/robots/show/251
I would like a formula to limit the volumes
eg 800k (0.8m) max
thank you very much.

élodie


hello
I found a few examples,
but I have not managed to adapt
thank you


@elodie

Nego
24 Jul 2013, 11:22

//+---------------------------------------------------------+
//| Limits the Volume                                       |
//+---------------------------------------------------------+
int VolumeLimit(int lprmnVolume, int lprmcMaxVolume=800000)
{
    int lnVolume = Math.Min(lprmnVolume,lprmcMaxVolume);
    return(lnVolume);
}
//+---------------------------------------------------------+

 

I suspect you simply dont know the Math.Min() function ...


@Nego

gorin
24 Jul 2013, 11:26

Hi,

You can limit by adding a statement like :

if (volume > 800k )
    volume = 800k;

you can put this statement in the code in the "ExecuteTrade" method at the beginning.


@gorin

elodie
24 Jul 2013, 20:28

RE:
gorin said:

Hi,

You can limit by adding a statement like :

if (volume > 800k )
    volume = 800k;

you can put this statement in the code in the "ExecuteTrade" method at the beginning.


thank you very much....

élodie


@elodie