Elite indicators :) - page 313

Mladen Rakic
151718
Mladen Rakic  

Greg

Here is a function that checks if there was an order opened at a current bar.
int countOpenedOnACurrentBar()

{

int openedAtBar = 0;

datetime startTime = Time[0];

datetime endTime = Time[0]+Period()*60;

for(int i=0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderSymbol() != Symbol()) continue;

if(OrderOpenTime()=endTime) continue;

openedAtBar++;

break;

}

return(openedAtBar);

}

[/php]
The purpose of it is to count all the orders opened at a current bar (so it depends on the time frame at which the EA is attached to) Then somewhere in the code, you would need to add something like this :
if (countOpenedOnACurrentBar()==0) then it can trade[/php]
If you want to check a certain time frame (for example if a 1 hour time frame) you would need to modify the countOpenedOnACurrentBar() to something like this :
[php]int countOpenedOnACurrentBar(int timeFrame)

{

int openedAtBar = 0;

datetime startTime = iTime(NULL,timeFrame,iBarShift(NULL,timeFrame,Time[0]));

datetime endTime = startTime+timeFrame*60;

for(int i=0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderSymbol() != Symbol()) continue;

if(OrderOpenTime()=endTime) continue;

openedAtBar++;

break;

}

return(openedAtBar);

}

So, the time frame is added and if you call the function like this
[php]if (countOpenedOnACurrentBar(PERIOD_H1)==0) then it can trade
The upper example will check if an order was opened on a last 1 hour bar (that would allow you to trade only 1 order per 1 hour bar) You must take care that if you attach the EA to, for example, 4 hour bar, it will check only if the order was opened at the first hour of the 4 hour bar so you might end up n a problem if time frame is not checked (in that case add something like timeFrame = MathMax(timeFrame,Period()) which will avoid that trap)

____________________________

If you want to have a specific interval between the orders, the simplest way is to to loop through all orders in order find the last order (simply the biggest open time of orders) and then add 3600 to that time : if TimeCurrent() < than that time you can not trade. The problem with that approach is that it can be time consuming in cases when there is a lot of orders in history (you must loop through all the orders since metatrader explicitly states that accessing orders by position does not guarantee that those orders are ordered by time)

kalusao:
Mladen,

I have tried it with that configuration but I still have more than 1 trade per hour occasionally.

I would like to have the following: Let's say a buy order was opened at 15:05 and closed by take profit or another close rule at 15:20. Then the next buy order should not be opened earlier than at 16:00 (when a new bar appears) even if a buy condition is met before. Other closes than by take profit I want at the end of a bar.
Flytox
256
Flytox  

Hi Mr Mladen,

could you please add an MTF parameter to this one if it doesn't exist already.

Thanks

Files:
Mladen Rakic
151718
Mladen Rakic  

Flytox

Try out this one

It is an EA (not an indicator) but this one shows time even when ticks are not coming in (unlike the indicators which works only when ticks come in and if you do not get ticks, you do not get a clock update) You can set up the additional time frame too (in the AlertCandleTF - in which case it is showing time left on the current time frame as well as the "other" time frame - like on the picture, in the lower right corner is the 4 hour time frame and near the daily data candle it is the current time frame)
PS: there is one more like this on this thread, but this one is change not to require alerts turned on in order to show "other" time frame bar too

regards

Mladen

Flytox:
Hi Mr Mladen,

could you please add an MTF parameter to this one if it doesn't exist already.

Thanks
Files:
eclock.mq4 8 kb
eclock.gif 20 kb
Flytox
256
Flytox  

thanks a lot Mladen

ismael360
748
ismael360  

Nice eClock, Mladen.

hazelj80
170
hazelj80  

i was wondering if someone could put an alert on this when the green/red arrows appear on candle close?

thanks!

Mladen Rakic
151718
Mladen Rakic  

hazelj80

Here you go

regards

Mladen

hazelj80:
i was wondering if someone could put an alert on this when the green/red arrows appear on candle close? thanks!
Mladen Rakic
151718
Mladen Rakic  

This "theme" was actually started by CrustallumKvs and mrTools : the main idea is mtf-ing the ZigZag.

________________________

But in order not to let it be "just" a ZigZag, in this case it is attached to adxvma indicator. At a first glance the addition of ZigZag seems to be helpful, but it will need to be tested in real time since, like all ZigZags this one too can be changed in cases when new highs or new lows are reached. Well, let see ...

Updated version posted here : https://www.mql5.com/en/forum/general

ismael360
748
ismael360  

The ADXVMA_MTF_ZigZag is a great concept. I really enjoy when you guys combine two ideas like this. And I hope to see more.

Thanks Mladen

mktsagli
35
mktsagli  

adxvma mtf

Thank you MLADEN for the amazing on the ADXVMA.. i have one request

is it possible to add a horizontal line on the zigzag that show price and alert when price close below the horizontal line

for you convenience i have attach a screen shot as a exemple..

best regards