MathSrand problem
-
@roar MathSrand(GetTickCount());
Hi
If someone could give me a hand please... I started a new thread because the other one was old and the old topic does not really address the problem I have.Is there any other code except MathSrand(GetTickCount()); I can use to rectify the expert because every first order it takes is not part of count of the total lots. Or maybe setup of expert blocks is wrong?
This is my goal
If the conditions is met but price action still moves further away from 1st trade(parent) in a negative direction: another order must be taken -30 pips(first child trade) away from original entry and then -30pips away from 1st child trade, etc..... and the lot sizes must be exponentially added on an averaging basis of a +/-150% of previous negative lot size, on every new child order. For example: 0.01(parent), 0.02(1st child), 0.03(2nd child) etc, and the take profit must modify 25% above the average of all tradesMy effort:
https://fxdreema.com/shared/x5dk8lW9bRoar original code:
https://fxdreema.com/shared/ucZlZvYccThank you in advance
-
@alphaomega this comparison gives trouble:

Just set it to "equal to 0" (or just use "no trade" block), then I think your grid will work.
Also, you dont need MathSrand(GetTickCount()) code, that was just setting some random lot sizes in my test. You dont have random lot sizes here.
-
@roar As always .. you are the best!!!! Thank you.
-
@roar Sorry to bother again ... I have changed the parameters as you said ... I still do not know how to get the first order to take a TP or SL? The TP and SL only kicks in if the 2nd order is taken. Thanks in advance.
https://fxdreema.com/shared/SScWMSFud

-
@alphaomega the "position created" may still have some problems.. You dont have to use that block or "On Trade" tab at all. Just modify the stops after doing the orders:

-
@roar Thanks for the reply..... Ok ... let me fight a bit with this and then will come back to you
-
@roar .. Hi Mr Roar I need your input again please. The expert does it,s averaging job very well but I do not understand where the TP comes from and where to set it? I have tried to control the TP with the adjustment add-on but it does not work correctly. Thank you in advance.
-
@alphaomega in your project, take profit is the average line.
Graphical objects are sometimes buggy, though, its better to simply insert the average variable directly into the TP field.
-
@roar Thanks so much for your speedy reply... let me do that .. I will come back with results... Thank you!!
-
@roar .. Hi Roar.. Sorry to bother you again... I have changed the settings as I understand you said and it is working but the TP is very small, like in cents..lol.. I must be doing something wrong again. Also, if I try change the settings there is no TP for the first order and the TP does not modify to the average if the 2nd order is placed, it just stays at the first order"s average. I have attached some pictures for you. Please advice me again. Thank you in advance




-
Hi @AlphaOmega , how are you?
You can check your mt4 connected to cent acc or std acc. I've experience this before.
If cent acc, try login to any std acc. Then do your backtesting. -
@biztet I am good! How are you my friend?... No I am running this on MT5 std account. The problem is definitely with the coding or the way I connected the blocks.. I am just to dumb to understand how to fix it. I do not think its a big problem. .. Mr Roar will sort it out I am dead sure!
-
@alphaomega where do you want the TP?
If TP is average open price of trades, it surely will be very small in pip terms. -
@roar Hallo Roar... thanks for replying... I want at least 15% in profit from average of all open price of trades .. How do I control it? Thank you in advance for your reply
-
@roar I have also tried this formula... but it also gives some error.. so I do not understand how to do it..

-
@roar This formula seems to work but it would not give me the TP

-
@roar Hallo Roar... when you have time please sort me out here... I am stuck. I want at least 15% in profit from average of all open price of trades .. How do I control it?
Attached is my last effort. Thank you in advance for your reply
https://fxdreema.com/shared/W3TcZf7he -
@alphaomega what do you mean by 15%? It takes many years for a forex symbol to move 15%
Or just equity > balance * 1.15 ? You dont need average for that.
-
@roar I will put it in a picture for better clarity because maybe I am expressing myself incorrectly. Please check the attached... Thanks in advance

-
@alphaomega I understand that you want to move the line, but where does that value come from? What calculation gives 15% as result? Perhaps 15% of the distance between highest and lowest trade?`
If you mean 15% more profit in pips, that makes no sense: profit at the average line is 0, 0 times 15% is still 0. It doesnt move anywhere by a percentage multiplication.