Hello Folks.
I'm just experimenting with programming.
I have a script which works if I run it manually. It's placing a pending order on the close of the previous candle.
To get this thing automated I need some modification, but I'm really stuck at this point.
These are the important points (which I can think of so far):
I'm just experimenting with programming.
I have a script which works if I run it manually. It's placing a pending order on the close of the previous candle.
To get this thing automated I need some modification, but I'm really stuck at this point.
These are the important points (which I can think of so far):
- How do I tell the EA that it should plece only one (1) pending order of each type before the next candle will open (In case a pending order becomes active and SL/TP is hit)?
- If the price is not right (too close to open a pending order), how do I tell the EA to continue trying to open a position until the price is right or the next candle opens (so the values have changed anyways).
- How do I calculate the time for the expiration of a pending order? So in case I'm on the M5 I want all pending orders closed just before the new candle opens.
- How Do I tell the EA to close all open orders before (or just when) the next candle opens).
And just upfront in case anybody is asking: This it not a strategy. I'm just experimenting with code and would like to see my own EA in the Backtest mode. Results are not important for me at this time, but working with the code is.
Thanks.
MikeFT
Inserted Code
#include <stdlib.mqh>
#include <WinUser32.mqh>
#property show_inputs
#property show_confirm
extern double Lots = 0.10;
extern double takeprofit = 300;
extern double stoploss = 200;
extern datetime expiration =D'31.12.2010';
double PrevClose;
int start()
{
PrevClose = iClose(NULL,PERIOD_M5,1);
OrderSend(Symbol(),OP_SELLSTOP,Lots,PrevClose,3,PrevClose+stoploss*Point,PrevClose-takeprofit*Point,"Comment",0,expiration,CLR_NONE);
OrderSend(Symbol(),OP_BUYSTOP,Lots,PrevClose,3,PrevClose+stoploss*Point,PrevClose-takeprofit*Point,"Comment",0,expiration,CLR_NONE);
}