Endless buy and sells in a row
-
Hello,
for training purpose I wanted to make a small EA, which uses the Stochastic Oscillator. The plan is to buy, when there is a crossup below 20 (with TP/SL) and to sell immediately should the main line reach 80.My problem is, that there are phases in which the EA buys and sells several times in a row and I don't understand why. Here is a link to the project https://fxdreema.com/shared/e408T8Mie

-
Block 3 should specify sell positions only and not buys too.
-
Thanks for your answer. Can you explain to me why this has to be the case? Until now I thought Buy positions were the important ones for that block, because it checks if I have bought a position or have an order to buy one and sells it, if the following conditions are true. Why does it need to be sell instead?
-
Because you are telling the bot that all condition on the right branch can be applied to open buys and sells on equal terms. What is the point of that? Then remove the buys branch on the left. Why two different sets of conditions are necessary to open a buy while only one set of conditions is applied to open a sell?
-
The left branch is supposed to open a buy and the right is supposed to open a sell. You are right, that block 3 doesn't need to include buy AND sell as a filter, but I still don't understand why it should check for sells. The right branch is supposed to open a sell at the end, so why should it check for a sell at the beginning? Wouldn't it make more sense to check for a buy (e.g. if I'm currently holding a stock or something like this) which can be sold?
-
What seems to be wrong to me is, once a trade is places on the left, right is free to constantly place trades, so as soon as the condition is true a trade is placed on every bar.
-
Shouldn't block 3 stop this (if the filter is set to buy)? My understanding was something like this:
Block 3 checks, if I hold something (e.g. a stock) -> If that is true, the next block checks a second condition -> If that is also true, my held position is sold (e.g. the stock) -> Block 3 isn't true anymore (I'm not holding a position), therefore the right branch stays inactive.
I mean yes, it obviously doesn't work that way, when I test it, but I don't see the mistake. Why is the right branch free to endlessly place trades?
BTW: In testing Block 3 with buy filter causes the same problem. Block 3 with sell filter doesn't do anything, which defeats the purpose.
-
No because that is switching the right side on if the left has placed a trade, do this set the left side to buys, on the right if buy - no sell - rest of your blocks. setting this up with the extra block should make it work.
-
You mean like this? https://fxdreema.com/shared/FSjLy415c
Testing it has the same loop of buy and sell like before.@jstap said:
No because that is switching the right side on if the left has placed a trade
I'm not sure, what you mean. I want the right branch to switch on, when the left has placed a trade, so the position will be sold at the right time. Since both sides check the same indicator and both sides are mutually exclusive (left <20 and right >80), I don't understand why the rebuy from the starting image happens.
-
If I remove the SL/TP of the sell block, there are no rebuys. Instead several sells in a row will be opened and yet the single position I currently hold won't be sold.
After seeing this, I think I somehow misunderstood the function of sell blocks. Do they not pay attention to the currently held positions?

-
You need to add the latest shared link to see what's been done and say what the problem is.
-
-
This project implements your idea from your second to last post: A check that there is a buy position and no sell position. - https://fxdreema.com/shared/sNhTNLzGb
This still results in an endless buy and sell like in the first picture. -
When I remove the SL/TP from the sell block and use the setup like before (without checking, if there is already a sell) ( https://fxdreema.com/shared/uAvpxz06 ) I get an endless sell like in my last picture.
-
When I remove the SL/TP from the sell block and use a check that there is a buy position and no sell position, I get a single sell (which is good), but it doesn't actually sell my currently held buy position. I creates a parallel sell position. ( https://fxdreema.com/shared/2698Veegd )
My problems / questions are:
- Why creates a SL/TP in the Sell block an endless buy and sell as seen in the first setup / example?
- Why won't my position be sold in the third setup / example? I don't even understand, what the sell position actually does, when it doesn't seem to care, if I actually have something (e.g. a stock) which can be sold.
-
-
Probably because you are using % of TP and % of SL without either being a fixed number.
-
Could you explain this a litte more in detail? Is this an answer to both questions and why does a percentage have that effect?
-
Test by setting both take and stop to a fixed value. When building EAs use a process of elimination, then you will find what is causing the trouble.
-
I was hoping to understand the inner logic of whats happening instead of just testing around until i get a working version.
In another thread you told me sell sells and buy buys, but there are obviously a few more nuances. If i want to use the sell block most effectively I would like to know as much as possible about its inner workings.
-
There is lots of information on this on the internet, to learn by testing will teach you the why, or at least limit the question to 1 area of understanding. All the logic in FX blocks comes from meta trader's design, what each block does is enact one of these commands.