dynamic lotsize not working. help! - page 6

 
Michael Charles Schefe #:

updated ea is attached. i readded the class and all is still working with the dual lotsizes, just the 3rd, biggest lot to prove now. 

removed some lines from loops that were not needed or variables not being used anymore that were from code snippets i borrowed from previous iterations of my eas.

down to 999 lines of code now! This is 100% due to everyone in this thread. I was "pulling my hair out" for 3, maybe up to 6 weeks! trying to fix this. THANKS.

EDIT: found another bug, but is fixed in 0431. deleted 0430 and replaced with 0431.
Thank you for posting your finished product. That is the epitome of participation in the Forum─a 2-way street, if you will.👍
 
Ryan L Johnson #:
Thank you for posting your finished product. That is the epitome of participation in the Forum─a 2-way street, if you will.👍

the file includes changes, i think, and i hope -- that are detailed in all the above thread, but it is far from the "finished product" albeit my demo shows it working well on 20 something pairs, without the dynamic lotsize as long as you have the single lot small -- and that you modify the code to only run the trade management on a single ea/chart.

feel free to use it for personal use only.

 
Michael Charles Schefe #updated ea is attached. i readded the class and all is still working with the dual lotsizes, just the 3rd, biggest lot to prove now.

You forgot to implement the 4th change proposed earlier:

Forum on trading, automated trading systems and testing trading strategies

dynamic lotsize not working. help!

Vinicius Pereira De Oliveira, 2026.04.29 00:33

4) The variables "buyMxg" and "buyMng" are being initialized incorrectly (lines 288-289):
selMxg = buyMng = 0;
buyMxg = selMng = DBL_MAX;

This way, the comparisons "position.PriceOpen() > buyMxg" and "position.PriceOpen() < buyMng" are never true - so "buyMxg" and "buyMng" are never updated. I think you should correct it to:

selMxg = buyMxg = 0;
buyMng = selMng = DBL_MAX;

In the attached version of the EA, the above change was made, as well as the lot size logic (in openNewTrade) to work according to what you described in comment #14. Now, at least in the Tester, the third lot is being triggered. Please test it! 👍

Files:
 
Vinicius Pereira De Oliveira #:

You forgot to implement the 4th change proposed earlier:

In the attached version of the EA, the above change was made, as well as the lot size logic (in openNewTrade) to work according to what you described in comment #14. Now, at least in the Tester, the third lot is being triggered. Please test it! 👍

wow. thanks again. i did make the change but few updates of windows, closing editor and such seems to have cause the change to be reverted in the file that i uploaded.

i will definitely! absolutely test out the new lotsize! And give report.

 
another potential bug. in ontick i have 2 variables in the loop; b4 and s4, but then i pass toalbuy and totalsel to opentrade function with same names b4 and s4. will fix these later and hope that the demo dont crash before then!
 

i made the change i described. I also altered the lotsizing so that there is allowed 2 trades with the first lotsize.

before somone says something... YES i know that there is no such date as 26.04.33 **tongue poke**.

I also fixed my "2ndary ea" which i have on all other trading charts.

 ie the ea we have detailed above (EA***_1) i only have on a single chart. This single chart ea manages all trades with what i have called a "group trail stop". the trail stop does not have inputs, you can add these yourself, shouldnt be hard to find the variables you will need to create external inputs.

Different trail stop could be used for different magics or symbols by modifiying this first ea; but the files detailed in this thread only use single magic, and trade management does manage all open trades, and all magics; ie including manual trades and trades opened by other eas+signals.

attached. EA*_1.mq5 is the ea we have detailed above and has the trade management for all charts. I usually put this on EURUSD but could be put on any.

EA*_2 is the ea that i attach to all other charts.

You will find that the files below will NOT COMPILE. they require other files to do that! find those in a zip file that can be found in a previous comment by me.

Note that this has only been tested for X hours, and the 3rd lotsize has not been seen. maybe it does not work? will post below if proven either way.

FURTHER Note: NO STOPLOSS OR TAKEPROFIT is added to any trade. i have ideas to add these, but i have had some success using ronz and other free eas to close single trades, working 100% with these eas. the first ea notices when trades have closed and makes changes to trail stops "on the fly"; no problems.

I am posting these files due to all the help I have got, all freely given by all posters in this thread; 

kudos to the authors of 2 original files i modded to suite these eas and included as resouce file (in zip file): fxsaber && mahmud

I have no issue with giving my stuff for free if the user uses them for personal use, but please only use them for personal use -- if being used otherwise -- contact me.

 
Michael Charles Schefe #:
[F]eel free to use it for personal use only
TBH, I"m not going to use it. I have plenty of my own EA's. Even so, I still commend you for sharing with all Forum users. In contrast, there are some users that get help, keep the code secret, and then even sell the compiled file.🤮
 
big kudos to @Mladen Rakic also. i got the rsi-oma indicator from codebase and modified it for the ea.
 
dam it. the files i posted are broken. they opened a couple trades on demo account so i thought they were good. on strategy tester they are giving many ordersend #0 errors.
 

both working in both backtester and demo, live charts. the 3rd lotsize has opened a demo trade on nzdjpy just few mins ago. the trades are buys, previous trade is 683, and the bigest lot trade is 211, therefore more than 160 points difference, and clearly meets that condition to be made the biggest lotsize.

I think i will add a limit to the number these biggest trades. And then if all works fine thru next week, no problems, then following week i will try a hard sl since i have noticed the balance rising very fast, so this could mean that i can add a much tighter sl than i had assumed without "breaking the bank". But i am planning on this being my last post unless there is any further major errors to fix.

Good trading to you.