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
Error help
Using the default zigzag indicator, I am trying to make trendlines using the last 10 high and low, so i can get better SR levels
But I am not able to set the limit to the number of lines being formed
Help me please
// begin custom code
if (LowMapBuffer[shift]!=0)
{
tm = iTime(Symbol(),0,shift);
tmL = TimeDay(tm) + "-" + TimeMonth(tm) + "-" + TimeYear(tm) + " - " + TimeHour(tm) + "-" + TimeMinute(tm);
prL = iLow(Symbol(),0,shift);
LDraw(tm, prL, tmL, Red, shift);
}
if (HighMapBuffer[shift]!=0)
{
tm = iTime(Symbol(),0,shift);
tmL = TimeDay(tm) + "-" + TimeMonth(tm) + "-" + TimeYear(tm) + " - " + TimeHour(tm) + "-" + TimeMinute(tm);
prL = iHigh(Symbol(),0,shift);
LDraw(tm, prL, tmL, Green, shift);
}
// end custom code
/+------------------------------------------------------------------+
void LDraw(datetime tmi, double pr, string tmli, color cl, double S)
{
ObjectCreate("AZ"+DoubleToStr(S,0), OBJ_HLINE, 0, tmi, pr);
ObjectSet("AZ"+DoubleToStr(S,0),OBJPROP_COLOR,cl);
ObjectSetText("AZ"+DoubleToStr(S,0),tmli,12,"Arial",Red);
}
Please let me know how to make following EA
Following action is the one I want to know in EA.
If there is executed order within last 10 bar, no new order is opened.
you will need to create a counter that is incremented every time a new bar is created. you may also want to account for if the time frame changes as well.
// begin custom code
if (LowMapBuffer[shift]!=0)
{
tm = iTime(Symbol(),0,shift);
tmL = TimeDay(tm) + "-" + TimeMonth(tm) + "-" + TimeYear(tm) + " - " + TimeHour(tm) + "-" + TimeMinute(tm);
prL = iLow(Symbol(),0,shift);
LDraw(tm, prL, tmL, Red, shift);
}
if (HighMapBuffer[shift]!=0)
{
tm = iTime(Symbol(),0,shift);
tmL = TimeDay(tm) + "-" + TimeMonth(tm) + "-" + TimeYear(tm) + " - " + TimeHour(tm) + "-" + TimeMinute(tm);
prL = iHigh(Symbol(),0,shift);
LDraw(tm, prL, tmL, Green, shift);
}
// end custom code
/+------------------------------------------------------------------+
void LDraw(datetime tmi, double pr, string tmli, color cl, double S)
{
ObjectCreate("AZ"+DoubleToStr(S,0), OBJ_HLINE, 0, tmi, pr);
ObjectSet("AZ"+DoubleToStr(S,0),OBJPROP_COLOR,cl);
ObjectSetText("AZ"+DoubleToStr(S,0),tmli,12,"Arial",Red);
}many edits later! look... I've cobbled together something that may work but at least should give you some ideas and possible ways to implement. looking at others code and attempting to not interfere much is h.a.r.d and causes suggestions to look a bit crazy!
Really hope what done helps in some way
not familiar with zz code. but why not after the main zz for loop has ended do: have your 'own' for loop. eg,
#define MAXLINES 10
int iHighLinesDrawn=0,iLowLinesDrawn=0;
for(shift=0;shift<maxbars;shift++)
{
}//for(shift=0;shift<maxbars;shift++)
/+------------------------------------------------------------------+
void LDraw(datetime tmi, double pr, string tmli, color cl, double S)
{
}idea is to let generic zz code do all it's stuff and only then, when it's about to return to terminal, you put above. The indicator buffers are all loaded and your code just does whatever processing it wants using these buffers and each time you only go back the number of bars needed UNTIL both hi and lo have MAXLINES drawn.
is idea , maybe get you on right track?
regards
Order Close by Magic Number
I am attempting to close one of three open orders by using the magic number that I assigned when the order was opened.
if (OrderMagicNumber() == 11111 && OrderOpenPrice() + (250 * Point) <= Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID),3, Red );
the above lines makes a reference to the trade with the magic numbe "11111", but using the order close function, closes all open trades based on the criteria of the magic number trade. How can I only close the order with the magic number that I have assigned?
how to detect the order is belong to which currency?
Hi i am new to mql,
I am trying to create an EA to trade automatic. The EA must only can have only one trade on each currency. which means that if i attach the EA to the chart, the EA must detect is there an Real Order running OR any pending order available for the currency that attached.
If there is any Real Order or Pending order, it must be discard and wait for no real order or pending order in the terminal..
The problem is..... even when i have a real trade order OR pending ticket in terminal, the code execute what i wanted, but it cannot detect whether it is same to the currency which attach with this EA or not.
below is my code,anyone who can help me, pls advise....
/////// My code ////////
//+------------------------------------------------------------------+
//| test_order.mq4 |
//| xxx |
//| / MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "xxx"
#property link "xxx"
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
Alert("EA attached"); //Test
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
string Symb=Symbol();
int total=OrdersTotal();
if (total>0){
Alert("Got trade/pending ticket in interminal..."); //Test
if (OrderSymbol()!= Symb){
Alert("Got trade/pending ticket in terminal, but not same currency"); //Test
}else{
Alert("Got trade/pending ticket in terminal which is same to the currency attach with this EA"); //Test
}
}else{
Alert("Got trade/pending ticket in interminal..."); //Test
}
//----
return(0);
}
//+------------------------------------------------------------------+
Looking for Code
Hello Everyone,
Can someone share some code on how to draw an OHLC bar on a sub window?
Thanks
EK
Open a pending order straddle at a given time
Dear problem solvers
I am totally new to MQL4 - learning it from 2 books.
My partner and I have an EA we wish to develop. We have tried 4 so called expert programmers all to no avail.
I am able to wrire an EA to place a pending order at Close[1] so the next step is to have the program open a OP_BUYSTOP and an OP_SELLSTOP
at a prescribed GMT or Server time equivalent
I must be missing the Time Function capabilities somewhere
HH = Hour()
MM = Minute()
int Currenttime = HH*100 + MM
if CurrentTime = StraddleOpenTime
etc
I have included where my EA is at ATM - don't laugh please
Trade entry based on Price
I am trying to figure out how to determine the entry of a trade based on the current price. I want to enter a trade when the last 2 digits read a certain price. Any help would be greatly appreciated.