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
  #971 (permalink)  
Old 05-29-2008, 08:42 AM
MrM MrM is offline
Member
 
Join Date: Jul 2007
Posts: 75
MrM is on a distinguished road
How to make an indicator work on another indicator?

If you drop the basic moving average (included as indicator in MT4) on another indicator, it is possible to calculate the MA of the indicator, but how do you change a custom indicator in such a way that it's possible to drop it on another indicator?
__________________
tensigma.blogspot.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #972 (permalink)  
Old 05-29-2008, 12:36 PM
Junior Member
 
Join Date: Apr 2008
Posts: 2
diffused is on a distinguished road
on bar open

Hi,

I'm wanting to run a piece of code only when a new bar is created (on bar open).

Anyone have a code snippet for something like this?


Cheers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #973 (permalink)  
Old 05-30-2008, 11:04 AM
Junior Member
 
Join Date: May 2008
Posts: 5
shenxinon is on a distinguished road
Unhappy why my Indicator do not work well????

#property copyright "沈欣"
#property link "shenxinon@126.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 SteelBlue
//#property indicator_minimum -0.01
//#property indicator_maximum 0.01
//---- input parameters
extern int SMA1=12;
extern int SMA2=72;
//---- buffers
double ExtMapBuffer1[];
//---- 自定义区
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
string sName="RAVI indicator";
IndicatorShortName("RAVI indicator("+SMA1+","+SMA2+")");

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
if(counted_bars<0) return(-1);// if there is a error then exit and return -1
if(counted_bars>0) counted_bars--;
int pos = Bars-counted_bars;

double sma1,sma2,r;
while(pos>=0)
{
sma1=iMA(NULL,0,SMA1,0,MODE_SMA,PRICE_CLOSE,pos);
sma2=iMA(NULL,0,SMA2,0,MODE_SMA,PRICE_CLOSE,pos);
r=((sma1-sma2)/sma2)*10000;
//Alert("r=",r);
ExtMapBuffer1[pos]=r;
pos--;
}
return(0);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #974 (permalink)  
Old 05-30-2008, 11:41 AM
Junior Member
 
Join Date: May 2008
Posts: 5
shenxinon is on a distinguished road
...

I've got it
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #975 (permalink)  
Old 05-30-2008, 04:08 PM
Member
 
Join Date: Oct 2006
Posts: 71
Big Be is on a distinguished road
Quote:
Originally Posted by diffused View Post
Hi,

I'm wanting to run a piece of code only when a new bar is created (on bar open).

Anyone have a code snippet for something like this?


Cheers

if (Volume[0] == 1)
{DO...}

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #976 (permalink)  
Old 05-31-2008, 07:26 PM
Junior Member
 
Join Date: Aug 2007
Posts: 5
Matrix 78 is on a distinguished road
trend Envelope EA

Hola
I'm teaching mql.
I read Usage of Technical Indicators - Simple Programs in MQL4 - MQL4 Tutorial, but i don't find something like
Is it possible to color a single bar?Exemple during test your EA u can color the entry bar...
On metatrader i don't see any watch system, like to see the field of my variabile array there is in all C compilator
I wanto to to do this stupid system:
When price broke and close up the trend evelope (look the pic wich yellow cirlce) i open an alert and color a breakbar.
But my problem is that this that i read only the trend up indicator and not during short period why??


Code:
double maxprec= iHigh(NULL, PERIOD_M5,1);
   double minprec=iLow(NULL, PERIOD_M5,1);
   double chiusura2 = iClose(NULL,PERIOD_M15 ,2);
   double chiusura = iClose(NULL,PERIOD_M15 ,1);
   double chiu2 = iClose(NULL,PERIOD_M5 ,2);
   double chiu = iClose(NULL,PERIOD_M5 ,1);
   double apertura = iOpen(NULL,PERIOD_M15 ,0)
string rottura [3] = {" Nulla"," ROTTO"};


envelope15_1=iCustom(NULL, PERIOD_M15, "TrendEnvelopes_v1", 5,0,1);// trend envelope

if( chiusura2 > envelope15_2 && chiusura < envelope15_2 && apertura <= envelope15_2)  
      {
      rot=1;
      Alert ( " ha rotto SH M15");
      }
     else
      rot=0; 

Comment( ""\nBreak Enveolpe M 5= ", rottura[rot2],
           "\nBrerak Enveolpe M 15= ", rottura[rot]
           ); // Alert
Attached Images
File Type: jpg eur.JPG (100.5 KB, 135 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #977 (permalink)  
Old 06-01-2008, 07:15 PM
Junior Member
 
Join Date: Apr 2006
Posts: 6
lizmerrill is on a distinguished road
Is This Correct Formula

is this the correct formula for calculating the value of a pip for the eur/chf cross:

(1/(eur/chf))*10*(eur/us)
a pip is .0001.

Correct formula above?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #978 (permalink)  
Old 06-01-2008, 10:24 PM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 345
Devil2000 is on a distinguished road
Quote:
Originally Posted by lizmerrill View Post
is this the correct formula for calculating the value of a pip for the eur/chf cross:

(1/(eur/chf))*10*(eur/us)
a pip is .0001.

Correct formula above?
Use this code:

pipvalue=MarketInfo("EURCHF",MODE_TICKVALUE);

Hope this helps
__________________
Need a professional MQL4 programmer? PM me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #979 (permalink)  
Old 06-04-2008, 02:05 PM
Member
 
Join Date: Mar 2008
Posts: 45
mauro269 is on a distinguished road
Need the code to stop the open of positions after a certain time

I've already seen all the posts in this section and I've made a research on all the forum using the google search tool at the top of the forum, but what I've found is not exactly what I'm looking for.

What I need is a code that I have to implement in my EA that stops to open new position after a certain hour, for example after 15 GMT. This parameter should be a setting that I can modify from the user panel.
It would be great if I could set a period of time in which the EA can open the positions, so

Open from X hours until Y hours

Thanks for your help.
Regards
__________________
I'm studing to become an MQL Programmer!
The best strategy to use ForexKiller. Try it: http://forex-killerallday.blogspot.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #980 (permalink)  
Old 06-04-2008, 04:40 PM
Senior Member
 
Join Date: Feb 2007
Posts: 947
FerruFx is on a distinguished road
Quote:
Originally Posted by mauro269 View Post
I've already seen all the posts in this section and I've made a research on all the forum using the google search tool at the top of the forum, but what I've found is not exactly what I'm looking for.

What I need is a code that I have to implement in my EA that stops to open new position after a certain hour, for example after 15 GMT. This parameter should be a setting that I can modify from the user panel.
It would be great if I could set a period of time in which the EA can open the positions, so

Open from X hours until Y hours

Thanks for your help.
Regards
Here's how I do:

Quote:
extern bool Use.Time.Filter = false;
extern string Server.Time.To.Start = "08:00";
extern string Server.Time.To.Stop = "16:00";
Quote:
start_time = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + Server.Time.To.Start);
end_time = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + Server.Time.To.Stop);

if(Use.Time.Filter && (TimeCurrent() < start_time || TimeCurrent() >= end_time)) return(0);
Hope that helps.

FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
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 12:18 PM.



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