if you save last 200 ticks then look how often a tick happend 3 or more times
So what do you mean price hits 1.5000 3 times in one day ....
I guess my problem is that i want to open an order after certain events have happened. i.e. at 1pm price hit 1.5000 then at 3pm a macd crossed then at 5pm a moving average hit a level.
I cant use if statements because these events are not happening at the same time.I guess my problem is that i want to open an order after certain events have happened. i.e. at 1pm price hit 1.5000 then at 3pm a macd crossed then at 5pm a moving average hit a level.
I cant use if statements because these events are not happening at the same time.You said that already . . .
Devries commented on the first part of my question. Can anyone help on the second part of my question?
You'll need to use static or global scoped variables to store counts etc. Here is a rough simplified template that I tend to use. This allows me to slot in extra steps to the strategy or remove them without too much pain...
#define STATE_BEGIN 0 #define STATE_WAIT_PRICE 1 #define STATE_WAIT_MACD_CROSS 2 #define STATE_WAIT_MA_HIT_LEVEL 3 #define STATE_ENTER_MARKET 4 #define STATE_NO_MORE_TRADES_TODAY 5 start() { static int state; if (day_changed) state=STATE_WAIT_PRICE; switch(state) { case STATE_WAIT_PRICE: code/fn to analyse tick/market for price if (condition met) { state = STATE_WAIT_MACD_CROSS; } // Fall through to save waiting for next tick if (state != STATE_WAIT_MACD_CROSS ) break; case STATE_WAIT_MACD_CROSS: code/fn to analyse tick/market for macd if (condition met) { state = STATE_WAIT_MA_HIT_LEVEL; } // Fall through to save waiting for next tick if (state != STATE_WAIT_MA_HIT_LEVEL ) break; case STATE_WAIT_MA_HIT_LEVEL: code/fn to analyse tick/market for MA hitting level if (condition met) { state = STATE_ENTER_MARKET; } // Fall through to save waiting for next tick if (state != STATE_ENTER_MARKET ) break; case STATE_ENTER_MARKET: buy, sell etc. state = STATE_WAIT_PRICE; or state = STATE_NO_MORE_TRADES_TODAY; break; case STATE_NO_MORE_TRADES_TODAY: break; } }
You'll need to use static or global scoped variables to store counts etc. Here is a rough simplified template that I tend to use. This allows me to slot in extra steps to the strategy or remove them without too much pain...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Lets say (for example) the price hits 1.5000 3 times in one day. I would like to buy it on the third time.
Is there any way MT4 can record how many times an event has happened?
I guess my problem is that i want to open an order after certain events have happened. i.e. at 1pm price hit 1.5000 then at 3pm a macd crossed then at 5pm a moving average hit a level.
I cant use if statements because these events are not happening at the same time.
Thanks to anyone who can solve this.