Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack (2) Thread Tools Display Modes
  #981 (permalink)  
Old 02-13-2008, 01:45 AM
Dave137 Dave137 is offline
Senior Member
 
Join Date: Oct 2007
Posts: 165
Dave137 is on a distinguished road
Question Adding & Deleting Indicators

Can a code be written in an EA to add or delete an indicator to the trading platform???

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #982 (permalink)  
Old 02-17-2008, 01:33 PM
metastock metastock is offline
Senior Member
 
Join Date: Jan 2006
Posts: 125
metastock is on a distinguished road
I have a big trouble on management of orders....
My simple EA entry at X:59......but i have multiple entry on the same cross. My question: It's possible to check orders time entry and to compare with new order?
I want entry at x:59 only with 1 order for cross....

Someone can help me?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #983 (permalink)  
Old 02-18-2008, 06:18 PM
metastock metastock is offline
Senior Member
 
Join Date: Jan 2006
Posts: 125
metastock is on a distinguished road
Quote:
Originally Posted by metastock View Post
I have a big trouble on management of orders....
My simple EA entry at X:59......but i have multiple entry on the same cross. My question: It's possible to check orders time entry and to compare with new order?
I want entry at x:59 only with 1 order for cross....

Someone can help me?
This is my solution, I hope this can help someone......

//+------------------------------------------------------------------+
//| Signal Begin(Entry) |
//+------------------------------------------------------------------+

if (Buy1_1 < Buy1_2 && Minute()>58 && check_buy==0) Order = SIGNAL_BUY;
if (Sell1_1 > Sell1_2 && Minute()>58 && check_sell==0) Order = SIGNAL_SELL;
if (Minute()==00) {check_buy=0;}
if (Minute()==00) {check_sell=0;}

//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+

//Buy
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
//if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (StopLossMode) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
if (TakeProfitMode) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;
check_buy=1;
Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy %W(#" + Magic_Number + ")", Magic_Number, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
// }
}

//Sell
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
//if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (StopLossMode) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
if (TakeProfitMode) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;
check_sell=1;
Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell %W(#" + Magic_Number + ")", Magic_Number, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else {
Print("Error opening SELL order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
//}
}

if (!EachTickMode) BarCount = Bars;

return(0);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #984 (permalink)  
Old 02-24-2008, 12:18 AM
Big Be Big Be is offline
Member
 
Join Date: Oct 2006
Posts: 67
Big Be is on a distinguished road
To Metastock

I can't tell what causes check_buy to be True.
To limit to one order open, you can use, before entry:
if (OrdersTotal()==0)

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #985 (permalink)  
Old 02-24-2008, 12:19 AM
Big Be Big Be is offline
Member
 
Join Date: Oct 2006
Posts: 67
Big Be is on a distinguished road
Coding Knowledge Questions

WHEN do you want to use a STATIC variable - what problems can it solve?

WHEN do you want to put something in the INIT() section - what problems does it solve?

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #986 (permalink)  
Old 02-24-2008, 04:47 AM
longng12 longng12 is offline
Junior Member
 
Join Date: Feb 2008
Posts: 3
longng12 is on a distinguished road
not sure if this has been asked befor, but is there a way to draw a line at the current time +1 hr befor and after at a certain price in an EA?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #987 (permalink)  
Old 02-24-2008, 08:58 AM
ralph.ronnquist's Avatar
ralph.ronnquist ralph.ronnquist is offline
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by Big Be View Post
WHEN do you want to use a STATIC variable - what problems can it solve?

WHEN do you want to put something in the INIT() section - what problems does it solve?

Big Be
So, an answer to this, is that instead of, or in addition to, the explanations in the MQ4 documentation?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #988 (permalink)  
Old 02-24-2008, 03:32 PM
SimonF SimonF is offline
Junior Member
 
Join Date: Jan 2008
Posts: 24
SimonF is on a distinguished road
How to keep track of multiple orders?

I'm currently making an EA that only has 1 open trade at a time.
I have alot of variables to keep track of what is happening during this trade.
If I had more open trades at the same time I thought I could use arrays for these variables with the ticket number as key. But as I understand it the keys has to be 0,1,2,3 etc right? So this wouldn't be possible.

Instead of that I could have a multidimension array like this, I hope you understand my javascript/php like description.
barsSinceOpen = array(
0 => array(0 => 123123, 1 => 63)
1 => array(0 => 552352, 1 => 5)
);
0 in second dimension would be ticket number, and 1 would be amount of bars since the trade was open.
barSinceOpen is just an example.. I know I could calculate this one out for each trade every time I want, but that's not the point. I have ALOT of things I keep track of for a trade.

And to select the correct order I would have to iterate over the array and select the 2nd level array with correct ticket.

Do you think this is a good idea? How would you do it?
__________________
boo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #989 (permalink)  
Old 02-24-2008, 03:55 PM
SimonF SimonF is offline
Junior Member
 
Join Date: Jan 2008
Posts: 24
SimonF is on a distinguished road
Another question

It seems like when I do a orderModify() to set a take profit for example.
And then before next tick or we could aswell say before I select the same order again I do another orderModify() to set a stop loss. And in that I use OrderTakeProfit() so it doesn't remove the take profit. But, It removes the take profit anyway.
Do I need to wait for next tick or to select the order again for the OrderTakeProfit() to return my new take profit?
__________________
boo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #990 (permalink)  
Old 02-24-2008, 04:46 PM
Big Be Big Be is offline
Member
 
Join Date: Oct 2006
Posts: 67
Big Be is on a distinguished road
re: Coding Knowledge Questions

Quote:
Originally Posted by Big Be View Post
WHEN do you want to use a STATIC variable - what problems can it solve?

WHEN do you want to put something in the INIT() section - what problems does it solve?

Big Be


Quote:
Originally Posted by ralph.ronnquist View Post
So, an answer to this, is that instead of, or in addition to, the explanations in the MQ4 documentation?
That would be in addition.
(I always try to do my homework first.)
Maybe I need explanation and example(s).

Big Be

Last edited by Big Be : 02-24-2008 at 05:08 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
Posted By For Type Date
OzFx System:) - Page 639 This thread Refback 06-21-2008 09:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 11:46 AM


All times are GMT. The time now is 08:12 AM.