fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Simulating trades outside of trading hours

    Questions & Answers
    2
    10
    2254
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      FXB last edited by

      I have searched but can't seem to find if there is any option for what I want to do, I wonder if someone can help.

      I am using an MA Crossover strategy with confirmation of the trade by using a candle pattern before entry. But I only want to trade during certain hours.

      Now what I would like to do is this: lets say my trading hours are 1300-1700, if there is an MA Crossover at 1200 followed by my signal candle pattern at 1230 then I effectively have an "active" trade, albeit outside my trading hours. What I don't want to do is enter this as a "late entry" at 1300 (start of my trading hours) as I have now "missed the boat" on this trade. I would like to wait for the next MA Cross then signal before trading. However if there has been an MA Cross at say 1250 but no signal I would like to enter a trade after 1300 without waiting for a further cross.

      Hope this makes sense, I would effectively like the EA to still recognise all trades but just not enter a trade other than in my specified trading hours.

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        Indicators are based on candles - each point of the indicator belongs to a certain candle, and candles are based on time. So for example, in 13:00 you can analyze something happened in 08:00. It's by taking a value from the indicator from the N-th candle on a certain timeframe.
        In other words, to analyze indicator/candle data we look from the present to the past.

        If we want to look from the present to the future, we have to save some data now an use it later. For example, in 10:00 we remember that event "A" happened, and in 12:00 we check whether the event "A" was happened. For this... well, there are many ways to remember something and use it later in fxDreema - Flags (there is a category of blocks named like this), Variables (basically the same thing - set variable and assign value to it), and Formula block (practically the same as Variables).

        I recommend to use the first method if possible - analyze past data.

        1 Reply Last reply Reply Quote 0
        • F
          FXB last edited by

          Thanks, that makes sense.

          I've had a go at various different setups but can't get any to work properly, any chance you would be able to have a look and give me a few pointers?

          I can't seem to get it to analyze the previous "n-th" candles as you have described.

          This is a basic version of a Sell Trade, any help would be greatly appreciated http://fxdreema.com/shared/XCPQRnAWc

          Cheers.

          1 Reply Last reply Reply Quote 0
          • fxDreema
            fxDreema last edited by

            You have single "Time filter" block, which passes all the time between 12:00 and 16:00. By the way, it's logically better to put that block on the top.

            But on the closing side... at any time if MA33 is lower than MA10 you close everything. Note that this is not a crossover, it's a simple condition - something is lower than something else at this moment.

            Here is a little bit more about crossover for indicators: http://fxdreema.com/documentation/proje ... er%20works

            In "Condition" in "More settings" there is an option "Candle ID" for most of the instruments, you can use it for the indicators if it's needed. If you put Candle ID to 100 for Moving Average, this operand will get the value of the 100th candle in the past. By defaut Candle ID is 0, which means Now.

            1 Reply Last reply Reply Quote 0
            • F
              FXB last edited by

              Interesting about the MA Crossover, I have updated this & also the Time Filter, thanks.

              I have tried the Candle ID but it still doesn't make sense to me, maybe I'm being a bit slow! I understand that Candle ID 100 would give me the value of the 100th previous candle, but how can I check, for example if there was a trade in the past 5 hours using this, without entering 99/98/97 etc. I assume there is a quicker way but am at a loss how this can be done? I am thinking to use Set Flag true/false to tell me if I am "in" a trade already at my starting time (to avoid entering), but I can't understand how the program would "back-test" this to set my flag accordingly.

              Thanks.

              1 Reply Last reply Reply Quote 0
              • fxDreema
                fxDreema last edited by

                Indicators are related to the candles, and the candles itseld. Trades and orders are not, they are not some naked price levels, but they have other attributes like the time when they are opened (open time). You can check the if the trade is older than X minutes for example. This functionality is located in one of the pink blocks, and I think you will get it - I can see you already use loops.

                1 Reply Last reply Reply Quote 0
                • F
                  FXB last edited by

                  I have tried every possible combination I can think of & am now going around in circles....!

                  "Start History Trades Loop" is the one I think I should be using, and I am setting flags where there is a trade within the last 5 hours, but I can't seem to get it to work at all. This is where I have got to, I have no doubt over-complicated the whole process but am now at a loss as to what else I need to do http://fxdreema.com/shared/77kfTakPc.

                  Could someone take a look & give me some advice please?

                  Cheers.

                  1 Reply Last reply Reply Quote 0
                  • fxDreema
                    fxDreema last edited by

                    Can you write the strategy step by step? Something like...

                    at 12:00 - check condition A and if it's true remember that event A happened.
                    at 12:30 - check condition B and if it's true remember that event B happened.
                    at 13:00 - if event A and event B -> do C. If event A, but not event B -> do D. If event B but not event A -> do E.

                    Doing this is actually constructing the strategy. Knowing what steps must be taken you will know what blocks are needed. And knowing what blocks are needed you can ask me "Where can I find a block that can do this?".

                    And by the way, do you know what are the history trades?

                    1 Reply Last reply Reply Quote 0
                    • F
                      FXB last edited by

                      Thanks, the strategy is very basic in itself, and for the most part I have it working. There is just one element which I can't work out 😕

                      This is the basic premise for a Sell trade:

                      I only want trade from 12:00 until 19:30 so

                      Set Start Time 12:00
                      Set End Time 19:30

                      At 12:00
                      Check no trades are running
                      Check Condition MA10<X MA33
                      Check Condition Candle1 High < MA10
                      Check Condition Candle0 < Candle1

                      If all conditions are met
                      Sell 1 lots, no SL/TP
                      then

                      If trade is running
                      Check Condition MA10>X MA33
                      Close Trade
                      Or
                      At 20:00 Close all trades

                      This part works fine, however it is the next part which I cannot work out. I am attempting to use "Start History Trades Loop", however as I'm not actually placing any trades 20:00-12:00 I don't think I can use this option (as there are no actual trades during these times).

                      This is what I would like to do:

                      At 12:00 (once every day)

                      Check to see if there has been a valid signal in the last 5 hours (i.e all trade conditions met), and there hasn't been an MA Cross since this signal.

                      If Yes
                      wait for the next MA Cross before entering a trade.
                      If No
                      take the next available trade.

                      So my thinking would be that at 12:00 I need to check for any historic trades in the last 5 hours, and if there is a trade setup in progress then wait until the MA's Crossover to signal a new trade. To do this I have tried this:

                      Once a Day at 12:00
                      Start history trades loop
                      (in loop) Check trade/order age for trades newer than 5 hours
                      If there is a trade in the last 5 hr
                      set flag to Y
                      else
                      set flag to N

                      I have then included in my trade criteria an option:

                      Check Flag
                      If set to Y then Stop
                      If set to N pass through and trade as normal

                      I think the Time Filter may be causing this to fall over, as trades are not being placed outside my trading hours, so perhaps I need an option to identify all trades and a seperate option to only activate a Sell where it is inside my trading hours, but then I don't know how it would then identify these previous setups at 12:00 when my trading starts.

                      Hope that makes sense.

                      Cheers.

                      1 Reply Last reply Reply Quote 0
                      • fxDreema
                        fxDreema last edited by

                        History trades are already closed trades, not the running ones. You really want to check already closed trades, not those who are still running?

                        At 12:00 do you really need to check for past crossover or just MA1>MA2? Because the crossover is valid for a single candle somewhere.

                        When you wonder if/when some block passes, place "Draw arrow" below that block and you will see many arrows on the chart where the block passes. There is also a block named "Logic points tester" which is designed to do the same - to check what is happening somewhere in the project, but it draws a line instead of multiple arrows.

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post

                        Online Users

                        G
                        E
                        T
                        M

                        11
                        Online

                        146.8k
                        Users

                        22.4k
                        Topics

                        122.6k
                        Posts

                        Powered by NodeBB Forums | Contributors