after closing profitable trades, Wait for remaining trades to profit before closing?
-
hello there guys! first of all I want to say im very happy to be a part of the FxDreema community!
I have been waiting to pull the trigger for some time now and i am glad i did! these tools have made the job
of creating excellent forex ea's simply amazing and fast.I have a question about how i would structure a certain logic into my ea , but first i want to post a shared link to my ea for those more advanced that don't care for my explantion of the logic.
https://fxdreema.com/shared/goneOZ93b
so in order for my question to make sense first i need to explain the objective and logic of this ea i have named
"close the gap" for simplicity.I have created a very basic ea, my first one, and the logic is very simple and profitable in my testing.
So the premise is the when the 100 ema is below the 500 ema, the ea will wait for a candle to close above the 100 ema then it will open a buy order. (vice versa for sells) . it will open a buy order every time this condition is met.
then it will wait for a candle to touch the 500 ema and it will close all open buy orders.
here is where my question comes in.
80 percent of the trades will close profitable when a candle touches the 500 ema, but sometimes a couple will close slightly negative. What i want to do is have the ea close all profitable trades when when the candle touches the 500 ema, then go into a wating period on the remaining trades and close them as soon as they are in any kind of profit or break even, accounting for spread plus commision ect. Basically as soon as the trades are not losers, i want to ea to close them.
Does any one have an obvious logic chain or solution to this, I'm assuming im not the first person to ask this, but ive looked around the forum and can't seem to find the answer i'm looking for.
I would greatly appreciate any insight into this query. and its totally ok if you don't . I still love ya! thanks again.
-
anybody have a clue?
-
Substitute your current 'close trade' paths for this (buys only)
https://fxdreema.com/shared/9G4rdekBb
Not tested, but that should work.
-
@l-andorrà thank you I will give this a shot!
-
@l-andorrà thank worked really well thank you so much for your help, you really know what you are doing don't you?
-
@wralyn watch out your bot without a stop loss could be dangerous if your conditions are not met
-
@l-andorrà said in after closing profitable trades, Wait for remaining trades to profit before closing?:
Substitute your current 'close trade' paths for this (buys only)
https://fxdreema.com/shared/9G4rdekBb
Not tested, but that should work.
This is strange. The first 2 blocks are working for the loop - some trade is selected and we reach block 3 when that trade is profitable. But then block 3 is a condition. When the first block runs, it will load the first available trade, then run block 2... after a moment it will load the second available trade, then run block 2 again... but this all happens as quickly as possible. The only thing that slows the whole loop is block 4, because when you close a trade, it takes second or two.
Then this blue block is strange to me. Why not the pink "close" block?
The whole thing looks to me that you are trying to initiate the closing procedure, assuming that while the trades are being closed, some time can pass and the MA values could change. This is strange. I'm also not sure if wralyn was asking for that, but I don't telly understand what he means. I have some feeling that he wants to delete the currently profitable trades and "mark" the rest for deletion at a future time, maybe not caring about 500 ema anymore.
-
You are absolutey right FxDreema, What i was asking for is when the price hits the 500 ema, close all the trades that are profitable at the 500 ema, then for the trades that are not profitable at the 500 ema, what for price to move a bit further than close them at break even or small profit. i decided to add this after back testing showed the price usually moves beyond the 500 ema once it is hit, and most of the unprofitable trades just need the market to move a small percentage more to be profitable.
I'm a beginer at using the FxDreema software, but the premise seems valid to me. And after testing the new EA results for the last 6 months of trading have been very profitable.
If there are ways to improve the EA i'm definitely listening.
Here is what i ended up with after implementing the changes suggested.
-
Also what i have found is that 1hr time frame yields the best results in my testing, if you go down in time frame the moving averages need to larger, and if you go up in time frame they need to be smaller to get similar results.
the only problem is that the Ea does not loose trades, i ran a test and over 200 trades in a row are winners over 6 months, so if market gets out of hand or a runaway trend occurs could be trouble as Nacim mentioned.
-
Running your little EA is a heady experience! Something so SIMPLE works extremely well. Very nice algorithm. Thank you for sharing.
-
Hello wralyn,
May I suggest that one small change could possibly help with drawdown and long-term open positions at the same time. You could try adding another parameter to your protocol which would be a minimum pips (such as 10 pips) as a separation between the EMA 100 and the EMA 500. Seems to work like a charm. -
@dscoles How do you do this one? This may help in the project I am doing.
Hi @l-andorrà any thoughts on this as well? Thanks. -
@fideld003 What do you exactly need?
-
@l-andorrà Per the suggestion of @dscoles, "May I suggest that one small change could possibly help with drawdown and long-term open positions at the same time. You could try adding another parameter to your protocol which would be a minimum pips (such as 10 pips) as a separation between the EMA 100 and the EMA 500. Seems to work like a charm."
@l-andorrà I'm trying to think how to do the suggestion of @dscoles, but I could not wrap my head around it.
Thank you for the response. -
@fideld003 You can insert a minimum distance between EMAS this way (for buys only):

You should reverse both EMAs positions for a sell.
-
@l-andorrà awesome stuff! Thank you for showing this to me. I'll try this minimum distance check on my project. I really appreciate it.
@dscoles thank you for the tip. Hope you're doing okay.
-
@fideld003 You're welcome.