hello, i am a newbie to programming of all types, i have been learning MQL4 for a couple weeks now because i have really wanted to program this system of mine into an EA, i am making some headway but i am stuck in one spot in particular. first i reccomend looking at the picture i posted... the green box is a modified panca eagle indicator
the way i am trading this is pretty basic, each time price leaves the box i open a position, and set SL and TP, what i want to program is that when price leaves the box and then reenters teh box i dont want a position to be able to be opened again untill price goes below the red line.
so: when price leaves the box and a position is opened, then it reenters the box, unless it goes below the red line, i dont want a position to be opened the next time it leaves the box. [and for this lets just worry about long trades]
so, in effect, you could call the red line a "reset line"
and remember...each dad a new box is drawn, so the values and size of the box are different, so if the top of the box is 1.4253 today it will be something different tomorrow.
Also,
i am going to post my code , for the EA which i have written so far, i think you will find i have not written it in a normal way in some parts, but the tutorial i read on mql4 was quite long and wordy and i found some parts stuck with me more then others, so until i complete reading it a second time this will have to do.
and sorry if i repeated my self a couple (or more) times, i drank abit toomuch tonight.
any hints, tips, tricks, techniques or wisdom is welcome.
- nikolaou
//+------------------------------------------------------------------+
//| optimized If Else EA.mq4 |
//| Alex Nikolaou Copyright 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Alex Nikolaou Copyright 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//--------------------------------------------------------------------
//--------------------------------------------------------------------
extern double levelhigh = 1.5000; // preset high alert level
extern double levellow = 1.4990; // preset low alert level
//--------------------------------------------------------------------
int start ()
{
for(double i=0;OrdersTotal()>i // keeps max simultaneous orders at 1
{
break; // keeps max simultaneous orders at 1
}
//-------------------------------------------------------------------
double price=Bid; // current Bid
if ( price > levelhigh) // Condition
{
OrderSend(Symbol(),OP_BUY,0.1,Ask, //Opens long orders
1,Bid-14*Point,Bid+15*Point); //Continued from previous line
Alert(GetLastError()); // Last Error Alert
}
else // Else operator
{
if (price < levellow) //Condition
{
OrderSend(Symbol(),OP_SELL,0.1,Bid, //Opens Short orders
1,Bid-14*Point,Bid+16*Point); //Continued from previous line
Alert(GetLastError()); //Last Error Alert
}
}
return; //Return operator
}
//--------------------------------------------------------------------
the way i am trading this is pretty basic, each time price leaves the box i open a position, and set SL and TP, what i want to program is that when price leaves the box and then reenters teh box i dont want a position to be able to be opened again untill price goes below the red line.
so: when price leaves the box and a position is opened, then it reenters the box, unless it goes below the red line, i dont want a position to be opened the next time it leaves the box. [and for this lets just worry about long trades]
so, in effect, you could call the red line a "reset line"
and remember...each dad a new box is drawn, so the values and size of the box are different, so if the top of the box is 1.4253 today it will be something different tomorrow.
Also,
i am going to post my code , for the EA which i have written so far, i think you will find i have not written it in a normal way in some parts, but the tutorial i read on mql4 was quite long and wordy and i found some parts stuck with me more then others, so until i complete reading it a second time this will have to do.
and sorry if i repeated my self a couple (or more) times, i drank abit toomuch tonight.
any hints, tips, tricks, techniques or wisdom is welcome.
- nikolaou
//+------------------------------------------------------------------+
//| optimized If Else EA.mq4 |
//| Alex Nikolaou Copyright 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Alex Nikolaou Copyright 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//--------------------------------------------------------------------
//--------------------------------------------------------------------
extern double levelhigh = 1.5000; // preset high alert level
extern double levellow = 1.4990; // preset low alert level
//--------------------------------------------------------------------
int start ()
{
for(double i=0;OrdersTotal()>i // keeps max simultaneous orders at 1
{
break; // keeps max simultaneous orders at 1
}
//-------------------------------------------------------------------
double price=Bid; // current Bid
if ( price > levelhigh) // Condition
{
OrderSend(Symbol(),OP_BUY,0.1,Ask, //Opens long orders
1,Bid-14*Point,Bid+15*Point); //Continued from previous line
Alert(GetLastError()); // Last Error Alert
}
else // Else operator
{
if (price < levellow) //Condition
{
OrderSend(Symbol(),OP_SELL,0.1,Bid, //Opens Short orders
1,Bid-14*Point,Bid+16*Point); //Continued from previous line
Alert(GetLastError()); //Last Error Alert
}
}
return; //Return operator
}
//--------------------------------------------------------------------