Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


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 (1) Thread Tools Display Modes
  #611 (permalink)  
Old 01-10-2008, 04:55 AM
Dan7974's Avatar
Senior Member
 
Join Date: Jul 2006
Posts: 264
Dan7974 is on a distinguished road
I need it for an EA though!
__________________
God Bless Everyone, and their trading logic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #612 (permalink)  
Old 01-14-2008, 08:25 AM
Senior Member
 
Join Date: Sep 2007
Location: Poland
Posts: 239
Pucio is on a distinguished road
Coders please help

What to change in the code to move more up and down dots from candlesticks ?
Attached Images
File Type: gif diagram.gif (17.0 KB, 92 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #613 (permalink)  
Old 01-14-2008, 09:07 AM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
Somebody might actually help you if you posted the code.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #614 (permalink)  
Old 01-14-2008, 04:23 PM
Senior Member
 
Join Date: Sep 2007
Location: Poland
Posts: 239
Pucio is on a distinguished road
Here is the indicator

Indicator you can change the code to move up and down dots
Attached Files
File Type: mq4 3_Level_ZZ_Semafor.mq4 (7.9 KB, 17 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #615 (permalink)  
Old 01-14-2008, 10:01 PM
Junior Member
 
Join Date: Jan 2008
Posts: 1
mweltin is on a distinguished road
proper use of Time[]

I'm a fair programmer but new to mql4. I'm working on a box trade (aka breakout trade) expert adviser. Essentially it should find the highest and lowest values for a specific time frame, and when a candle closes outside of that box I place a trade.

Essentially there are three states, I can start my EA in
1) after the close of the previous day, and before the box start time.
2) after the start of the box but before the end of the box.
3) after the end of the box.

What I find confusing is the Time[] array because the index keeps changing. Assume I enter at state 2. In the init function I was going to set a global variable giving the position of the start of the box. As quotes come in my start function is constantly called, and once the end of the box time was reached I would have the start and end positions. Of course that is not the case as the index on the Time array keeps rolling forward.

At best I can keep incrementing the position of the box start index, but that doesn't seem a very clean way to do things.

If you have a suggestion on how I should change my thinking away traditional c/c++ to mql4 I'd love to hear it.

Also when I'm done I would obviously benefit greatly from a code review by a more senior programmer. Would anyone like to volunteer for that?

Thanks for your time,
Markus
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #616 (permalink)  
Old 01-14-2008, 10:35 PM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
Quote:
Originally Posted by mweltin View Post
I'm a fair programmer but new to mql4. I'm working on a box trade (aka breakout trade) expert adviser. Essentially it should find the highest and lowest values for a specific time frame, and when a candle closes outside of that box I place a trade.

Essentially there are three states, I can start my EA in
1) after the close of the previous day, and before the box start time.
2) after the start of the box but before the end of the box.
3) after the end of the box.

What I find confusing is the Time[] array because the index keeps changing. Assume I enter at state 2. In the init function I was going to set a global variable giving the position of the start of the box. As quotes come in my start function is constantly called, and once the end of the box time was reached I would have the start and end positions. Of course that is not the case as the index on the Time array keeps rolling forward.

At best I can keep incrementing the position of the box start index, but that doesn't seem a very clean way to do things.

If you have a suggestion on how I should change my thinking away traditional c/c++ to mql4 I'd love to hear it.

Also when I'm done I would obviously benefit greatly from a code review by a more senior programmer. Would anyone like to volunteer for that?

Thanks for your time,
Markus
Hi. The Time[] function does not keep changing - only at the end of the current chart bar does it change. TimeCurrent() on the other hand returns a continuously changing value (albeit, with a 1 sec resolution).

You can get the exact time of any bar and timeframe using iTime() as well. There's quite a few ways to go about it...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #617 (permalink)  
Old 01-17-2008, 05:01 PM
Junior Member
 
Join Date: Dec 2005
Posts: 1
jdr100 is on a distinguished road
open two orders on the same time (problem...)

Hi, i don't know why in some Opportunities the script open two orders on the same time.

someone can help me with this, please

if(UseStopLoss)
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,EAName, MagicNo, 0,Green);
else
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point,EAName, MagicNo, 0,Green);

if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());


thank's
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #618 (permalink)  
Old 01-17-2008, 10:18 PM
Junior Member
 
Join Date: Dec 2007
Posts: 7
manu29 is on a distinguished road
Help for code

Hi all,

I would like to code an indicator for compute the close value wich create a reversal of an indicator like HMA. For that i need to create a function for compute one value of HMA with a close values tab where i modify the current value in an dichotomy loop to find the value wich create the reversal.
Somebody can help me with my ComputeHull function ?

Here my code, without dichotomy reseach it is just a simple HMA indicator with computeHull function, the indicator is displayed but it is shifted down

Regards

//#property indicator_separate_window
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue

//---- input parameters
extern int HullAntPeriod=12;

//---- buffers
double TempBuf1[];
double TempBuf2[];
double HullAntBuf[];

//Variable
int HalfHullAntPeriod;
int SqrtHullAntPeriod;

//+------------------------------------------------------------------+
//| Specific functions |
//+------------------------------------------------------------------+
double ComputeHull(int ActualBar)
{
double CloseTemp[];
double Temp[];
double Temp1, Temp2;
double result = -1;
int i;

//Copy Close Values to CloseTemp
ArrayResize(CloseTemp, HullAntPeriod+SqrtHullAntPeriod);
ArrayCopy(CloseTemp, Close, 0, ActualBar, HullAntPeriod+SqrtHullAntPeriod);
ArraySetAsSeries(CloseTemp, true);
ArrayResize(Temp, SqrtHullAntPeriod);

//HMA value computation
for(i=0; i<SqrtHullAntPeriod; i++)
{
Temp1 = iMAOnArray(CloseTemp, 0, HalfHullAntPeriod, 0, MODE_LWMA, i);
Temp2 = iMAOnArray(CloseTemp, 0, HullAntPeriod, 0, MODE_LWMA, i);
Temp[i] = 2*Temp1-Temp2;
}
ArraySetAsSeries(Temp, true);
result = iMAOnArray(Temp, 0, SqrtHullAntPeriod, 0, MODE_LWMA, 0);

//---- done
return(result);
}

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 1 additional buffers are used for temporary data.
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_NONE);
//---- 2 indicator buffers mapping
SetIndexBuffer(0,HullAntBuf);
SetIndexBuffer(1,TempBuf1);
SetIndexBuffer(2,TempBuf2);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("HULL ANTICIP("+HullAntPeriod+")");
SetIndexLabel(0,"HULL ANTICIPATION");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);

//---- Specific indicator initialization
HalfHullAntPeriod = MathFloor(HullAntPeriod/2);
SqrtHullAntPeriod = MathFloor(MathSqrt(HullAntPeriod));

//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int bar, limit, i;
int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

for(i=0; i<limit; i++)
HullAntBuf[i]=ComputeHull(i);
//----
return(0);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #619 (permalink)  
Old 01-18-2008, 06:52 AM
Dan7974's Avatar
Senior Member
 
Join Date: Jul 2006
Posts: 264
Dan7974 is on a distinguished road
Why doesn't this work?

PHP Code:
int Highest;
double Place;

int Start()
 {
  
Highest=iHighest(Symbol(),0,MODE_HIGH,1,0);Place=iHigh(Symbol(),0,Highest);
  
  if(
Gate==0){
   if(
iClose(Symbol(),0,0)>=Place){
    
OrderModify(ticket3,Ask,Ask-TrailingStop*Point-Spread,0,0,Green);
    
Gate=1;}
    
    return(
0);
 } 
I get errors. I can't make a simple trailing stop!!!!!!!
__________________
God Bless Everyone, and their trading logic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #620 (permalink)  
Old 01-18-2008, 11:42 AM
Senior Member
 
Join Date: May 2007
Posts: 150
dvarrin is on a distinguished road
HOW to Open an order at the beginning of a bar only ??

Hi,

I'm implementing an EA in which I want to open an order only if a cross of some level by an indicator has occured between the second previous bar and the previous one.

For example, on the daily chart, If there is a cross between the 18th of January and the 19th of January, I want to open an order on the 20th of January.

I did something like this:
When I open an order, I record the order open time.
Then I do the following test: Is (CurrentTime() - LastOrderOpenTime) < Period() ??

If yes, it means that the current bar is not finished, yet, and I shouldn't open a new order. And also, when this condition becomes false, I should be on the next bar of the chart, and the cross happened before the last bar and no order should be opened until the next signal.

The problem is that when attaching it to a chart, it keeps on creating new orders until the bar is finished. Anybody can tell me what I did wrong?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading

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/metatrader-programming/554-how-code.html
Posted By For Type Date
Need an experienced programmer? - Page 2 Post #0 Refback 09-24-2008 07:24 AM

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


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



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