Hello everyone, I'm a begginer in MT programming and I have stuck at one thing. How to send a market order at the close of a bar? Indiors is calculated by me in the close and the order remains send intrabar.
Please assist
Hello everyone, I'm a begginer in MT programming and I have stuck at one thing. How to send a market order at the close of a bar? Indiors is calculated by me in the close and the order remains send intrabar.
Please assist
Well...
PHP Code: <code><span style=â€color: #000000â€> <span style=â€color: #0000BBâ€>
intBarCount</span><span style=â€color: #007700â€>;
</span><span style=â€color: #0000BBâ€>init</span><span style=â€color: #007700â€>()
</span><span style=â€color: #0000BBâ€>BarCount</span><span style=â€color: #007700â€>=</span><span style=â€color: #0000BBâ€>Bars</span><span style=â€color: #007700â€>-</span><span style=â€color: #0000BBâ€>1</span><span style=â€color: #007700â€>;
</span><span style=â€color: #0000BBâ€>Beginning </span><span style=â€color: #007700â€>()
if(</span><span style=â€color: #0000BBâ€>BarCount</span><span style=â€color: #007700â€>!=</span><span style=â€color: #0000BBâ€>Bars</span><span style=â€color: #007700â€>)</span><span style=â€color: #0000BBâ€>OrderSend</span><span style=â€color: #007700â€>(...);
</span><span style=â€color: #0000BBâ€></span> </span> </code>
Basically, the EA will put trades in the open of the new bar.
Another option is:
PHP Code: <code><span style=â€color: #000000â€> <span style=â€color: #0000BBâ€>
intTimeCount</span><span style=â€color: #007700â€>;
</span><span style=â€color: #0000BBâ€>start</span><span style=â€color: #007700â€>()
</span><span style=â€color: #0000BBâ€>TimeCount</span><span style=â€color: #007700â€>=</span><span style=â€color: #0000BBâ€>Period</span><span style=â€color: #007700â€>();
</span><span style=â€color: #0000BBâ€>datetimeBarEnd</span><span style=â€color: #007700â€>=</span><span style=â€color: #0000BBâ€>Timing </span><span style=â€color: #007700â€>#91;</span><span style=â€color: #0000BBâ€>0</span><span style=â€color: #007700â€>#93; (</span><span style=â€color: #0000BBâ€>TimeCount</span><span style=â€color: #007700â€>*</span><span style=â€color: #0000BBâ€>60</span><span style=â€color: #007700â€>);
</span><span style=â€color: #0000BBâ€>intSecondsToBarEnd</span><span style=â€color: #007700â€>=</span><span style=â€color: #0000BBâ€>BarEnd</span><span style=â€color: #007700â€>-</span><span style=â€color: #0000BBâ€>TimeCurrent</span><span style=â€color: #007700â€>();
if(</span><span style=â€color: #0000BBâ€>SecondsToBarEnd</span><span style=â€color: #007700â€>lt;=</span><span style=â€color: #0000BBâ€>5</span><span style=â€color: #007700â€>)</span><span style=â€color: #0000BBâ€>OrderSend</span><span style=â€color: #007700â€>(...)
</span><span style=â€color: #0000BBâ€></span> </span> </code> This piece of code puts an order when there is less than 5 seconds left in a bar.
Wish I could get some help over. I'm only a trader who would like to get help as I've hunting for it because a while ago.
I currently looking to get an script or an EA where it could open my trades at the following opening candle or the end of current candles.
I found difficulties to start the trade exactly at the opens of their new candles although I'm currently using hotkey buy / sell scripts. It always been pips.
So wish could get a little hand out of here.
mph, I made a script with Ronald's code but it isn't opening the order on the start of the bar yetOriginally Posted by ;
Ronald, will you examine the code and fix what is wrong?
Thank you
PHP Code: <code><span style=â€color: #000000â€> <span style=â€color: #0000BBâ€>intBarCount</span><span style=â€color: #007700â€>;
</span><span style=â€color: #0000BBâ€>intinit</span><span style=â€color: #007700â€>()
</span><span style=â€color: #0000BBâ€>BarCount</span><span style=â€color: #007700â€>=</span><span style=â€color: #0000BBâ€>Bars</span><span style=â€color: #007700â€>-</span><span style=â€color: #0000BBâ€>1</span><span style=â€color: #007700â€>;
return(</span><span style=â€color: #0000BBâ€>0</span><span style=â€color: #007700â€>);
</span><span style=â€color: #0000BBâ€>intstart</span><span style=â€color: #007700â€>()
if(</span><span style=â€color: #0000BBâ€>BarCount</span><span style=â€color: #007700â€>! =</span><span style=â€color: #0000BBâ€>Bars</span><span style=â€color: #007700â€>)</span><span style=â€color: #0000BBâ€>OrderSend</span><span style=â€color: #007700â€>(</span><span style=â€color: #0000BBâ€>Symbol</span><span style=â€color: #007700â€>(),</span><span style=â€color: #0000BBâ€>OP_BUY</span><span style=â€color: #007700â€>,</span><span style=â€color: #0000BBâ€>0.1</span><span style=â€color: #007700â€>,</span><span style=â€color: #0000BBâ€>Ask</span><span style=â€color: #007700â€>,</span><span style=â€color: #0000BBâ€>3</span><span style=â€color: #007700â€>,</span><span style=â€color: #0000BBâ€>0</span><span style=â€color: #007700â€>,</span><span style=â€color: #0000BBâ€>0</span><span style=â€color: #007700â€>,</span><span style=â€color: #DD0000â€>â€BuyOrderâ€</span><span style=â€color: #007700â€>,</span><span style=â€color: #0000BBâ€>255</span><span style=â€color: #007700â€>,</span><span style=â€color: #0000BBâ€>0</span><span style=â€color: #007700â€>,</span><span style=â€color: #0000BBâ€>Blue</span><span style=â€color: #007700â€>);
</span><span style=â€color: #0000BBâ€></span> </span> </code> https://www.nigeriaforextrading.com/...5723409598.ex4
I will test this out the following week because tonight will going to market close.
Particularly, I think what I needed is juz an EA whereby it could start trades in the end of the bar / open of the bar, then I can attach it when I desire, and juz dis-attach it as it has already open the transactions. It is the best if a script is to do that. However an EA with above purpose is adequate for me as I just want to start transactions in the most precise accurate value of the bar.
Notice: Can post some charts whereby it did not open in the opening of bars? Can it involving disperse stuff?
EX4 documents are useless to me.Originally Posted by ;
But if it is a script, it won't work because scripts run just on the tick for which they were enabled.
It Has to Be an EA. And make sure that after the OrderSend work, you place BarCount = Bars. This way, the EA understands the transaction was placed by it.
Sorry Ronald, if had become the file. So it would not function as a script for mphpopular. I'll try it in my EA.
Thank you, enjoy
Dan
Mine to get one for me? As I really dunno the way to writes the EA code outside....Originally Posted by ;
Juz wish to have one... But plz do ignore me whether it is troublesome. Cause I know making an EA requires a lot of time...
Ronald, I left EA's with both codes and wont work. That the expresion BarCount! = Bars is always true, BarCount variable is different than Bars variable because we've got BarCount = Bars - 1 at the init() function, so it puts an order at each tick.Originally Posted by ;
Can you look at my attached EA and see what's wrong, perhaps you can make it work.
Thanks, Dan
https://www.nigeriaforextrading.com/...6773845439.mq4