I wanted the code to multiply the lot, every 1.000
EX:
1000 - 0.10
1100 - 0.11
1500 - 0.15
1000 - 0.10
2000 - 0.20
1500 - 0.15
I wanted to add this feature in EA Simple Spider and already ancient if anyone much good will add this feature in the EA, I appreciate it.
More leaving the code I at least try.
Sorry for the english
Help - multiply lot for each thousand
- Carioca
- Trader
- Posts: 49
- Joined: Sat Jun 09, 2012 12:12 am
Help - multiply lot for each thousand
You do not have the required permissions to view the files attached to this post.
Last edited by Carioca on Tue Aug 07, 2012 6:50 pm, edited 3 times in total.
-
garyfritz
Re: Lot code to multiply by a thousand
I think you just want to divide by 10,000 -- so 1500 / 10000 = 0.15.
But I'm guessing you want it to step by 0.01? So e.g. 1567 => 0.15 ?
If so, then use 100*MathFloor(X/100)/10000 which is equal to MathFloor(X/100)/100.
NormalizeDouble(X/10000,2) is close, but that would round 1567 up to 0.16 instead of 0.15.
But I'm guessing you want it to step by 0.01? So e.g. 1567 => 0.15 ?
If so, then use 100*MathFloor(X/100)/10000 which is equal to MathFloor(X/100)/100.
NormalizeDouble(X/10000,2) is close, but that would round 1567 up to 0.16 instead of 0.15.
- Carioca
- Trader
- Posts: 49
- Joined: Sat Jun 09, 2012 12:12 am
Re: Lot code to multiply by a thousand
garyfritz I'm a lousy codergaryfritz wrote:I think you just want to divide by 10,000 -- so 1500 / 10000 = 0.15.
But I'm guessing you want it to step by 0.01? So e.g. 1567 => 0.15 ?
If so, then use 100*MathFloor(X/100)/10000 which is equal to MathFloor(X/100)/100.
NormalizeDouble(X/10000,2) is close, but that would round 1567 up to 0.16 instead of 0.15.
I found this code in another EA
Code: Select all
//Auto lot size, calculated as LotsPerThousandOfBalance per $1000
SendLot = Lot;
if (LotsPerThousandOfBalance > 0)
{
//Code for rounding down the account balance to bare thousands profided by Garyfritz. Many thanks Gary.
double BaseMag = MathPow(10, MathFloor(MathLog(AccountBalance()) / MathLog(10))); // 4376.59 -> 1000
double RoundDown = MathFloor(AccountBalance() / BaseMag) * BaseMag;
SendLot = (RoundDown * 0.1) / 1000;
}//if (LotsPerThousandOfBalance > 0)-
garyfritz
Re: Help - multiply lot per thousand
I don't think you need to credit me for that, I don't recognize my formula in there anywhere!! 
So for a balance of 4376.59, BaseMag = 1000. RoundDown = 4000. SendLot = 0.40. Is that what you wanted? Didn't you want LotsPerThousandOfBalance in there somewhere?
So for a balance of 4376.59, BaseMag = 1000. RoundDown = 4000. SendLot = 0.40. Is that what you wanted? Didn't you want LotsPerThousandOfBalance in there somewhere?
- Carioca
- Trader
- Posts: 49
- Joined: Sat Jun 09, 2012 12:12 am
Re: Help - multiply lot per thousand
you got it wrong, what 's written in the code came along it was not me who wrote it. descupe was supposed to have deletedgaryfritz wrote:I don't think you need to credit me for that, I don't recognize my formula in there anywhere!!
So for a balance of 4376.59, BaseMag = 1000. RoundDown = 4000. SendLot = 0.40. Is that what you wanted? Didn't you want LotsPerThousandOfBalance in there somewhere?
Sorry my english now and terrible, and I understand very little mq4.
I wanted the lot, it increases and diminishes as the account balance.
If I had $ 1000 $ 1099 it will be a lot 0.10, $ 1100 $ 1199 would be a lot 0.11
successively
I hope you understand me
thanks
-
garyfritz
Re: Help - multiply lot for each thousand
Your BaseMag calculation gets the "magnitude" of a number: 1234 -> 1000, 9876 -> 1000, 12345 -> 10000, 98765 -> 10000.
RoundDown rounds a number down to its most significant digit: 1234 -> 1000, 9876 -> 9000, 12345 -> 10000, 98765 -> 90000.
SendLot just divides RoundDown by 10000: 1234 -> 0.10, 9876 -> 0.90, 12345 -> 1.00, 98765 -> 9.0.
So that does not do the 1050 -> 0.10, 1150 -> 0.11 that you want.
It sounds like you want 0.01 lot per $100 in the account, and that's easy. That's what I did above:
SendLots = 100 * MathFloor(AccountBalance()/100) / 10000 = MathFloor(AccountBalance()/100)/100.
That returns 0.10 for 1000-1099, 0.11 for 1100-1199, 1.11 for 11100-11199, etc.
More generally, if you want 0.01 lot per $X in the account, use
SendLots = MathFloor(AccountBalance()/X) / 100
RoundDown rounds a number down to its most significant digit: 1234 -> 1000, 9876 -> 9000, 12345 -> 10000, 98765 -> 90000.
SendLot just divides RoundDown by 10000: 1234 -> 0.10, 9876 -> 0.90, 12345 -> 1.00, 98765 -> 9.0.
So that does not do the 1050 -> 0.10, 1150 -> 0.11 that you want.
It sounds like you want 0.01 lot per $100 in the account, and that's easy. That's what I did above:
SendLots = 100 * MathFloor(AccountBalance()/100) / 10000 = MathFloor(AccountBalance()/100)/100.
That returns 0.10 for 1000-1099, 0.11 for 1100-1199, 1.11 for 11100-11199, etc.
More generally, if you want 0.01 lot per $X in the account, use
SendLots = MathFloor(AccountBalance()/X) / 100
- Carioca
- Trader
- Posts: 49
- Joined: Sat Jun 09, 2012 12:12 am
Re: Help - multiply lot for each thousand
The easy for you and very hard for me, the more I understood.garyfritz wrote:Your BaseMag calculation gets the "magnitude" of a number: 1234 -> 1000, 9876 -> 1000, 12345 -> 10000, 98765 -> 10000.
RoundDown rounds a number down to its most significant digit: 1234 -> 1000, 9876 -> 9000, 12345 -> 10000, 98765 -> 90000.
SendLot just divides RoundDown by 10000: 1234 -> 0.10, 9876 -> 0.90, 12345 -> 1.00, 98765 -> 9.0.
So that does not do the 1050 -> 0.10, 1150 -> 0.11 that you want.
It sounds like you want 0.01 lot per $100 in the account, and that's easy. That's what I did above:
SendLots = 100 * MathFloor(AccountBalance()/100) / 10000 = MathFloor(AccountBalance()/100)/100.
That returns 0.10 for 1000-1099, 0.11 for 1100-1199, 1.11 for 11100-11199, etc.
More generally, if you want 0.01 lot per $X in the account, use
SendLots = MathFloor(AccountBalance()/X) / 100
If you or someone might add this function in EA I would appreciate it, because surely I will stay a few days trying to make it work, of course if you're not busy.
Thank garyfritz
-
garyfritz
Re: Help - multiply lot for each thousand
I know nothing about this EA.
Looking at the CalculateLotSize() function, I see a line (#1059) that says
SendLots = NormalizeDouble(OrderLots() * MartingaleLotMultiplier, digit);
digit is 1 if your crim accepts lot sizes in steps of 0.1, and 2 if the crim accepts lot sizes in steps of 0.01.
On line 1082 it calculates SendLots = CalculateLotSize().
You could just replace line 1082 with SendLots = MathFloor(AccountBalance()/X) / 100;
HOWEVER I have no idea how well that would work. This EA uses a Martingale, which means it uses increasing lot sizes when you have losses. Without digging into it and understanding its logit a lot better -- which I don't plan to do -- I don't know what will happen to the EA performance if we start changing the lotsize.
The EA was designed as a Martingale, probably for a good reason. I suggest you should not try to redesign its behavior without understanding very well what it does.
Looking at the CalculateLotSize() function, I see a line (#1059) that says
SendLots = NormalizeDouble(OrderLots() * MartingaleLotMultiplier, digit);
digit is 1 if your crim accepts lot sizes in steps of 0.1, and 2 if the crim accepts lot sizes in steps of 0.01.
On line 1082 it calculates SendLots = CalculateLotSize().
You could just replace line 1082 with SendLots = MathFloor(AccountBalance()/X) / 100;
HOWEVER I have no idea how well that would work. This EA uses a Martingale, which means it uses increasing lot sizes when you have losses. Without digging into it and understanding its logit a lot better -- which I don't plan to do -- I don't know what will happen to the EA performance if we start changing the lotsize.
The EA was designed as a Martingale, probably for a good reason. I suggest you should not try to redesign its behavior without understanding very well what it does.
- Carioca
- Trader
- Posts: 49
- Joined: Sat Jun 09, 2012 12:12 am
Re: Help - multiply lot for each thousand
I'm testing it on more than two months in 2007-2011 for backtesting, optimization and demo.
This was my last post I talk about vq http://www.stevehopwoodforex.com/phpBB3 ... 317#p17317
And he really had good results and profitable.
And add this feature in EA would be more profit.
The code I posted was that EA I'm not mistaken it uses Martingale and has the function of esa.
http://www.stevehopwoodforex.com/phpBB3 ... ?f=5&t=485
From what you said seems to add that function without touching the martingale would be complicated, alas.
Even so thanks garyfritz
This was my last post I talk about vq http://www.stevehopwoodforex.com/phpBB3 ... 317#p17317
And he really had good results and profitable.
And add this feature in EA would be more profit.
The code I posted was that EA I'm not mistaken it uses Martingale and has the function of esa.
http://www.stevehopwoodforex.com/phpBB3 ... ?f=5&t=485
From what you said seems to add that function without touching the martingale would be complicated, alas.
Even so thanks garyfritz