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 Thread Tools Display Modes
  #1 (permalink)  
Old 11-15-2005, 08:01 AM
newdigital newdigital is online now
Administrator
 
Join Date: Sep 2005
Posts: 15,370
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
Working Hours

I found some piece of code which I am using sometimes.

If I need to do some back/forward test in particular hours, or if I am not trading 24 hours per day I use the following code to be inserted in EA:

In the top of EA (where information about the lots, Take Profit etc are located) insert the following:

Code:
extern bool UseHourTrade = True;
extern int  FromHourTrade = 9;
extern int  ToHourTrade = 21;
After that look on the code and find the line

Code:
int start()
After this line there are some pieces of the code where something is checking (Bars, TakeProfit<10 etc).
If you see it you may insert the following code:

Code:
if (UseHourTrade){
   if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){
   Comment("Non-Trading Hours!");
   return(0);
   }
   }

For example:

Code:
int start(){
   if(Bars<100){
      Print("bars less than 100");
      return(0);
   }
   if (UseHourTrade){
   if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){
   Comment("Non-Trading Hours!");
   return(0);
   }
   }
   
   if(lStopLoss<10){
      Print("StopLoss less than 10");
      return(0);
   }
   if(lTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }
We can not do it with every EA. But in some EA we can. If I change something in the code I will mark it in the comments in the code (working hours was added by newdigital) and will re-name this EA. For example, I changed something in Ichimoku5 and I receive Ichimoku5_1. Why? If you post changed EA to the forum the other members will not be confused with the versions and will know exactly where the original version is and where is yours which you changed for yourself only.

Codersguru will correct me if I did mistake.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-15-2005, 03:55 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Thumbs up Great!

newdigital,

You are moving at the speed of the rock.

The code is 100% right. KEEP GOING MAN!

When I make changes to any code I rename it like that:
SuperTrend (This is the original)
SuperTrend_Alert (This is the new name. Added _Alert to the original name because I've added Alerts function to the original code)

I don't rename it to SuperTrend2 or SuperTrend_v2 because I didn't make a lot of improvements to consider it a new version. (Just an opinion)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-07-2005, 06:29 AM
lowphat's Avatar
lowphat lowphat is offline
Senior Member
 
Join Date: Sep 2005
Posts: 199
lowphat is on a distinguished road
maybe in the ea's that dont work you can use something like
if (Hour( ) >8 && Hour( ) <18)
I dont think u have to declare it
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
Market Hours Indicator moldem Indicators - Metatrader 4 50 07-11-2008 03:38 PM
Working indicator not working yuhu Indicators - Metatrader 4 0 05-25-2007 01:38 AM


All times are GMT. The time now is 10:39 AM.