Basket take profit and profit retrace workaround
-
Hi again,
I've decided to create a workaround the the basket trail SL as the block is not working as expected.
I have the following settings up, but is not working either. Maybe because I'm missing a piece of the pie as I need some formulas to do so.Attached an image of my "basket stop system". What is planned to do is the following:
- I have divided a basket for buys and a basket for sells.
- Call the open trades by group (buys or sells)
- Have a close condition of the trades when profit of each basket is over $100, by using a condition conected to the purple block, in which I ask for "profit" -> "total value" and if is over 100, then close open and pending trades.
- Same thin as above, but use a loss of -$50, to that if the loss of the basket exceeds that, it closes open and pending orders.
Then, I have another system which intention is this:
- Activate it when profit of the basket has reached $20
- After activation, at all times calculate the maximum profit reached so far (so I select "max value" from the "value to get")
- Set a value of 70% of maximum profit as the SL for the whole basket. I calculate this with the formula "max value" x .7, and then store this value in a custom variable, that will be used for calculation in one condition block.
- If profit reaches 70% of maximum profit (water mark), then close all open and pending orders.
As you can see, I've worked with this model, but cannot make it work (none of the 2 functions I want) as not sure if I'm missing something, or have wrong connections or blocks. Also not sure if formula blocks should be connected to something.
I appreciate very much your help. This functionality is what I was expecting from trailing stop group of trades, but is not working for me.
I see that in attibutes and values of conditions I cannot use pips, so instead I use money.
Here is a link to the system in this example:
https://fxdreema.com/shared/3LdYKtLWb
Many thanks for your great help
......
basketstops.jpg -
What's wrong with "Check profit (unrealized)"? The idea of this block is to check the current porofit from a group of trades.
Max value - this is the the biggest profit at the moment, the profit from a single trade that has the biggest profit, the profit from only one trade. This is not the max. profit reached so far, there is nothing to collect such information
-
__What's wrong with "Check profit (unrealized)"? The idea of this block is to check the current porofit from a group of trades.
Max value - this is the the biggest profit at the moment, the profit from a single trade that has the biggest profit, the profit from only one trade. This is not the max. profit reached so far, there is nothing to collect such information[/quote:1epben0h]
Will try check profit unrealized block. I thougt max value refered to what I needed. So, in this case I need to use it instead if blocks 1,2 and 4?
Purple basket block is needed there?
All other blocks and connections are OK? Well structured?
Formulas need to be connected as I did?
I understand you have no block to count max profit achieved at a time (watermark). What would be your suggestion to create such functionality?
Thanks
-
Please, go to the examples and check those blocks - the purple "bucket" blocks and pink "for each..." blocks. There are some examples and each example have description.
In short, "For each... " blocks are used when you want to iterate throuhg trades, one by one, and do something with each one of them.
"Bucket" blocks are to be used when you want to get value (min, max, averate or total) out of a group of trades."Check profit (unrealized)" does everything inside - loads trades, collects data and checks the result.
Also check how to work with Variables. You can define as many variables as you want and modify them as you want. This is low level stuff and I will always recommend to not use Variables (at least not too many of them), but I will not add such functionality to collect profits over time.
What is the idea. If you have variable named "MyVar", then on each tick calculate the total profit and if the total profit is > than the value of MyVar => set the value of MyVar to that profit. This is simple. What is not simple is when to reset the value of that variable, because you have trades that will be closed and trades that will be opened. It sounds boring, but it depends.
-
__Please, go to the examples and check those blocks - the purple "bucket" blocks and pink "for each..." blocks. There are some examples and each example have description.
In short, "For each... " blocks are used when you want to iterate throuhg trades, one by one, and do something with each one of them.
"Bucket" blocks are to be used when you want to get value (min, max, averate or total) out of a group of trades."Check profit (unrealized)" does everything inside - loads trades, collects data and checks the result.
Also check how to work with Variables. You can define as many variables as you want and modify them as you want. This is low level stuff and I will always recommend to not use Variables (at least not too many of them), but I will not add such functionality to collect profits over time.
What is the idea. If you have variable named "MyVar", then on each tick calculate the total profit and if the total profit is > than the value of MyVar => set the value of MyVar to that profit. This is simple. What is not simple is when to reset the value of that variable, because you have trades that will be closed and trades that will be opened. It sounds boring, but it depends.[/quote:29srlbfe]
Hi there,
I´m now having issues with writing my custom variable. The reason is that I cannot find how to pull out the value of the "Check profit (unrealized)". When you work with formulas, you can set it to write the value of the calculation into a variable. I can see that in the block, you can edit variables as well. Attached an image, from which my guess is that the value of "compare" (or P11) is the value of current unrealized profit. So, will I simply put P11 in the orange field of my variable?Now, how to call custom variables from formula block? As in terminal variables, it clearly says "This is NOT for variables"
I suggest to review how your "trail stop group of trades" block works. It really has flaws when using it real time.
I found the block "trailing money loss group of trades", that my understanding is that it DOES keep record of the maximum profit from a filtered group of trades, and this may work out for me as well.
Many thanks for your help as always
EDIT: Following the image here, I set P11 in the orange box as drawn, but got a compile error. 'Compare' - Undeclared identifier
{
v::MAXProfitBuy = Compare;
block98(103);
}......
variables.jpg -
__The reason is that I cannot find how to pull out the value of the "Check profit (unrealized)"[/quote:2j3w60dy]
That's why I made those Bucket blocks - with them you can get the value in Condition. "Check profit (unrealized)", as well as ALL blue blocks do their job inside and does not put anything to the outher world. With "For each... " and "Bucket..." blocks you can load trade/trades and get different values in separate block (Condition or other blocks).
Use Variables in Condition -> Value -> Numeric
Those P things are the input values of the block. Again, blocks does not export nothing.
Give me example for EURUSD that contains 2-3 blocks and shows the problem in any block, and I will fix it or tell you if I don't want to "fix" it