You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'd have better luck getting a federal tax refund...
I added the code as follows:
--------------------------
[other variables here]
datetime Timestamp = 0;
//+------------------------------------------------------------------+
//| Expert Initialization |
//+------------------------------------------------------------------+
int init()
{
LastPrice = Bid;
return(0);
}
//+------------------------------------------------------------------+
//| Expert start |
//+------------------------------------------------------------------+
int start()
{
if(Timestamp != iTime(NULL,0,0))
Timestamp = iTime(NULL,0,0);
------------------------------------
and it's not working; still generating multiple trades.
Have I entered it correctly?
The trade logic comes much farther down in the code; unfortunately the code is copyrighted and I cannot disclose it.
This is a simple code to do it. Isn't it?
int start()
{
if (Bars > BarsCount)
{
//your code to be executed only once per bar goes here
BarsCount = Bars;
}
return(0);
}No new order on same bar
Could anyone show me how to code this?
What I want is hopefully pretty basic, if an order closes on the current bar, no new order will take place until the next bar open (or after close of current bar).
Thank you for any help on this probably easy question for any good programmer.
Try This
See attached word.doc
Dave
Could anyone show me how to code this?
What I want is hopefully pretty basic, if an order closes on the current bar, no new order will take place until the next bar open (or after close of current bar).
Thank you for any help on this probably easy question for any good programmer.Wolfe, look here:
https://www.mql5.com/en/forum/general
Cheers
EA to open trade at next bar
Does anyone have an EA that you can drop onto a chart and it will open a trade on the open of the next bar? It would be nice if you could set the SL and TP.
Thanks
How to allow only one trade per break and close at bar close?
Hi,
I need help,
i have to put in my ea code a logic condition that allow only one trade per break condition and close the trade at the same bar close, then wait another signal break to trade.
Is there a way to do this?
Thanks in advance.
Lubo.
I moved your post to this thread - may be it will help.
The other related thread: https://www.mql5.com/en/forum/173026
Hi,
I need help,
i have to put in my ea code a logic condition that allow only one trade per break condition and close the trade at the same bar close, then wait another signal break to trade.
Is there a way to do this?
Thanks in advance.
Lubo.You will either need to post the EA's code and conditions you want implemented (but then the EA will be downloaded by everyone, shared, modified, sold ect) or you need to contact a programmer (most likely you'll need to pay for their time).
Or you can do what I did - learn MQL4 programming language
Nice code but the condition OrderOpenTime() >= Time[0] will not work.
Now lets check this condition:
if 12.01 >= 12.02 opened_on_current_bar = true;
will this code work ? I don't think so.Think again, my friend! It works perfectly Because you forgot timestamps are "number of seconds passed from 1st of january 1970" and Time contains opening of all bars, Time[0] is the opening time of the "now" bar of the current chart. Current time is TimeCurrent()
If the trade was opened in this specific bar, its open time is bigger (more seconds have passed) than Time[0]. So the code posted in the beginning by ralph.ronnquist will work properly. I'll quote it.
for (int i = OrdersTotal() - 1; i >=0; i-- ) {
if ( ! OrderSelect( i, SELECT_BY_POS ) )
continue;
if ( OrderOpenTime() >= Time[ 0 ] ) {
opened_on_current_bar = true;
break;
}
}
// Here the variable opened_on_current_bar is set appropriatelyIt will only keep your EA from opening more than 1 trade per bar.
Hope this helps everyone who finds this thread