How to code? - page 236

 

Problem with my ea placing a trade on each bar

Hi there,

Firstly I just want to to say that I love this forum. This is my first post as I didn't want to unnecessarily waste anyones time if I could help it. I have made an expert advisor which is supposed to execute on each bar. I have joined fxprimus recently. I know that they are an ecn stp 5 digit broker so I have adjusted my code to using the OrderSend function with 0,0, for the stoploss and take profit and then using the OrderModify function to place the stop and take profit. Also I have placed a timer function to execute only once per bar. However on fxprimus each time I load my ea it places a trade on the first bar, modifys the order perfectly and will then handle the take profit and stoploss functions fine but it will not place any more trades when the next bar forms. I even took out the indicator and made it just place a trade on each bar but nothing seems to work. I have taken out the timer which is supposed to prevent the program from placing an order on every tick but it sill just places the one trade.

I have gone through a few versions of placing the trades taking profit and tried out about four timer functions. I've been at this for over a week now and the support at fxprimus do not offer technical assistance but have said that they have no limitations on trading. I was sure I would eventually come accros a thread somewhere where somebody else would have had the same problem as me but nothing! Is there anybody out there with a similar experience? By the way I've nothing against the broker in fact the trades I have done with them were executed at lightening speed.

regards, Donal

 

I'm a totally newbie to this forum and started on Forex 6 Weeks ago. Must say I take my hat off to you guys. Basically everything I learned so far came from past posts on this forum. I want to thank one and all. This is great but....I found a indicator somewhere that i seriously need a minor change to. it's chart signal for MT4 (arrow) that i need a sound alert put to. Please can anybody help? I attached it.

please let me know. anybody. should only take a minute or so (I guess)..

Files:
entry.mq4  4 kb
 

Donal - Sounds like the problem is with your 'timer' function. Did you try the EA on a different broker to rule the broker out?

Not sure why you've overcomplicated things with a timer function.

Just count the orders. Make sure there's only one open at a time. Then when order count is zero just check that no order has been closed (OrderHistory()) on the current bar (OrderCloseTime() >= Time[0]). It's straightforward really. My guess is you're over complicating it and can't see the wood for the trees.

Hope that helps.

Lux

 

Thanks for the reply Lux

Hi Lux,

thanks for your reply, I'm afraid I'm new to programming expert advisors, so I'm not too sure what you mean. What I'm trying to do is have multiple trades on at the same time both up and down on the same currency, with either an up or down trade being executed at the open of each bar on a 5 minute timeframe. I'll then let minimum profit stops, take profit, breakeven stops and a close all trades function if an average of x points reached function handle the trades.

I know its probably alot for me to take on at this early stage of my programming career (this is my first ea!) But I have my messy code working perfectly on the strategy tester. Big difference when it comes to the live account. (fxprimus, it also being my first and only broker)

I'm from sunny Ireland and fxprimus are in Mauritius so there is no hedging issues and as for the trades that I do get placed the other functions I mentioned seem to work. So do you still think the timer might be an issue? I know that when I take the timer off on the strategy tester it'll place a million trades on per bar, yet when I take the timer off on the live account it still just places one trade on the initial bar and then nothing after that!

any thoughts on this would be appreciated, thanks Donal

 

Alert TF

Hello, could anyone advise me how to change the xpMA alert, which would show all the TF, then pointed to alert all TF. Thank you

download link: 4shared.com - online file sharing and storage - download xpMA.mq4

 
 

Friday Close Time - Help!!!

Hello people,

Can anyone help me? I want my EA to close out all trades at a particular time on fridays (so that the trade don't proceed to the next week). I think the code is called 'friday close', any help please?

 

How can I geht Ask[1]?

Hi,

I no it is not right to write Ask[1] but how can I get the Ask-Price from the last tick??

Thank you!

 
sunshineh:
Hi,

I no it is not right to write Ask[1] but how can I get the Ask-Price from the last tick??

Thank you!

Sincerly I do not understand what you mean!!!

You can get the:

  • close price ---> Close[1]
  • open price ---> Open[1]
  • high price ---> High[1]
  • low price ---> Low[1]

for the last bar.

Hope this help!!!

 
sunshineh:
Hi,

I no it is not right to write Ask[1] but how can I get the Ask-Price from the last tick??

Thank you!

You can't. You have to store it as a variable and access it.

int last_ask;

int main() {

... your code ...

last_ask = Ask;

}

Reason: