Download MetaTrader 5
To add comments, please log in or register
Publish your article. We will translate it into other languages!
Andy
11
Andy 2014.06.30 21:08 
Hi there,

I have the following problem with my EA:

It opens a trade when trade signal is hit (lets say 'long'), when that trade is finished (TP or Sl) it waits until signal turns to short and then opens a short position. It SHOULD keep on trading as long as the signal is valid, although there should only be one trade open at time of course. So i would be able to profit from the whole trend, and not only once...

Does anyone have an idea if / how this is possible???

Many many thanks :)
whroeder1
13612
whroeder1 2014.07.01 11:23  
2701ag: Does anyone have an idea if / how this is possible???
  1. You code it so it does it.
  2. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
Alain Verleyen
Moderator
28564
Alain Verleyen 2014.07.01 14:00  
2701ag:
Hi there,

I have the following problem with my EA:

It opens a trade when trade signal is hit (lets say 'long'), when that trade is finished (TP or Sl) it waits until signal turns to short and then opens a short position. It SHOULD keep on trading as long as the signal is valid, although there should only be one trade open at time of course. So i would be able to profit from the whole trend, and not only once...

Does anyone have an idea if / how this is possible???

Many many thanks :)
Don't set a TP and wait reverse signal.
Ian Venner
2583
Ian Venner 2014.07.01 15:47  
When you open a trade hold the ticket number in a static variable, check that ticket number is still open using OrderSelect() SelectByTicket. If it is closed, and if signal is still long open another one.
qjol
3243
qjol 2014.07.01 15:57  
SDC:

When you open a trade hold the ticket number in a variable,


in addition:

if i may, use globals in case you have/must restart the EA/computer/terminal

SDC:
if it is not open it must have been closed, so if signal is still long open another one.

in addition:

you can check OrdersHistoryTotal too

Could EA Really Live By Order_History Alone? - MQL4 forum

Ian Venner
2583
Ian Venner 2014.07.01 16:08  
qjol:

in addition:

if i may, use globals in case you have/must restart the EA/computer/terminal


Yes or you can write a recovery function to run from OnInit(). My own preferred method is to use local static vars and a recovery function because it goes faster in strategy tester.

Andy
11
Andy 2014.07.01 19:35  
Thanks so far, i will try this, do my testing and see how far i will get :) Thank you!!
/
To add comments, please log in or register