Hedging problem
-
Hello everyone. I'm facing an issue somewhere, and I would appreciate it if you could help. What I want to do is as follows: Let's say I have 3 buy positions (0.01-0.02-0.03) at a total of 0.06 lots. If a sell-oriented condition occurs, I want it to open sell positions equal to the size of these lots, which is 0.06 lots. In other words, I want it to hedge the trades. If, by any chance, the condition returns to a buy condition, I want it to close the sell positions it has opened
-
The problem is defining those buy/sell-oriented conditions. Do you know exactly what conditions are those?
-
Let's say we have 4 buy positions: 0.01, 0.02, 0.03, 0.04, totaling 0.1 lots. When the 15-minute supertrend gives a sell signal, we will open a 0.1 lot sell position. In fact, this is all about accepting the loss instead of stopping the trade. If there is a significant drop here, we will escape from large losses because we have hedged our positions. Let's say our trades continue in the buy direction, and when the 15-minute supertrend returns to buy, the 0.1 lot sell hedge positions we opened will close. These positions can close in profit or in loss. If they close in profit, we can average down by taking new positions with the 15-minute buy signal. If they close in a loss, we accept it as a kind of stop. In summary, what I want to do is this: Condition (15-minute supertrend) >>> the total of all opened lots >>> open buy or sell positions equal to the total of all lots.
-
Sell (Hedge) Trade
1- If the 15-minute supertrend gives a sell signal,
2- Sum the lots of all open buy positions,
3- Open sell positions equal to the total of all open buy positions.Buy (Hedge) Trade
1- If the 15-minute supertrend gives a buy signal,
2- Sum the lots of all open sell positions,
3- Open buy positions equal to the total of all open sell positions.Close Sell (Hedge)
1- If the 15-minute supertrend returns to buy, close all sell positions.Close Buy (Hedge)
1- If the 15-minute supertrend returns to sell, close all buy positions. -
The supertrend indicator is simply terrible. It repaints and that means the bot s doomed with it. I strongly recommend using s different indicator.
-
ok. lets use as a condition 9 and 50 simple ma cross
-
Ok. Now we need to define the hedging conditions. How many open trades is the bot supposed to open at any time? Infinite?
-
The bot should open reverse trades equal to the total lot size of the previous trades. There is no limitation here. For example, if the bot opened 5 lots of sell, it should open 5 lots of buy to hedge. If the bot opened 3 lots of sell, it should open 3 lots of buy when the conditions are met. There is no limitation on the lot size, dear Andorra. It will only open one trade, and that trade will be equal to the sum of the other trades
-
Any suggest dear @l-andorrà
-
Sorry, I didn't see your last reply. If I understand it correctly, there can be an infinite number of trades open at the same time. The question then is how those '3 lots' are supposed to be distributed between, 2, 5, 20 or 100 trades. Do they need to be equally distributed?
-
No problem, @l-andorrà Let's not get caught up in the infinite number of trades at the same time, dear Andorra. The bot should simply open reverse trades equal to the total lot size of the previous trades. For example, if the bot opened 5 lots of sell, it should open 5 lots of buy to hedge. If the bot opened 3 lots of sell, it should open 3 lots of buy when the conditions are met. It's actually that simple. But I can't seem to figure it out, and I end up doing it manually. It will only open one trade, and that trade will be equal and opposite to the sum of the other trades.
-
Yes, That I understand, but I need to understand how many different values that variable can take. And apparently it can be any number. And when do you decide to open that hedge trade? What is more trades in the previous direction are open? A second hedge trade should be open with the combined lot size of the second batch?
-
I've solved the problem as shown in the picture, dear @l-andorrà. Thank you very much for your attention and assistance. I am attaching a screenshot to the post for the benefit of other friends." "In the Variable section, it should be entered as double - Lots_Volume_Buy = 0.

-
@chattahooche Well done for this, for your information, you can do this without a variable.

-
@chattahooche You're welcome, man!
