How to code? - page 98

 

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?

 

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

 

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);

 

...

I've got it

 
diffused:
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

 

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??

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
Files:
eur_1.jpg  101 kb
 

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?

 
lizmerrill:
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 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

 
mauro269:
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:

extern bool Use.Time.Filter = false;

extern string Server.Time.To.Start = "08:00";

extern string Server.Time.To.Stop = "16:00";
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() = end_time)) return(0);

Hope that helps.

FerruFx

Reason: