You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Description:
1) EA will open ONE ORDER ONLY with 1 lot OP_BUY at marker price with TP = 20pips.
2) Once TP is hit, EA WILL THEN ONLY open new pending order OP_BUYLIMIT at 20 pips below current market price with TP = 20pips.
3) And this process will continue until user deactivate this EA.
4) Can the ALL involve orders (OP_BUY & OP_BUYLIMIT use the SAME magic number? If can, please help to insert this same magic number criteria into the correct source code :) )
Problems face:
1) The OP_BUY order below code is open many times by EA *** (pls help to make EA open ONLY one OP_BUY, until this OP_BUY is closed)
2) The OP_BUYLIMIT is also opened many times (instead I want it to be opened only one time)
=============================================================================================
//// Below is the EA source code i built, of course, with above 2 problems face ... (i think because i am a newbies in mql4...)
extern double Lot = 1;
extern int TP = 20;
extern int Slippages = 3;
extern int Magic_Buy = 1000;
int start()
{
//// EA opens one and only one order (only until this order is closed at TP, then it will open another OP_BUYLIMIT)
{OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippages, 0, Bid+TP*Point, "Buy1", Magic_Buy, NULL, CLR_NONE);}
//// Once TP is reached, EA will be informed through Magic_Buy at history trade
for(int i=1;i>=0;i--)
{OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if (OrderMagicNumber()== Magic_Buy)
OrderSend(Symbol(), OP_BUYLIMIT, Lot, Ask-20*Point, S, 0, Bid, "Buy2", Magic_Buy, NULL, CLR_NONE);
}
return(i);}
//// Then the above process (open 1 order & order close at TP... open 1 order & order closed at TP ...) is repeated unlimited time until user manually deactivate EA
================================================================================