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

One trade per bar!
http://www.molanis.com/forum/viewtopic.php?f=3&t=6059
Page 1 of 1

Author:  stenath [ Tue Aug 05, 2014 3:35 pm ]
Post subject:  One trade per bar!

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

Author:  admin [ Wed Aug 06, 2014 8:32 pm ]
Post subject:  Re: One trade per bar!

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.

Author:  stenath [ Thu Aug 07, 2014 3:47 pm ]
Post subject:  Re: One trade per bar!

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 829 times

Author:  molanisfx [ Thu Aug 07, 2014 9:14 pm ]
Post subject:  Re: One trade per bar!

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

Author:  stenath [ Fri Aug 08, 2014 5:29 am ]
Post subject:  Re: One trade per bar!

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?

Author:  molanisfx [ Fri Aug 08, 2014 8:13 am ]
Post subject:  Re: One trade per bar!

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.

Author:  stenath [ Sun Aug 10, 2014 6:34 pm ]
Post subject:  Re: One trade per bar!

Yes I need trading on every tick. where Can I copy this code in metaeditor? :?: Thanks

Author:  molanisfx [ Mon Aug 11, 2014 10:34 am ]
Post subject:  Re: One trade per bar!

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.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/