molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Sun Apr 28, 2024 10:04 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: One trade per bar!
PostPosted: Tue Aug 05, 2014 3:35 pm 
Offline

Joined: Mon Jul 07, 2014 5:01 pm
Posts: 4
Hello, I have a little big problem. I want just one trade per bar!. I found this (viewtopic.php?p=10210#p10210 )but it is a little complicated for me. :? Is there a easily solution for this problem maybe using mql+ icon?
I found this too:

bool isLastOrderCandle(){
//TRUE è già stato aperto un ordine su questa candela
//FALSE non sono stati aperti ordini su questa candela

int v_LastOrderHistory = OrdersHistoryTotal() - 1;

if (OrderSelect(v_LastOrderHistory, SELECT_BY_POS, MODE_HISTORY) && (OrderMagicNumber() == e_MagicID))
if (iBarShift(NULL, 0, OrderOpenTime(), true) == 0)
return(True);

return(False);
}

Is it possible to use it with mql+ icon. ( maybe I must start to study mql codes....I know)
Thank you very much


Top
 Profile  
 
 Post subject: Re: One trade per bar!
PostPosted: Wed Aug 06, 2014 8:32 pm 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
In the START icon you can set to trade bars or ticks. If you trade bars the trading condition is evaluated once per bar so potentially you will trade once per bar (if you only have one buy/sell in the ea). If that is not your case please explain your ea.
Unfortunately pasting code from the internet in the mql icons may not work. The code needs to follow the same standards that the code generated by the strategy builder.


Top
 Profile  
 
 Post subject: Re: One trade per bar!
PostPosted: Thu Aug 07, 2014 3:47 pm 
Offline

Joined: Mon Jul 07, 2014 5:01 pm
Posts: 4
Ok. Attached you can find the file with the EA that I want to develop. It want just to buy when the price is higher than the average line and sell when it is lower than that line. The SL may to be the max/min of the previous candle. The best it will be to find a way that allow to choise to trade once per bar or just allow one trade per direction per bar. Thank you very much for your help


Attachments:
media 5 buy and sell.mol [67.25 KiB]
Downloaded 790 times
Top
 Profile  
 
 Post subject: Re: One trade per bar!
PostPosted: Thu Aug 07, 2014 9:14 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Quote:
The SL may to be the max/min of the previous candle
You cannot do dynamic stops with the current version. You need to wait for the next release in some weeks
Quote:
The best it will be to find a way that allow to choise to trade once per bar or just allow one trade per direction per bar.
In the start icon Set it to trade bars and max positions = 1


Top
 Profile  
 
 Post subject: Re: One trade per bar!
PostPosted: Fri Aug 08, 2014 5:29 am 
Offline

Joined: Mon Jul 07, 2014 5:01 pm
Posts: 4
ok I will wait for the SL :) , but about the second sentence I cannot set trade with complete bar. The EA will not work correctly. How can I modify the mql code to do it?


Top
 Profile  
 
 Post subject: Re: One trade per bar!
PostPosted: Fri Aug 08, 2014 8:13 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
does it mean do you want to trade every tick? if that is the case you really need some custom coding. The link to the code you posted seem to have the right code but You cannot add it with the mql icon. Adding that code is a bit cumbersome since it has to go in several places.


Top
 Profile  
 
 Post subject: Re: One trade per bar!
PostPosted: Sun Aug 10, 2014 6:34 pm 
Offline

Joined: Mon Jul 07, 2014 5:01 pm
Posts: 4
Yes I need trading on every tick. where Can I copy this code in metaeditor? :?: Thanks


Top
 Profile  
 
 Post subject: Re: One trade per bar!
PostPosted: Mon Aug 11, 2014 10:34 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Are you aware that using the 0 position you get many false signals trading ticks? for example you have many green bars on position zero. The bar 0 changes as it receives ticks so it can be green one second and then turn to red.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009