Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
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 Thread Tools Display Modes
  #511 (permalink)  
Old 11-27-2007, 08:10 AM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 502
Michel is on a distinguished road
You can use this to count only those which are opened today:
PHP Code:
if(OrderType() == OP_BUY && OrderOpenTime() >= iTime(NULLPERIOD_D10)) buys++; 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #512 (permalink)  
Old 11-29-2007, 03:36 AM
teldon teldon is offline
Senior Member
 
Join Date: Nov 2006
Posts: 222
teldon is on a distinguished road
need quick help

i have these codes below.....
can somebody please check to see if they follow this rule...

If no trades on the chart then with signal it opens 1 lot.
if 1 trade already on the chart all the rest of the orders are double lot..

please verify,

total = OrdersTotal();
if(total>=2)
{
if(MA11>MA21 && MA12<MA22)
{
ticket=OrderSend(Symbol(),OP_BUY,2*Lots,Ask,5,Ask-stoploss*Point,0,0,Magic_number,0,Green);
return (0);
}
if(MA11<MA21 && MA12>MA22)
{
ticket=OrderSend(Symbol(),OP_SELL,2*Lots,Bid,5,Bid +stoploss*Point,0,0,Magic_number,0,Red);
return (0);
}
}
if(MA11>MA21 && MA12<MA22)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Ask-stoploss*Point,0,0,Magic_number,0,Green);
}
if(MA11<MA21 && MA12>MA22)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Bid+s toploss*Point,0,0,Magic_number,0,Red);
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #513 (permalink)  
Old 11-29-2007, 07:13 AM
kjhfdgjfhdghdf's Avatar
kjhfdgjfhdghdf kjhfdgjfhdghdf is offline
Senior Member
 
Join Date: Mar 2007
Posts: 663
kjhfdgjfhdghdf is on a distinguished road
Talking

Martingale?
You have no hope.....
__________________
Dont worry, bout a thing, cos every little thing, gonna be alright.
The future has not been written.
There is not fate, but what we make for ourselves.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #514 (permalink)  
Old 11-29-2007, 08:48 AM
teldon teldon is offline
Senior Member
 
Join Date: Nov 2006
Posts: 222
teldon is on a distinguished road
Quote:
Originally Posted by kjhfdgjfhdghdf View Post
Martingale?
You have no hope.....
i will keep it in mind, thx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #515 (permalink)  
Old 11-29-2007, 12:36 PM
antone antone is offline
Senior Member
 
Join Date: Oct 2006
Posts: 102
antone is on a distinguished road
i just change and added.. the red characters.. hope that helps..

Quote:
total = OrdersTotal();
if(total>=1)
{
if(MA11>MA21 && MA12<MA22)
{
ticket=OrderSend(Symbol(),OP_BUY,2*Lots,Ask,5,Ask-stoploss*Point,0,0,Magic_number,0,Green);
return (0);
}
if(MA11<MA21 && MA12>MA22)
{
ticket=OrderSend(Symbol(),OP_SELL,2*Lots,Bid,5,Bid +stoploss*Point,0,0,Magic_number,0,Red);
return (0);
}
}
if(total<1)
{
if(MA11>MA21 && MA12<MA22)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Ask-stoploss*Point,0,0,Magic_number,0,Green);
}
if(MA11<MA21 && MA12>MA22)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Bid+s toploss*Point,0,0,Magic_number,0,Red);
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #516 (permalink)  
Old 11-30-2007, 06:50 AM
Jovager Jovager is offline
Member
 
Join Date: Oct 2006
Posts: 56
Jovager is on a distinguished road
StopLoss on MAs crossing

In an EA, I have a SL=50.

How code if I want SL=50 OR crossing of 2 Ma ?

Thanks for help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #517 (permalink)  
Old 11-30-2007, 07:08 AM
Devil2000 Devil2000 is offline
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 340
Devil2000 is on a distinguished road
Try this..

Put
Code:
double ma_cross;
as a global variable.

In the start function :

Code:
double ma1=NormalizeDouble(first_ma,Digits);
double ma2=NormalizeDouble(second_ma,Digits);

if(ma1=ma2)
 {
    ma_cross=ma1;
 }

int spread=MarketInfo(Symbol(), MODE_SPREAD);

SLbuy=ma1+spread-SL*Point;
SLsell=ma1+SL*Point;
Hope this helps
__________________
Still learning..

Last edited by Devil2000 : 11-30-2007 at 07:12 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #518 (permalink)  
Old 11-30-2007, 07:52 AM
dxtrade's Avatar
dxtrade dxtrade is offline
Senior Member
 
Join Date: Jul 2007
Location: Maldives
Posts: 194
dxtrade is on a distinguished road
Close/Open trades at inversed signal

I have a small problem here:

In my EA I have a BuyCondition and Sell Condition and a close order for inversed signals. To prevent opening and closing trades inside the same bar I have the following code:
if(OneEntryPerBar==true)
{
if(CheckEntryTime==iTime(NULL,PERIOD_H1,0)) return(0); else CheckEntryTime = iTime(NULL,PERIOD_H1,0);
}

All fine. But now if he finds a sell condition during an open buy trade, he closes the buy, which is OK. But he doesn't open the sell as the above code is preventing this.

Any idea on how to make him close and open inside 1 bar... but only once per bar?

I hope I make myself understood.

Thanks
__________________
Happy Trading...

"Failure is only a temporary change in direction to set you straight for your next success."
"Winning is a habit. Unfortunately, so is losing."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

"Say what you mean, but don't say it mean!"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #519 (permalink)  
Old 12-05-2007, 01:54 AM
Hisashi Hisashi is offline
Junior Member
 
Join Date: Jun 2007
Posts: 3
Hisashi is on a distinguished road
Question Close and cancel at a certain time?

Can anyone help me with setting up EA that closes all open orders and cancels all pending order at a certain time, i.e., 5:15 a.m. UTC+1 ?
Is it also possible to specify not only the time but the date?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #520 (permalink)  
Old 12-05-2007, 04:05 AM
antone antone is offline
Senior Member
 
Join Date: Oct 2006
Posts: 102
antone is on a distinguished road
Quote:
Originally Posted by dxtrade View Post
I have a small problem here:

In my EA I have a BuyCondition and Sell Condition and a close order for inversed signals. To prevent opening and closing trades inside the same bar I have the following code:
if(OneEntryPerBar==true)
{
if(CheckEntryTime==iTime(NULL,PERIOD_H1,0)) return(0); else CheckEntryTime = iTime(NULL,PERIOD_H1,0);
}

All fine. But now if he finds a sell condition during an open buy trade, he closes the buy, which is OK. But he doesn't open the sell as the above code is preventing this.

Any idea on how to make him close and open inside 1 bar... but only once per bar?

I hope I make myself understood.

Thanks
it won't open cause of the code you use above.. until the next hour..

you can try this..

Quote:
if (OrderOpenTime() >= iTime(NULL, PERIOD_H1, 0)) order++;

if (order < 1)
{
order conditions
}
hope that helps.. not an expert.. but this code won't stop from doing it more than once..

Last edited by antone : 12-05-2007 at 04:15 AM.
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 04:22 PM


All times are GMT. The time now is 09:50 PM.