Exit Conditions
-
I am working on exit conditions for ea's and I want to exit based on certain indicators behavior. When my indicator moves in the opposite direction of my current trade, I want to monitor its status for a few seconds, minutes, ect. before the ea closes the trade out. I also would like to be able to not close the trade should the indicator move back inline with my trade. I tried to make an example of what i want to so here.
http://fxdreema.com/shared/yQGTBlf9c
Let me know if i am on the right track,
Thanks,
PS. If i am on the right track I need to know what to attach to the yellow output of the condition block to prevent the closing of the trade.
-
This block "Once per minutes", if executed and passed now, can pass again after 20 minutes or more. If you access it after 30 minutes, it will pass and will start to count new 20 minutes from that time. This logic can lead to irregular periods, shifting of the next 20-minutes period, because it's all depending on when the block is executed (and passed).
What do you need - regular periods (like Once per bar) or not?There is a category named "Flags" and these blocks are very similar to using normal variables in the project. The idea is... let's say you have variable named "CanDoIt" with value "true". If the variable is "true", you can go to close all trades, but if it is "false", you can't. And you can make it "true" or "false" anytime, anywhere.
-
What i'm trying to get at is a condition needing to be true for x amount of continual minutes. For example moving average 10 less than moving average 20 for 5 solid minutes. If for any reason during those five minutes the moving average 10 is greater than the moving average 20 the close all trades block is not excuted and the 5 minute timer is reset to zero.
-
Because you want to check MAs for a period of 5 minutes and to take action at the end of that period, you have to use variable to store the temporary state. Let's say value "true" of that variable means to close all trades and "false" means to do nothing. At the beginning of the period the value must be "false", in the middle of the period it can become "true" (depending on MAs) and at the end of the perood you will ask if it is "true" or "false". If it is "true", you will close trades and modify the variable back to "false". Then the new period begins and the same procedure starts again...
I just added negative output of "Once per minutes" because it was not there and I think it will be needed, but my mind is almost asleep right now, so I will continue tomorrow... meanwhile you can try something.
-
I don't mean to sound dumb, but, I don't actually know how to use variables. I understand the different blocks well enough to do most things I want to do, but, variables and constants I'm not knowledgeable with.
-
Variables explained at 0:20 - 1:25 in https://www.youtube.com/watch?v=aeoGGabJhAQ
-
Something like this? http://fxdreema.com/shared/Uzvugs75d
When backtesting, white checksigns are the moments where it tries to close the trade, yellow x-signs are the moments where it says that no close will happen on the next check.
Those 3 blocks on the right are optional, they does not matter in the strategy and can be removed. Block "a" is connected between "5" and "10" because otherwise "10" changes the environment for "a".
Every "n" minutes - this is a block who can pass once at the last minute in the period. When started for the first time, it does not pass.