Gradual decrease in lot size, and timing
-
Greetings,
I want to create an EA where when conditions are met, a trade will open. However, only one trade must be opened when conditions are met. The take profit is simply one pip. There is always a possibility that a position will not take profit, therefore I would like any opened positions to be closed on new candle opening price.
This is where things get a bit complicated:
When conditions are met, the first 10 trades opened will start with lot sizes of 1.0 then 0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1, then when the last trade with lot size of 0.1 is closed, then all the other next positions that ought to be opened when conditions are met, will be opened at lot size of 0.01.
Shared Project:
https://fxdreema.com/shared/Qh9BQxlje
Notes to simplify things:
-
When conditions are met, open a position. If it took profit, and conditions are still met, then open another position. (only single position will be taken)
-
The first position opened when conditions are met, will be opened at lot size of 1.0. When that position is closed, the next position to be opened (within the same candle) is 0.9, and so on. Essentially after the position with lot size of 1.0 is closed, lot size will gradually decrease by 0.1 for every position closed. Until it reaches 0.1. when position with 0.1 has been closed, then the next position to be opened will be 0.01.
-
Any positions opened will be closed immediately on the new candle opening price.
-
At the same time, when a new candle is opened, and the previous position is closed, and conditions are met, then open the position with lot size of 1.0, and ten the process repeats itself. For every candle opened, the first position to be opened will be opened with lot size of 1.0
*Kindly note:
- Do not worry about my broker
- I do not know anything about EA and it's terminology (such as constants and variable, etc)
- Do not show me tutorials
- I know very minimal about FxDreema
- Kindly just show me what to add in to my set up, no more no less
Your earliest response is much appreciated.
Sincerely
-
-
@ramimoujaes A Take profit of 1 pips is not a realistic target. Are you sure your broker will allow it? I see you say we should not worry, but let me insist that it is probably a bad feature for a strategy.
-
Greetings @l-andorrà
It isnt issue.
-
@ramimoujaes Your money management is certainly weird. What's the point of opening more than ten trades with decreasing lot size? And what is the maximum number of open trades possible?
-
Greetings @l-andorrà,
-
Don't worry about money management (I am testing a certain philosophy.
-
There is no limits regarding what is the maximum number of open trades possible. only the fact that only one position is opened for ever time conditions are met.
-
For every candle opened, when conditions are met, one trade is opened. The first position is opened at lot size of 1.0, and then for every position closed decrease the lot size by 0.1. Then when the position with lot size of 0.1 is closed, any other ought to be open will be opened at lot size of 0.01.
-
When a new candle is opened, any opened position shall be closed.
*It is important that when a candle is opened, and conditions are met, and there is a position already opened, the first step is to close the previous position, then open a new position with lot size of 1.0 (-similar to step 3).
*I appreciate your concern, but do not worry about anything else. I just kindly ask for your help.
Sincerely
-
-
@ramimoujaes Then yopu can try this:
-
Greetings,
Do you care to tell me, where do I fit your shared link in my shared link? (like where how do I connect what you created with my shared project
Also what is the type for variable and constant?
-
@ramimoujaes All constants and variables are of a 'double' type. And this is how you should try it:
-
Greetings @l-andorrà ,
Thanks you for your cooperation. There is just one small problem. Below, you will find an image, explaining that the EA is not opening position for every time conditions are met, which is a bit odd.

As you can see from the image above, it has successfully decreased trades up to 0.1 (I expected to see the next position after 0.1 to be 0.01, but we can not decide on event, so we can do this last, however, it was successful enough to decrease trade), but it did not reopen trades later on when it was overbought or oversold (when conditions has been met). What do you recommend we should do?
*The issue for now is that it is not opening a position for every time it is overbought or oversold
Shared Folder:
https://fxdreema.com/shared/4dIzODw2d
Above is my shared folder, I kindly request from you to have a look at it, I made it a complete replica of your latest shared folder. Kindly check if I did something wrong (hopefully I didn't)
Your response is much appreciated
-
@ramimoujaes You should specify candle ID 1 in blocks 15 and 30:

-
Greetings @l-andorrà ,
After amendment, it still did not work. Below you may find the image:

Shared Folder:
https://fxdreema.com/shared/bWGQGFJSc
*As you may see, it was successful in decreasing trades, but it is not opening the trade every time conditions are met (in this case, when RSI indicates overbought or oversold). Your further assistance is much appreciated.
**If I am not mistaken (bare in mind I am not an expert), the EA is decreasing lot sizes by 0.1. But I do not think that the EA understand that when conditions are met again, it should restart the process; as in open the position with lot size of 1.0 and decrease it by 0.1. I think if I am not mistaken, the EA is decreasing lot size by 0.1 on a general basis, therefore, after 0.1, well then comes nothing because 0.1-0.1 = 0. I am not sure, it was just a thought. The EA should open position for every time conditions are met
Sincerely
-
@ramimoujaes Ok. Then substitute both 'No position/order' blocks with one 'Once per bar' block connected to both subtrees. That way a new order will be open every time are met, but you can have more than one buy or sell at the same time.
-
Greetings @l-andorrà,
That did not quite work as per below image:

Issues:
-
It only took one position per bar; after position was closed, conditions were still met, yet no positions were opened, which is odd.
-
It is not closing the positions at the new candle opening price; as you can see, there is a red dotted line, which indicates that it took a couple of bars to close the positions.
**I think we should target the first issue, which when conditions are met, the first position must start off with lot size of 1.0 and then decrease it by 0.1. When the position with lot size of 0.1 is closed, any further positions ought to be opened shall be opened with lot size of 0.01 until a new candle is opened. When a new candle is opened, then close previous position and check if conditions are met. If conditions are met, then open a position with lot size of 1.0, and the process repeats itself.
If there are any questions, or if there is something unclear, please do ask me.
Shared Folder:
https://fxdreema.com/shared/YZDOmflV
Thank you for your cooperation and your earliest response is much appreciated.
Sincerely
-
-
@ramimoujaes Then I don't understand what you need. How many open trades do you want every time conditions are meet?
-
Greetings @l-andorrà ,
It is ok. I will re-explain myself. The condition is simple, when price is overbought or oversold, open one position. That position would have a lot size of 1.0. When the position with lot size of 1.0 closes, and within the same candle bar conditions are still met, then open another position with lot size of 0.9 (-0.1 lot size from the previous position closed). This somewhat worked when we had the "No position/order". The issue is that, when condition are met, it is not opening position. There are no limits to how many position ought to be opened. The issue, to be more specific, is that when the EA discovers that price has been overbought or over sold, it opens positions and closes them as well. But, as time passes by, essentially conditions are going to be met again (when it is either overbought or oversold), during that stage it is not opening a position; when conditions are met again on a new candle bar.
For a better understanding, lets look at the picture below:

As you can see, the first position was opened at lot size of 1.0 which is great. But after a while, conditions are met, but it opened position size of 0.9, which is wrong, because this is a new candle, therefore, the position must be opened at 1.0.
Always when a new candle is opened, and conditions are met, open with lot size of 1.0. Then if conditions are met within the SAME candle, decrease the lot size by 0.1.
*EVERYTIME conditions are met (whether overbought or oversold) a position must be opened, the trick part is where is it opened, if it is opened on a new candle, then the position must be lot size of 1.0. The key is that where and when are the position being opened, if it is opened within the same candle then decrease the lot size, if a new candle is opened, the restart; starting lot size would be 1.0 and if conditions are met within the SAME candle, then decrease the lot size by 0.1.
I appreciate you help, and my apologies if I was not clear before. If there are any questions, please do tell me.
--To answer you questions, no there are no limits.
Shared Folder:
https://fxdreema.com/shared/AxtJUMA6d
Sincerely
-
-
@ramimoujaes here's a tip:
https://fxdreema.com/shared/66msZc8rc -
Greetings @roar @line @l-andorrà ,
Can you please tell me where would I place this in my shared folder. Also can you please tell me what are the P3,P4,P31,P32,P33,P39, P40.
Doing this is really giving me a headache at this point XD
-
@ramimoujaes I don't know about your folders.. Do you mean the builder? Build it On Tick.
The P's are just shortcuts to different arguments in your block, you can modify your varialbes in the right popup pane using those shortcuts. But if you dont want to use them, just forget them, they arent any danger.