Trying to learn multiple conditions in an EA
-
Hi - I am new to fxdreema, I hope this is posted correctly. I am trying to create a test EA that has the following rules for a sell condition (although buy would be exact opposite). I have created a project and seems to get stuck around the transition from Step 2 to Step 3 and I would appreciate any pointers;
https://fxdreema.com/shared/FcAMNUzHc
Step 1
20EMA has to be below 50EMA and 200EMA
50EMA has to be below 200EMA
Step 2
Price needs to close above the 20EMA, although not close above the 50EMA
Step 3
With Step 1 & 2 still valid, price needs to close back down below the 20EMA - this would trigger a trade.
Apologies if this is basic. I have completed a few simple EAs already that operate, although I cannot work through the logic correctly. Any help appreciated. -
Your project is designed to search for all those conditions to happen exactly at the same time while I guess those steps are supposed to happen in different moments in time, right?
-
Yes - that is right. I have a few projects that I want to have conditions initially in place, and then have secondary, and possibly third conditions.
I am not looking to have the answers provided as I want to learn, although if you can give a few pointers I will update project as I go if that is okay?
The logic is:
Step 1 - all steps must occur
Step 2 - in addition to all steps in step 1, which may be 1, or many bars later
Step 3 - the close below the 20EMA must occur before a close above the 50EMA, and whilst step 1 conditions are still valid.
If I can get the logic of this correct, then I think it will be very beneficial for the testing I would like to do.
Thanks in advance for any advice! -
Then you need to disconnect each step from the previous one and use a boolean variable for each one so that the next step can 'know' the previous one happened.
-
Oh right - so I should have Step 1 with an output variable or true / false?
And then step 2 will look for the output variable from 1 to be true to be allowed to run, etc?
I shall try this in my lunch break and do an update. Thanks! @l-andorrà -
@RazordLid
@l-andorrà
I've had a go and still getting some strange behaviour - would you be able to have a look and let me know why I experience the following problems:- I have set this to Once per bar, and tested it on a 1H timeframe, although I get the initial status message for Stage 1 much more often than this
- When I switch on the Stage 2 condition, I don't get any Log messages from the Stage one at all
https://fxdreema.com/shared/B14C8DZUc