Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions


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
  #701 (permalink)  
Old 08-02-2007, 10:18 AM
Member
 
Join Date: Feb 2006
Posts: 35
flexie is on a distinguished road
Quote:
Originally Posted by european View Post
I am coding an option of OrderSend on the start of the next bar.

Anybody can direct/post good code on how to enter trade on a new bar?
// in main program
if(NewBar()) doEnterTrade();


bool NewBar()
{
static datetime dt = 0;

if (Time[0] != dt)
{
dt = Time[0];
return(true);
}
return(false);
}

Mark
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #702 (permalink)  
Old 08-02-2007, 10:21 AM
Member
 
Join Date: Feb 2006
Posts: 35
flexie is on a distinguished road
Quote:
Originally Posted by luckyfx View Post
Hello!

Could someone post simple code which disable Expert on Monday and start trading week only of the beginning of Tuesday?

Thanks!
luckyfx
#define TUESDAY 2

if(DayOfWeek() < TUESDAY) return(0);

Mark
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #703 (permalink)  
Old 08-02-2007, 11:37 AM
european's Avatar
Senior Member
 
Join Date: Apr 2006
Posts: 284
european is on a distinguished road
Quote:
Originally Posted by flexie View Post
// in main program
if(NewBar()) doEnterTrade();


bool NewBar()
{
static datetime dt = 0;

if (Time[0] != dt)
{
dt = Time[0];
return(true);
}
return(false);
}

Mark
Thanks flexie,

I know how to use Time/iTime now.

euro
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #704 (permalink)  
Old 08-02-2007, 12:14 PM
Junior Member
 
Join Date: Jul 2007
Posts: 3
Benjimang is on a distinguished road
Quote:
Originally Posted by Benjimang View Post
Hi everyone!

I have used the Expert Advisor Builder at sufx.com to create an EA. It has two limitations that I am trying to get rid of:

1. only opens 1 trade at a time. I can get it to have two trades open at once, but I can't get it to open a buy order and a sell order simultaneously.

2. seems to take sell orders as a preference over buy orders. This wouldn't really be an issue if problem number 1 was solved.

Here is the peice of code that seems to be holding me up:

Code:
   //Check position
   bool IsTrade = False;
   
   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
            IsTrade = True;
      if (OrderType() == OP_BUY) {
            //Close
Any suggestions? I'd like to let it open as many trades as possible, and be able to open buy and sell orders simultaneously if the indicators say so.

Cheers for the help,
Benjimang
Why is everyone ignoring me?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #705 (permalink)  
Old 08-02-2007, 12:22 PM
luckyfx's Avatar
Junior Member
 
Join Date: Feb 2006
Posts: 2
luckyfx is on a distinguished road
Quote:
Originally Posted by flexie View Post
#define TUESDAY 2

if(DayOfWeek() < TUESDAY) return(0);

Mark
To flexie:
Thanks a lot! It works fine!
__________________
Lux ex tenebris!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #706 (permalink)  
Old 08-02-2007, 10:25 PM
SaxMan's Avatar
Member
 
Join Date: Mar 2006
Posts: 27
SaxMan is on a distinguished road
New Question -- Simple and quick for "Pros"

Hi Coders,

I need a simple code function to look back over a certain number of bars and return the index of the bar with the greatest range (i.e. high[]-low[]) as well as the range of that bar, itself.

Any help would be appreciated,
Thanks,
SaxMan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #707 (permalink)  
Old 08-03-2007, 07:19 PM
SaxMan's Avatar
Member
 
Join Date: Mar 2006
Posts: 27
SaxMan is on a distinguished road
Asked & Answered

Hi all,

I thought I had my answers with the following code:

Code:
double range[5];
  for(int i=1;i<5;i++)
   {
  range[i]={High[i]-Low[i]};
  int Max=ArrayBsearch(range,10,WHOLE_ARRAY,1,MODE_ASCEND);
  double MaxRange=(High[Max]-Low[Max])/Point;
  } 
  Print("Max Range: ",MaxRange," found at index: ",Max);
But it still just returns the last index not the largest range index.

Any further help would be appreciated.
SaxMan

Last edited by SaxMan; 08-03-2007 at 07:37 PM. Reason: found error
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #708 (permalink)  
Old 08-03-2007, 08:01 PM
SaxMan's Avatar
Member
 
Join Date: Mar 2006
Posts: 27
SaxMan is on a distinguished road
Error Fixed

Quote:
Originally Posted by SaxMan View Post
Hi all,

I thought I had my answers with the following code:

Code:
double range[5];
  for(int i=1;i<5;i++)
   {
  range[i]={High[i]-Low[i]};
  int Max=ArrayBsearch(range,10,WHOLE_ARRAY,1,MODE_ASCEND);
  double MaxRange=(High[Max]-Low[Max])/Point;
  } 
  Print("Max Range: ",MaxRange," found at index: ",Max);
But it still just returns the last index not the largest range index.

Any further help would be appreciated.
SaxMan
Here's the fix:
Code:
double range[5];
  for(int i=1;i<5;i++)
   {
  range[i]={High[i]-Low[i]};
  int Max=ArrayMaximum(range);
  double MaxRange=(High[Max]-Low[Max])/Point;
  }
  
  Print("Max Range: ",MaxRange," found at index: ",Max);
This could be used to get the highest/lowest(using ArrayMinimum(range)) of the array to compare any variables.

Hope this helps,
SaxMan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #709 (permalink)  
Old 08-03-2007, 08:56 PM
SaxMan's Avatar
Member
 
Join Date: Mar 2006
Posts: 27
SaxMan is on a distinguished road
Same Code with additions

Added:
* Minimum range
* Vertical Lines to highlight Max and Min range bars:

Code:
double range[2000];
  for(int i=1;i<2000;i++)
   {
   range[i]={High[i]-Low[i]};
   int Max=ArrayMaximum(range,WHOLE_ARRAY,1);
   int Min=ArrayMinimum(range,WHOLE_ARRAY,1);
   double MaxRange=(High[Max]-Low[Max])/Point;
   double MinRange=(High[Min]-Low[Min])/Point;
   }
  
  Print("Max Range: ",MaxRange," pips    found at index: ",Max);
  Print("Min Range: ",MinRange," pips    found at index: ",Min);
  
  int time1=Time[Max];
  int time2=Time[Min];
  
  ObjectCreate("stats1",OBJ_VLINE,0,0,0);
  ObjectSet("stats1", OBJPROP_TIME1, time1);
  ObjectSet("stats1", OBJPROP_COLOR, Red);
  ObjectSet("stats1", OBJPROP_WIDTH, 1);
  
  ObjectCreate("stats2",OBJ_VLINE,0,0,0);
  ObjectSet("stats2", OBJPROP_TIME1, time2);
  ObjectSet("stats2", OBJPROP_COLOR, Blue);
  ObjectSet("stats2", OBJPROP_WIDTH, 1);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #710 (permalink)  
Old 08-04-2007, 12:53 AM
iscuba11's Avatar
Senior Member
 
Join Date: May 2006
Location: Houston
Posts: 399
iscuba11 is on a distinguished road
Exclamation Code complies, but does not display value

extern Bool Direction_Up=true;

if(Direction_Up==true) Dir="UP"; ///////////This is wrong conversion - How do I convert it to the proper syntax????

ObjectCreate("Dir", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Dir", 10, "Arial", White);///////////This is wrong - How do I get it to display UP on the screen????
ObjectSet("Dir", OBJPROP_CORNER, 1);
ObjectSet("Dir", OBJPROP_XDISTANCE, 36);
ObjectSet("Dir", OBJPROP_YDISTANCE, 120);///



Dave
<><<<

Last edited by iscuba11; 08-04-2007 at 03:41 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram, forex, ZUP_v1.mq4

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
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 10:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 12:46 PM


All times are GMT. The time now is 06:17 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.