Download MetaTrader 5

My EA should continue trading as long as signal exists, help needed!!!

To add comments, please log in or register
Andy
11
Andy  
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
14781
whroeder1  
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
31185
Alain Verleyen  
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
2584
Ian Venner  
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  
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
2584
Ian Venner  
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  
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