Heeeelp! heeeelp! - page 4

 
RaptorUK:
To do what . . . . you haven't actually explained what you want to do . . despite being asked specific questions . . . if you ignore questions that are asked so you can be helped then you will be ignore very quickly.

to turbo or not to turbo
 
jameslarry:

to turbo or not to turbo
OK, enjoy yourself . . you don't want help.
 
I got a system that does it like i wanted ill post it to you guys soon
 

Well since you seem like you want it the simplest possible as you are a novice i looked for the easiest to understand.

extern double LotPerThousand=0.1;  // If you had 1000 balance what lot size would you use

int start()
{

double lots;

lots=NormalizeDouble((LotPerThousand/1000)*AccountBalance(),2);
if(lots<MarketInfo(Symbol(),MODE_MINLOT)){ lots=MarketInfo(Symbol(),MODE_MINLOT); }
if(lots>MarketInfo(Symbol(),MODE_MAXLOT)){ lots=MarketInfo(Symbol(),MODE_MAXLOT); }

...
OrderSend(Symbol(),OP_BUY,lots,...)
...

return 0;
}
 
tonny:
Well since you seem like you want it the simplest possible as you are a novice i looked for the easiest to understand.
Sorry tonny lot size must be between minlot and maxlot AND a multiple of lotStep.
double NormalizeLots(double lots, string pair=""){
    if (pair == "") pair = Symbol();
    double  lotStep     = MarketInfo(pair, MODE_LOTSTEP),
            minLot      = MarketInfo(pair, MODE_MINLOT);
    lots            = MathRound(lots/ls) * ls;
    if (lots < minLot) lots = 0;    // or minLot
    return(lots);
}
 
tonny:

Well since you seem like you want it the simplest possible as you are a novice i looked for the easiest to understand.


Bingo! Tonny this is exactly what i wanted it works on strategy tester and auto increments the lot size maintaining the percentage. Its better than my previous one with countless if statements thanks alot all! :-)
 
Well i just remember the math where if a is to b then c is to? the formula would be (b/a)*c in this case c is your account balance. And the result respects the ratio of a:d i.e. lets say the result is d then a:b is same as c:d and b:a is same ratio as d:a . Then just put the formula in normalize double to get a two decimal place rounded off lot value in case the calculations return more decimal places than two of which ordersend would reject as an invalid lot size. From there check if this value is less than minimum required lot if so use the minimum required and if higher than maximum required lot then use the maximum as lot value.
/* new value of lot would be (old lot/old balance)*new balance in this case we fix old balance at 1000 and new balance is the current balance i.e. (LotPerThousand/1000)*AccountBalance() */

lots=NormalizeDouble((LotPerThousand/1000)*AccountBalance(),2);                            // round two 2 decimal places incase more than 2 decimal places is returned
if(lots<MarketInfo(Symbol(),MODE_MINLOT)){ lots=MarketInfo(Symbol(),MODE_MINLOT); }        // if lower than minimum required use the minimum
if(lots>MarketInfo(Symbol(),MODE_MAXLOT)){ lots=MarketInfo(Symbol(),MODE_MAXLOT); }        // if higher than maximum required use the maximum
 
Thank you very much!
 
WHRoeder:
Sorry tonny lot size must be between minlot and maxlot AND a multiple of lotStep.

dear WHRoeder, please do not misguide people by giving codes which just have lots of errors in it, you have not defined ls object in the code and you are giving it to someone to use it, please stop your mischievous behavior

 
tonny:

Well since you seem like you want it the simplest possible as you are a novice i looked for the easiest to understand.


tonny thanks a lot by the code you gave, it really worked very well



i was finding it from 2 days and even quarelled with my wife on it!


thanks

Reason: