Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
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
  #21 (permalink)  
Old 11-12-2005, 12:41 AM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Lightbulb Wait!

Quote:
Originally Posted by ferman
Hi,

can you explain, how to work with the backtesting ?
what is needed to do for preparing our EA for backtesting ?
how is backtesting works (every tick, open price ...) ?


thanks.
Hi ferman,

Could you wait for backtesting lesson very soon!
I hope you red the previous lessons?
__________________
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #22 (permalink)  
Old 11-15-2005, 12:11 PM
hua hua is offline
Member
 
Join Date: Oct 2005
Location: Athens
Posts: 75
hua is on a distinguished road
Disable alert once hit.

ONE VITAL QUESTION.
In case for an alert in EA, we can mark ''disable alert once hit''.
how we can do that on indicator alerts???
Many tks in advance.
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
  #23 (permalink)  
Old 11-15-2005, 06:22 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow

Quote:
Originally Posted by hua
ONE VITAL QUESTION.
In case for an alert in EA, we can mark ''disable alert once hit''.
how we can do that on indicator alerts???
Many tks in advance.
Hua,

Please refer to my reply here.

I can make a demo for you if you want, Please tell me the indicator you want to add to ''disable alert once hit''.
__________________
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #24 (permalink)  
Old 11-16-2005, 05:57 PM
Member
 
Join Date: Oct 2005
Posts: 35
yaniv_av is on a distinguished road
Hi - a simple question (I hope...)

How can I code a time base exit command ?
I want to know the duration of an open position expresse by the number of bars that position already open.
Actually, I want to close a position automatically after 30 bars (in my expert-advisor)
How can I code that in mql4?

10X !
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
  #25 (permalink)  
Old 11-17-2005, 12:28 AM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Talking BarsCountDown Function (by codersguru)

Quote:
Originally Posted by yaniv_av
How can I code a time base exit command ?
I want to know the duration of an open position expresse by the number of bars that position already open.
Actually, I want to close a position automatically after 30 bars (in my expert-advisor)
How can I code that in mql4?

10X !
Hi yanuv_av,

I'm so sorry for the delay in replaying you; I've spent all the day fixing my damn car to reach my office and reply your questions .

Now you have an EA and want to close the order after 30 bars (or whatever count you want), Right?

Well

Place this function on the top of start() function:

PHP Code:
bool BarsCountDown(int count)
   {
      
      static 
bool first_call true
      static 
int start_bar 0
      if(
first_call)
      { 
         
start_bar=Bars;
         
first_call=false;
      }
      if(
Bars == (start_bar+count))
      {
         Print(
"(TRUE) Bars= " Bars " : start_bars = " start_bar);
         
first_call=true;
         return (
true);
      }
      else
      {
         Print(
"(FALSE) Bars= " Bars " : start_bars = " start_bar);
         return (
false);
      }
      
      
   } 
How to use this function:

bool BarsCountDown(30);

The line above returns false if the current bar hasn't exceeded the number 30 from the first call of the function (the 30 bars not yet counted)

And returns true if the current bar has exceeded the 30 bars

So, when you get true, close the position

In your start() function you may use code like this:

PHP Code:
start()
{
  ....
  if(
BarsCountDwon(30))
  
OrderClose(OrderTicket(),OrderLots(),Bid,3,Red); // close position
  
.....

I hope you've got it.
__________________
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #26 (permalink)  
Old 11-30-2005, 01:29 AM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Unhappy Worked?

Quote:
Originally Posted by codersguru
Hi yanuv_av,

I'm so sorry for the delay in replaying you; I've spent all the day fixing my damn car to reach my office and reply your questions .

Now you have an EA and want to close the order after 30 bars (or whatever count you want), Right?

Well

Place this function on the top of start() function:

PHP Code:
bool BarsCountDown(int count)
   {
      
      static 
bool first_call true
      static 
int start_bar 0
      if(
first_call)
      { 
         
start_bar=Bars;
         
first_call=false;
      }
      if(
Bars == (start_bar+count))
      {
         Print(
"(TRUE) Bars= " Bars " : start_bars = " start_bar);
         
first_call=true;
         return (
true);
      }
      else
      {
         Print(
"(FALSE) Bars= " Bars " : start_bars = " start_bar);
         return (
false);
      }
      
      
   } 
How to use this function:

bool BarsCountDown(30);

The line above returns false if the current bar hasn't exceeded the number 30 from the first call of the function (the 30 bars not yet counted)

And returns true if the current bar has exceeded the 30 bars

So, when you get true, close the position

In your start() function you may use code like this:

PHP Code:
start()
{
  ....
  if(
BarsCountDwon(30))
  
OrderClose(OrderTicket(),OrderLots(),Bid,3,Red); // close position
  
.....

I hope you've got it.
yanuv_av,

Did that work for you?
__________________
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #27 (permalink)  
Old 12-06-2005, 07:05 AM
Junior Member
 
Join Date: Nov 2005
Posts: 16
alnasiradhikari is on a distinguished road
Question ema cross

Hello,
First of all I am very imprest with this site and also with coder, who is helping us to test and make difference code

I am looking to have a code to open and close my position with the following deffination

ema = 3
ema = 13
when ema 3 cross from down to ema 13 plus move 5 pips up, the order will open automatically eample ema 3 and ema 13 cross at 1.1705 for euro/usd my order will be open at 1.1710 it is something like bunnygirl system but I dont know how to make expert please help me.

same technique for selling but all technique reverse

Thanks
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
  #28 (permalink)  
Old 12-06-2005, 07:18 AM
hua hua is offline
Member
 
Join Date: Oct 2005
Location: Athens
Posts: 75
hua is on a distinguished road
Triggerlines Alert

Dear CodersGuru, can we hv an alert when this indicator changes colour pls??
Attached Files
File Type: mq4 Triggerlines.mq4 (3.6 KB, 145 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
  #29 (permalink)  
Old 12-06-2005, 02:29 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Trigger Line

Quote:
Originally Posted by hua
Dear CodersGuru, can we hv an alert when this indicator changes colour pls??
Dear hua,

Please try this:

PHP Code:
//+------------------------------------------------------------------+
//|                                                     Trigger Line |
//|                             Copyright © 2005 dwt5 and adoleh2000 |
//|                                     http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005 dwt5 and adoleh2000 "
#property  link      "http://www.metaquotes.net/"

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 4            
#property indicator_color1 Red      
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Blue

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

int width;

extern int Rperiod 15;
extern int LSMA_Period 5;
int Draw4HowLong;
int shift;
int i;
int j;
int loopbegin;
int length;
int lsma_length;

double lengthvar;
double tmp ;
double tmp2 ;
double wt[];
double sum[];
double lsma_sum[];
double lsma_ma[];
double middle[];
int c;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 7 additional buffers are used for counting.
   
IndicatorBuffers(7);   
   
//---- drawing settings
   
   
SetIndexBuffer(0,ExtMapBuffer1);
   
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   
   
SetIndexBuffer(1,ExtMapBuffer2);
   
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   
   
SetIndexBuffer(2,ExtMapBuffer3);
   
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
   
   
SetIndexBuffer(3,ExtMapBuffer4);
   
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2);
   
   
   
   
SetIndexBuffer(4,sum);        
   
SetIndexBuffer(5,wt);         
   
SetIndexBuffer(6,lsma_ma);
   
//---- initialization done
   
return(0);
  }

int start()

 { 
Draw4HowLong Bars-Rperiod 5;                         //Rperiod = 20
     
length Rperiod;                                         //length now = 20 
      
lsma_length LSMA_Period;
      
loopbegin Draw4HowLong length 1;   
      

      for(
shift loopbeginshift >= 0shift--)  //  MAIN For Loop
      

         
sum[1] = 0;                                             
         for(
length>= i--)             //LSMA loop
         
{
         
lengthvar length 1;                             //lengthvar = 21 
         
lengthvar /= 3;                                     //lengthvar = 7
         
tmp 0;
         
tmp = ( lengthvar)*Close[length-i+shift];         //tmp = 20 - 7 * close[20-i+shift]
         
sum[1]+=tmp;
         }
         
wt[shift] = sum[1]*6/(length*(length+1));  
         
shift;
         
lsma_ma[shift] = wt[j+1] + (wt[j]-wt[j+1])* 2/(lsma_length+1);
  
                         
//========== COLOR CODING ===========================================                     
        
        
            
ExtMapBuffer1[shift] = wt[shift]; 
            
ExtMapBuffer2[shift] = lsma_ma[shift]; 
            
ExtMapBuffer3[shift] = wt[shift]; 
            
ExtMapBuffer4[shift] = lsma_ma[shift]; 
            
            
            
            if (
wt[shift]  < lsma_ma[shift])
            {
                
//Alert("color changed");
                
ExtMapBuffer4[shift] = EMPTY_VALUE;
                
ExtMapBuffer3[shift] = EMPTY_VALUE;
           }          
        
        }
        
        
// Alerts on color change
        // added by codersguru - www.forex-tsd.com

        
static string last_clr "";
        
string current_clr;
        static 
bool first_time false;
        
        if (
first_time)
        {
         if (
wt[0]  < lsma_ma[0])
            
current_clr="Red";
         if (
wt[0]  > lsma_ma[0])
            
current_clr="Blue";
        
         if(
last_clr != current_clr//changed 
          
{
             
last_clr current_clr;
             
Alert("changed : current color is " current_clr);
          }
         }
         else
         {
            
first_time true;
         }
         
  }
//+------------------------------------------------------------------+ 
__________________
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #30 (permalink)  
Old 12-06-2005, 03:17 PM
hua hua is offline
Member
 
Join Date: Oct 2005
Location: Athens
Posts: 75
hua is on a distinguished road
Quote:
Originally Posted by codersguru
Dear hua,

Please try this:

PHP Code:
//+------------------------------------------------------------------+
//|                                                     Trigger Line |
//|                             Copyright © 2005 dwt5 and adoleh2000 |
//|                                     http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005 dwt5 and adoleh2000 "
#property  link      "http://www.metaquotes.net/"

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 4            
#property indicator_color1 Red      
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Blue

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

int width;

extern int Rperiod 15;
extern int LSMA_Period 5;
int Draw4HowLong;
int shift;
int i;
int j;
int loopbegin;
int length;
int lsma_length;

double lengthvar;
double tmp ;
double tmp2 ;
double wt[];
double sum[];
double lsma_sum[];
double lsma_ma[];
double middle[];
int c;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 7 additional buffers are used for counting.
   
IndicatorBuffers(7);   
   
//---- drawing settings
   
   
SetIndexBuffer(0,ExtMapBuffer1);
   
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   
   
SetIndexBuffer(1,ExtMapBuffer2);
   
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   
   
SetIndexBuffer(2,ExtMapBuffer3);
   
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
   
   
SetIndexBuffer(3,ExtMapBuffer4);
   
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2);
   
   
   
   
SetIndexBuffer(4,sum);        
   
SetIndexBuffer(5,wt);         
   
SetIndexBuffer(6,lsma_ma);
   
//---- initialization done
   
return(0);
  }

int start()

 { 
Draw4HowLong Bars-Rperiod 5;                         //Rperiod = 20
     
length Rperiod;                                         //length now = 20 
      
lsma_length LSMA_Period;
      
loopbegin Draw4HowLong length 1;   
      

      for(
shift loopbeginshift >= 0shift--)  //  MAIN For Loop
      

         
sum[1] = 0;                                             
         for(
length>= i--)             //LSMA loop
         
{
         
lengthvar length 1;                             //lengthvar = 21 
         
lengthvar /= 3;                                     //lengthvar = 7
         
tmp 0;
         
tmp = ( lengthvar)*Close[length-i+shift];         //tmp = 20 - 7 * close[20-i+shift]
         
sum[1]+=tmp;
         }
         
wt[shift] = sum[1]*6/(length*(length+1));  
         
shift;
         
lsma_ma[shift] = wt[j+1] + (wt[j]-wt[j+1])* 2/(lsma_length+1);
  
                         
//========== COLOR CODING ===========================================                     
        
        
            
ExtMapBuffer1[shift] = wt[shift]; 
            
ExtMapBuffer2[shift] = lsma_ma[shift]; 
            
ExtMapBuffer3[shift] = wt[shift]; 
            
ExtMapBuffer4[shift] = lsma_ma[shift]; 
            
            
            
            if (
wt[shift]  < lsma_ma[shift])
            {
                
//Alert("color changed");
                
ExtMapBuffer4[shift] = EMPTY_VALUE;
                
ExtMapBuffer3[shift] = EMPTY_VALUE;
           }          
        
        }
        
        
// Alerts on color change
        // added by codersguru - www.forex-tsd.com

        
static string last_clr "";
        
string current_clr;
        static 
bool first_time false;
        
        if (
first_time)
        {
         if (
wt[0]  < lsma_ma[0])
            
current_clr="Red";
         if (
wt[0]  > lsma_ma[0])
            
current_clr="Blue";
        
         if(
last_clr != current_clr//changed 
          
{
             
last_clr current_clr;
             
Alert("changed : current color is " current_clr);
          }
         }
         else
         {
            
first_time true;
         }
         
  }
//+------------------------------------------------------------------+ 
TKS VM INDEED AGAIN YOUR ALWAYS VALUABLE ASSISTANCE.
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
forex, histogram, JMASlope, ToR 1.20, ZUP_v1.mq4


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


All times are GMT. The time now is 12:48 PM.



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