How to properly set up this EMA situation?
-
I am trying to figure out how to draw out these situations:
Sell:
previous candle ( candle 0) is below 8EMA
current candle ( candle 1) rises above 8EMA
Current candle (Candle 1) closes below 8EMA
execute trade at the start of the next candle (candle 2)Buy:
Previous candle (candle 0) is above 8EMA
Current candle (candle 1) drops below 8EMA
Current candle (candle 1) closes above 8EMA
execute trade at the start of the next candle (candle 2)I attached a picture of how I thought it should be laid out for the sell (buy is the same concept) but it isn't opening trades correctly?
any help is greatly appreciated!
-

-
I tried your current project and it makes bunch of sells and buys:

If you still have the problem, are ypu sure that you are backtesting the correct EA and do you have any errors? -
Yes, I know. It isnt waiting until the candle close to execute trades. I was hoping that it would wait until the candle closes to execute trades.
There are no errors, everything is working correctly. I do not have the parameters set the way that I have it envisioned in my head.
I want every trade to be executed at the very beginning of a candle, not in the middle of one.
Thanks for your help!
-
@traderjud I suggest (as I have done several other times) not to use the ID 0 candle, because the zero candle is not defined as it is forming, once formed it automatically becomes the ID 1 candle, so in all "condition" blocks we must use the ID 1 candle



-
That made a lot of sense, and I thought that might have been the issue. It still isnt making entries like I was hoping though.
Here is an example of an Ideal entry:
https://www.tradingview.com/x/8sfkS8v7/ -
@traderjud it seems to me that there is a bit of confusion with the candles: the candle 0 is the current candle that is being formed at this time and is not yet finished, the candle 1 is the candle that has just been completed (to the left of the candle 0 ), the candle 2 is the candle to the left of the candle 1 etc.
perhaps this is the problem
-
Yes, I understood that.
The issue is, I want candle 0 to break above the 8ema, then the second candle 0 turns into candle 1if it is outside of the 8ema then execute a trade. ( In a sell, break above the 8ema and close below then execute a trade. In a buy, break below the 8ema and close above then execute.) The candlestick would look something like a hammer with the wick going through the 8ema but price closing outside of the 8ema in the direction of the trend.
Hopefully this makes sense.
-
@traderjud please, share your project
-
@traderjud said in How to properly set up this EMA situation?:
The candlestick would look something like a hammer with the wick going through the 8ema but price closing outside of the 8ema in the direction of the trend.
i think this is where you answer to your question. First you explain how candle 0 turns into 1 and so on, but try to look at the situation after it happened. Be in the present moment and look how candles look in the near past. Instead of wondering how to detect multiple rules one after another in the time.
So it sounds to me that you want to detect when Candle High is > MA and Candle Close is > MA. I can also see that you did that in your project... but I don't understand why for MA you use candle 1 (the previous candle) and for High/Close you are using candle 0 (the current candle). I think you want to use Candle ID = 1 for both.
You also say that you want the candle to close... take a look at this example - https://fxdreema.com/demo/mt4-once-per-bar