I'm new to c++ & MQL4 and am trying to create some basic stuff so that I can maybe start building some serious EA's 6 months to a year from now.
I am working on making a simple EA that closes an open order after three positive ticks have occoured.
The way that my EA works (or atleast I'd like to work) is that I place a buy order beforehand & upon loading the EA onto a EURUSD D1 chart, its stores the value of Close[0] into memory and when initial Close[0] + 3 pips occours I want it to close the open order.
I'm noticing however that it is not exactly doing that. It is closing orders at times other than when initial Close[0] + 3pips is true.
Here is a copy of the code so far:
I've kinda hit a brick wall here as to why I can't get it to close orders exactly when the initial Close[0] amount + 3 pips becomes true. Any ideas?
I am working on making a simple EA that closes an open order after three positive ticks have occoured.
The way that my EA works (or atleast I'd like to work) is that I place a buy order beforehand & upon loading the EA onto a EURUSD D1 chart, its stores the value of Close[0] into memory and when initial Close[0] + 3 pips occours I want it to close the open order.
I'm noticing however that it is not exactly doing that. It is closing orders at times other than when initial Close[0] + 3pips is true.
Here is a copy of the code so far:
PHP Code
//+------------------------------------------------------------------+
//| Simple3.mq4 |
//| XTrain63 |
//| |
//+------------------------------------------------------------------+
#property copyright "XTrain63"
#property link ""
double a;
double b;
int ticket1;
int init()
{
//----
a = Close[0];
b = a + 0.0003;
if(OrderSelect(0, SELECT_BY_POS)==true)
ticket1=OrderTicket();
else
Print("OrderSelect failed error code is ",GetLastError());
//----
return(0);
}
int deinit()
{
//----
a = 0;
b = 0;
ticket1 = 0;
//----
return(0);
}
int start()
{
//----
if(Close[0] == a)
{
OrderClose(ticket1,OrderLots(),Bid,5,Violet);
}
//----
return(0);
}
//+------------------------------------------------------------------+