Thread: Help
View Single Post
  #6 (permalink)  
Old 12-14-2005, 12:20 PM
newdigital newdigital is online now
Administrator
 
Join Date: Sep 2005
Posts: 15,879
Blog Entries: 54
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Quote:
Originally Posted by Teres
Hallo

Thank you very much....

This i exactly what I tried to copy and compiled with my strategy...it is similar...

But could you help me construct one method like this but which start at exact time? 5:02 PM time zone New York? This it the main breakpoint...

And when you calculate by hand....it seem to be more profitable.....another way and I can learn how to construkt my own strategy.

Thanks

Regards Teres
Teres,
I studed the coding together with Codersguru lessons so may be, I did some mistake. So you must check everything that I posted below.

It should not be NY time. It should be your server's time (Metatrader's time). Just re-calculate the time acording to your Metatrader.

As I know it may be the following code in the beginning in the place where the settings are located:

Code:
extern bool UseHourTrade = True; //Use time to trade (from ... to ...)
extern int FromHourTrade = 0; // Time to start trading 
extern int ToHourTrade = 23; // Time to finish
extern int HourOpen = 7; // Exact hour to open the order
extern int MinuteOpen = 0; //exact minutes to open the order
And after that you may use the following (as example):

Code:
int start(){

for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
TrailingPositions();
}
}
if (UseHourTrade){
if (!(Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {
Comment("Not time to trade!");
return(0);
}
}
if(Bars<100){
Print("bars less than 100");
return(0);
}

if (prevCountBars != Bars && prevCountBars !=0 && !ExistPositions()) {
if(AccountFreeMargin()<(1000*Lots)){
Print("no money available. Free Margin = ", AccountFreeMargin());
return(0);
}


if ((Hour()==HourOpen && Minute()>=MinuteOpen)){
OpenBuy();
Sleep(3000);
OpenSell();
return(0);
}
}
If you want to open the order exact at the time you estimated you may change this one:

Code:
if ((Hour()==HourOpen && Minute()>=MinuteOpen))
on to that one:

Code:
if ((Hour()==HourOpen && Minute()==MinuteOpen))


But in this case you must be sure that the price is crossing the MA exact at the time. Otherwise you need to change something inside the EA also because the EA I posted above is trading when the price is crossing the MA but as I understand you need the price to be above or below MA at the time you estimated.


In the EA I posted the sell condition is the following:

Code:
//---- sell conditions
   if(Open[1]>ma && Close[1]<ma)
And buy condition:

Code:
//---- buy conditions
   if(Open[1]<ma && Close[1]>ma)
So it works on the price-ma crossing. But as I understand you need the price above or below so use just
Code:
Close [1]<ma
only for example for sell or something else (I do not know).

You also mentioned that you need for everything to be in opened bar (zero bar) because you are using D1 timeframe. In this case it may be for sell:

Code:
Open[0]<ma;
Sorry I can not help you a lot because I am studying Codersguru lessons together with everybody and may be I did mistake somewhere. I think Codersguru may check it because he is more professional with this subject.

Just try, open the EA I posted above this post and change everything. And may be it will work.

Last edited by newdigital; 12-14-2005 at 12:31 PM.
Reply With Quote