Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #611 (permalink)  
Old 01-10-2008, 03:36 AM
Dan7974's Avatar
Senior Member
 
Join Date: Jul 2006
Posts: 267
Dan7974 is on a distinguished road
A code

How can I code this?

If the market touches (X.XX50 or X.XX00)
then buy. How to identify last two numbers?


thanks.
__________________
God Bless Everyone, and their trading logic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #612 (permalink)  
Old 01-10-2008, 04:16 AM
TheRumpledOne's Avatar
Banned
 
Join Date: Nov 2006
Posts: 802
TheRumpledOne is an unknown quantity at this point
Quote:
Originally Posted by Dan7974 View Post
How can I code this?

If the market touches (X.XX50 or X.XX00)
then buy. How to identify last two numbers?


thanks.

This should do it:

Code:
     
if ( Point == 0.01 )  {xPrice = Close[i] - MathMod(Close[i],0.50) ; }
     else { xPrice = Close[i] - ( MathMod(100*Close[i],0.50)*0.01 ) ;  } 


        P1Buffer[i] = xPrice + Point*50;
        P2Buffer[i] = xPrice ;
        P3Buffer[i] = xPrice - Point*50;

When MathMod(Close[i],0.50) = 0 then the price ends in 00 or 50.






Here's my indicator to identify 00 lines:


Code:
//+------------------------------------------------------------------+
//|          _TRO_00_Lines                                           |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window 

#property indicator_buffers 3

#property indicator_color1 LightGray 
#property indicator_color2 LightGray 
#property indicator_color3 LightGray  

// indicators parameters

//---- buffers
double P1Buffer[];
double P2Buffer[];
double P3Buffer[];

double xPrice ;
int myStyle  = 2 ;

int myWingDing  = 250 ;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

   SetIndexBuffer(0, P1Buffer);
   SetIndexBuffer(1, P2Buffer);
   SetIndexBuffer(2, P3Buffer); 

SetIndexArrow(0, myWingDing); 
SetIndexArrow(1, myWingDing); 
SetIndexArrow(2, myWingDing); 

   SetIndexStyle(0, DRAW_ARROW, myStyle, 1);
   SetIndexStyle(1, DRAW_ARROW, myStyle, 1);   
   SetIndexStyle(2, DRAW_ARROW, myStyle, 1);   
   
   SetIndexEmptyValue(0,0); 
   SetIndexEmptyValue(1,0);
   SetIndexEmptyValue(2,0);

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

   int i, dayi, counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;  
   int limit = Bars - counted_bars;
//----   





   for(i = limit - 1; i >= 0; i--)
     {
      
     if ( Point == 0.01 )  {xPrice = Close[i] - MathMod(Close[i],1.00) ; }
     else { xPrice = Close[i] - ( MathMod(100*Close[i],1.00)*0.01 ) ;  }  
   
        P1Buffer[i] = xPrice + Point*100;
        P2Buffer[i] = xPrice ;
        P3Buffer[i] = xPrice - Point*100;  
                    
     } // for 
 
   return(0);

  } // start
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #613 (permalink)  
Old 01-10-2008, 04:55 AM
Dan7974's Avatar
Senior Member
 
Join Date: Jul 2006
Posts: 267
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #614 (permalink)  
Old 01-14-2008, 08:25 AM
Senior Member
 
Join Date: Sep 2007
Location: Poland
Posts: 272
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, 117 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #615 (permalink)  
Old 01-14-2008, 09:07 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #616 (permalink)  
Old 01-14-2008, 04:23 PM
Senior Member
 
Join Date: Sep 2007
Location: Poland
Posts: 272
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, 30 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #617 (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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #618 (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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #619 (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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #620 (permalink)  
Old 01-17-2008, 10:18 PM
Junior Member
 
Join Date: Dec 2007
Posts: 8
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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:30 AM.



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