| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Help - multiply lot for each thousand https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=751 |
Page 1 of 1 |
| Author: | Carioca [ Tue Aug 07, 2012 4:33 pm ] |
| Post subject: | Help - multiply lot for each thousand |
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 |
|
| Author: | garyfritz [ Tue Aug 07, 2012 4:51 pm ] |
| Post subject: | 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. |
|
| Author: | Carioca [ Tue Aug 07, 2012 5:18 pm ] |
| Post subject: | Re: Lot code to multiply by a thousand |
garyfritz I'm a lousy coder I found this code in another EA Code: Select all |
|
| Author: | garyfritz [ Tue Aug 07, 2012 5:39 pm ] |
| Post subject: | 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? |
|
| Author: | Carioca [ Tue Aug 07, 2012 5:59 pm ] |
| Post subject: | 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 deleted 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 |
|
| Author: | garyfritz [ Tue Aug 07, 2012 8:08 pm ] |
| Post subject: | 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 |
|
| Author: | Carioca [ Tue Aug 07, 2012 8:40 pm ] |
| Post subject: | Re: Help - multiply lot for each thousand |
The easy for you and very hard for me, the more I understood. 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 |
|
| Author: | garyfritz [ Tue Aug 07, 2012 8:52 pm ] |
| Post subject: | 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. |
|
| Author: | Carioca [ Tue Aug 07, 2012 9:16 pm ] |
| Post subject: | 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 |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|