[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 141

 

That's it, it worked. Seems to be because I set one buffer.

#property indicator_buffers 1

 

You have done everything correctly. I checked it - it outputs as it should (I can give you a screenshot).

I just added on top of it

#property  indicator_separate_window
#property  indicator_buffers 2
 

Помогите, плиз!!!

double Lots_simb[3];


if(( Lots_simb[0]*2)< Lots_simb[2]) // почему истина ?
{

Print("Lots_simb[0]*2=", Lots_simb[0]*2,"Lots_simb[2]=", Lots_simb[2]);
Open_Buy_otl( symb[0],( Lots_simb[2]/2- Lots_simb[0]));

return;

}

2009.07.10 06:57:09 newseason GBPJPY, M30: Lots_simb[0]*2=8.4  Lots_simb[2]=8.4
 
Gentlemen of knowledge, when the log in the tester says "Function not allowed in test mode" how do I know what function is not allowed?
 
Dimoncheg писал(а) >>
Gentlemen, when the log in the tester says "Function is not allowed in test mode" how do I know what function is not allowed?

Features and limitations of testing trading strategies in MetaTrader 4'

 

Hello, I really need some help! I want to make an EA based on an indicator. In the beginning, like in any indicator, there are these lines:

SetIndexBuffer(0,ExtBullBuffer);
SetIndexBuffer(1,ExtBull1Buffer);
SetIndexBuffer(2,ExtBull2Buffer);
SetIndexBuffer(3,ExtBull3Buffer);
SetIndexBuffer(4,ExtBull4Buffer);
SetIndexBuffer(5,ExtBull5Buffer);
SetIndexBuffer(6,ExtBull6Buffer);
SetIndexBuffer(7,ExtBull7Buffer);
Then comes the body of the program (int start()...) where the variables ExtBullBuffer are calculated... I want to make an EA, so I don't need SetIndexBuffer, but if I remove it, while testing variables ExtBullBuffer are not calculated (for all timeframe of testing, for all timeframes it generates 0, though it's not true)... Can you advise what to do? Thank you.

 
Levchik >> :

Hello, I really need some help! I want to make an EA based on an indicator. In the beginning, like in any indicator, there are these lines:

SetIndexBuffer(0,ExtBullBuffer);
Then comes the body of the program (int start()...), which calculates variables ExtBullBuffer... I want to make an EA, so I don't need SetIndexBuffer, but if I remove it, while testing variables ExtBullBuffer are not calculated (for all timeframe of testing, for all timeframes it generates 0, though it's not true)... Can you advise what to do? >> Thank you.

In indicator buffers, the buffer is initialized automatically as soon as you declare the buffer as indicator (not auxiliary),

in other programs (not indicators) buffers need to be initialized with the ArrayResize(ExtBullBuffer,Bars) function;

(if the buffer is not explicitly named double ExtBullBuffer[1000]; )

And initialization should be done in function where it is supposed to assign values to the buffer. In your case, in int start().

 

Hi all. Can you tell me how to fix the code of the indicator, so that the beep is output not once, but 10 times, or as there is an indicator where the signal until the next candlestick appears. That is, the signal goes all the time the candle in which it occurred. I have a good signal, but only once... Unfortunately, I can not hear it at night(((( I thank you in advance for your feedback.

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Yellow
#property indicator_width1 2
#property indicator_color2 SkyBlue
#property indicator_width2 2
#property indicator_color3 Tomato
#property indicator_width3 2

#property indicator_color4 Blue
#property indicator_color5 Red
#property indicator_width4 1
#property indicator_width5 1

//---- input parameters
extern int Price = 0; //Apply to Price(0-Close;1-Open;2-High;3-Low;4-Median price;5-Typical price;6-Weighted Close)
extern int Length = 15; //Period of NonLagMA
extern inttern Displace = 0; //DispLace or Shift
extern double PctFilter = 0; //Dynamic filter in decimal
extern string note1 ="turn on Color: ln=1 ln&dot=2; off=0";
extern int Color = 2; //Switch of Color mode (1-color)
extern int ColorBarBack = 0; //Bar back for color mode
extern double Deviation = 0; //Up/down deviation
extern string note2 ="turn on = 1; turn off = 0";
extern int AlertMode = 0; //box Alert switch (0-off,1-on)
extern int WarningMode = 0; //Sound Warning switch(0-off,1-on)
extern int SendEmail = 0;
extern string soundfile = "news.wav";
//---- indicator buffers
double MABuffer[];
double UpBuffer[];
double DnBuffer[];
double trend[];
double Del[];
double AvgDel[];
double updbuffer[];
double dndbuffer[];

double alfa[];
int i, Phase, Len, Cycle=4;
double Coeff, beta, t, Sum, Weight, g;
double pi = 3.1415926535;
bool UpTrendAlert=false, DownTrendAlert=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(8);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,MABuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,UpBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,DnBuffer);

SetIndexBuffer(5,trend);
SetIndexBuffer(6,Del);
SetIndexBuffer(7,AvgDel);


SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,159); SetIndexBuffer(3,updbuffer); SetIndexEmptyValue(3,EMPTY_VALUE);
SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,159); SetIndexBuffer(4,dndbuffer); SetIndexEmptyValue(4,EMPTY_VALUE);


string short_name;
//---- indicator line

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
short_name="NonLagMA("+Length+")";
IndicatorShortName(short_name);
SetIndexLabel(0, "NonLagMA");
SetIndexLabel(1, "Up");
SetIndexLabel(2, "Dn");
//----
SetIndexShift(0,Displace);
SetIndexShift(1,Displace);
SetIndexShift(2,Displace);
SetIndexShift(3,Displace);
SetIndexShift(4,Displace);

SetIndexEmptyValue(0,EMPTY_VALUE);
SetIndexEmptyValue(1,EMPTY_VALUE);
SetIndexEmptyValue(2,EMPTY_VALUE);

SetIndexDrawBegin(0,Length*Cycle+Length+1);
SetIndexDrawBegin(1,Length*Cycle+Length+1);
SetIndexDrawBegin(2,Length*Cycle+Length+1);
//----

Coeff = 3*pi;
Phase = Length-1;
Len = Length*4 + Phase;
ArrayResize(alfa,Len);
Weight=0;

for (i=0;i<Len-1;i++)
{
if (i<=Phase-1) t = 1.0*i/(Phase-1);
else t = 1.0 + (i-Phase+1)*(2.0*Cycle-1.0)/(Cycle*Length-1.0);
beta = MathCos(pi*t);
g = 1.0/(Coeff*t+1);
if (t <= 0.5 ) g = 1;
alfa[i] = g * beta;
Weight += alfa[i];
}

return(0);
}

//+------------------------------------------------------------------+
//| NonLagMA_v7.1 |
//+------------------------------------------------------------------+
int start()
{
int i,shift, counted_bars=IndicatorCounted(),limit;
double price;
if ( counted_bars > 0 ) limit=Bars-counted_bars;
if ( counted_bars < 0 ) return(0);
if ( counted_bars ==0 ) limit=Bars-Len-1;
if ( counted_bars < 1 )

for(i=1;i<Length*Cycle+Length;i++)
{
MABuffer[Bars-i]=0;
UpBuffer[Bars-i]=0;
DnBuffer[Bars-i]=0;
}

for(shift=limit;shift>=0;shift--)
{
Sum = 0;
for (i=0;i<=Len-1;i++)
{
price = iMA(NULL,0,1,0,3,Price,i+shift);
Sum += alfa[i]*price;

}

if (Weight > 0) MABuffer[shift] = (1.0+Deviation/100)*Sum/Weight;


if (PctFilter>0)
{
Del[shift] = MathAbs(MABuffer[shift] - MABuffer[shift+1]);

double sumdel=0;
for (i=0;i<=Length-1;i++) sumdel = sumdel+Del[shift+i];
AvgDel[shift] = sumdel/Length;

double sumpow = 0;
for (i=0;i<=Length-1;i++) sumpow+=MathPow(Del[shift+i]-AvgDel[shift+i],2);
double StdDev = MathSqrt(sumpow/Length);

double Filter = PctFilter * StdDev;

if( MathAbs(MABuffer[shift]-MABuffer[shift+1]) < Filter ) MABuffer[shift]=MABuffer[shift+1];
}
else
Filter=0;

if (Color>0)
{
trend[shift]=trend[shift+1];
if (MABuffer[shift]-MABuffer[shift+1] > Filter) trend[shift]= 1;
if (MABuffer[shift+1]-MABuffer[shift] > Filter) trend[shift]=-1;

updbuffer[shift] = EMPTY_VALUE; dndbuffer[shift] = EMPTY_VALUE;

if (trend[shift]>0)
{
UpBuffer[shift] = MABuffer[shift];
if (trend[shift+ColorBarBack]<0) UpBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
DnBuffer[shift] = EMPTY_VALUE;
if (trend[shift+1]<0&Color>1) updbuffer[shift]= MABuffer[shift];
}
if (trend[shift]<0)
{
DnBuffer[shift] = MABuffer[shift];
if (trend[shift+ColorBarBack]>0) DnBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
UpBuffer[shift] = EMPTY_VALUE;
if (trend[shift+1]>0&Color>1) dndbuffer[shift]= MABuffer[shift];

}
}
}
//----------
string Message;

if ( trend[2]<0 && trend[1]>0 && Volume[0]>1 && !UpTrendAlert)
{
Message = ""+Symbol()+" M "+Period()+" NonLagMa Signal for BUY";
if ( AlertMode>0 ) Alert (Message);
if ( WarningMode>0 ) PlaySound(soundfile);
if ( SendEmail>0 ) SendMail("NonLagMa", "UpTrendAlert");
UpTrendAlert=true; DownTrendAlert=false;
}

if ( trend[2]>0 && trend[1]<0 && Volume[0]>1 && !DownTrendAlert)
{
Message = ""+Symbol()+" M "+Period()+" NonLagMa Signal for SELL";
if ( AlertMode>0 ) Alert (Message);
if ( WarningMode>0 ) PlaySound(soundfile);
if ( SendEmail>0 ) SendMail("NonLagMa", "DownTrendAlert");
DownTrendAlert=true; UpTrendAlert=false;
}
//----
return(0);
}

 
E_mc2 >> :

Hi all. Please advise how to fix the code indyuka that the beep is not displayed once, and then 10 times, or as there are indyuki where the signaling until the next candle appears. That is, the signal goes all the time the candle in which it occurred. I have a good signal, but only once... Unfortunately, sometimes I can not hear it at night(((( I thank you in advance who will help.

What do you need it for? Tell me more about it, maybe there is a solution and you don't know how to ask the right questions so that people understand.

On what you have written, I have two solutions, you what, two at once too long to write :)

..

By the way, it's better to attach such long codes as a file.

And for the code, there's a special button SRC.

Reason: