[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 263

 
Run >> :

Can you tell me how to draw a square or rectangle without drawing it as a background, and draw it as a frame?

Thank you

In the list of object properties, set the rectangle property to be drawn as a background to false:

ObjectSet( string name, OBJPROP_BACK, false) ;

But the object will be drawn before the chart .

 

edit | delete

I apologise, perhaps for an unreasonable question...


I am a little slow with indicator buffers.... Or, I haven't quite figured out the indicator itself...


Could you please advise how to refer to BrainTrend2StopN indicator if possible?


I want to check if the opening of the current bar is higher/lower than the indicator values.

I access the indicator from the EA with string:


iCustom(NULL,0, "BrainTrend2StopN",CountBars, 1,0)

or

iCustom(NULL,0, "BrainTrend2StopN",CountBars, 0,0)

for zero and the first buffer respectively....

But, the Expert Advisor doesn't react to this string...


Many thanks in advance.

Files:
 
Morzh09 >> :

iCustom(NULL,0, "BrainTrend2StopN",CountBars,1,0)

or

iCustom(NULL,0, "BrainTrend2StopN",CountBars,0,0)

for zero and the first buffer respectively....

The Expert Advisor doesn't react to this string...

Note that you have 2 external parameters in your indicator:

extern int Simbol =119;

extern intBars=500;

you have to write them all in the iCustom:


iCustom(NULL,0,"BrainTrend2StopN", Simbol, CountBars, 0,0);

iCustom(NULL,0,"BrainTrend2StopN", Simbol, CountBars, 1,0);
 

alsu


Thank you very much. Corrected the code, now I pass both parameters, but unfortunately, when I call Alert with indicator buffer values, I get only zeros....


If you get a chance, can you tell me how to deal with it.

Files:
bt1_1.mq4  10 kb
 

Try

Alert("Buy signal",
      "  ",
      DoubleToStr(iCustom(NULL,0,"BrainTrend1StopN", Simbol, CountBars, EnableAlerts, SignalID,1,0),8),
      "   ", 
      DoubleToStr(iCustom(NULL,0,"BrainTrend1StopN", Simbol, CountBars, EnableAlerts, SignalID,0,0),8)
      );
 
Please help me, gentlemen programmers. I have been struggling with this for a week, but nothing works, because I have no idea how to program. Can you write an indicator that crosses two HMAs and has pointers in the form of arrows?
Files:
hma.mq4  4 kb
 

for some reason does not understand what a shift is and does not want to put arrows

#property indicator_chart_window
//#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Magenta // 12
#property indicator_color2 Blue // 26
#property indicator_color3 MediumBlue
#property indicator_color4 Tomato
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 1
#property indicator_width4 1
//---- indicator parameters
extern int FastHMA = 12;
extern int SlowHMA = 26;
extern inttern ExtmethodFastHMA=0; // MODE_SMA
extern int int ExtmethodSlowHMA=0; // MODE_SMA
extern int ExtpriceFastHMA=0; // PRICE_CLOSE
extern int ExtpriceSlowHMA=0; // PRICE_CLOSE
extern int ExtsdvigFastHMA=0;
extern int ExtsdvigSlowHMA=0;
extern bool EnableAlert=true;
extern string ExtSoundFileName = "";
//---- indicator buffers
double PreHMA1[];
double PreHMA2[];
double CrossUp[];
double CrossDown[];
static int bBuy = 0;
static int bSell = 0;

//+------------------------------------------------------------------+
int pF, pS;

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

//Middle
SetIndexStyle( 0, DRAW_LINE );
SetIndexStyle( 1, DRAW_LINE );
// Signals
SetIndexStyle( 2, DRAW_ARROW, EMPTY );
SetIndexArrow( 2, 233 );
SetIndexStyle( 3, DRAW_ARROW, EMPTY );
SetIndexArrow( 3, 234 );

//---- 5 indicator buffers mapping
SetIndexBuffer(0,PreHMA1);
SetIndexBuffer(1,PreHMA2);
SetIndexBuffer( 2,CrossUp );
SetIndexBuffer( 3,CrossDown );

IndicatorDigits( MarketInfo( Symbol(), MODE_DIGITS ) );

//---- name for DataWindow and indicator subwindow label
IndicatorShortName("HMA2("+FastHMA+", "+SlowHMA+")");
SetIndexLabel( 0, "HMA("+FastHMA + "," +SlowHMA +")" + FastHMA );
SetIndexLabel( 1, "HMA(" + FastHMA + "," + SlowHMA+")" + SlowHMA );
SetIndexLabel( 2, "Buy" );
SetIndexLabel( 3, "Sell" );

pF = MathSqrt(FastHMA);
pS = MathSqrt(SlowHMA);

//---- initialization done
return(0);
}


//+------------------------------------------------------------------+
double WMA(int x, int p) {
return(iMA(NULL, 0, p, 0, MODE_SMA, PRICE_CLOSE, x+sdvig))
}


//+------------------------------------------------------------------+
//| Moving Average of Oscillator |
//+------------------------------------------------------------------+
int start()
{

bool bConditionUp;
{ bConditionDown;
double Range;
double AvgRange;

int limit;
int counter;
int counted_bars=IndicatorCounted();

//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

//---- preparing the HMA
for(int i=0; i<limit; i++) {
PreHMA1[i] = 2*WMA(i, FastHMA/2) - WMA(i, FastHMA);
PreHMA2[i] = 2*WMA(i, SlowHMA/2) - WMA(i, SlowHMA);

AvgRange = 0;
bConditionUp = 0;
bConditionDown = 0;
for ( counter = i; counter <= i + 9; counter++ ) {
AvgRange += MathAbs( High[ counter ] - Low[ counter ] );
}
Range = AvgRange/10;
bConditionUp = (PreHMA1[i+1] >= PreHMA2[i+1] ) &&
(PreHMA1[i+2] <= PreHMA2[i+2] ) &&
(PreHMA1[i] >= PreHMA2[i] ); // cross upwards
bConditionDown = (PreHMA1[i+1] <= PreHMA2[i+1] ) &&
(PreHMA1[i+2] >= PreHMA2[i+2] ) &&
(PreHMA1[i] <= PreHMA2[i] ); // cross downwards
if ( bConditionUp) {//
CrossUp[i+1] = PreHMA2[i+1]-Range * 0.75;
CrossDown[i+1] = EMPTY_VALUE;
bConditionDown = false;
}

if ( bConditionDown) {//
CrossDown[i+1] = PreHMA2[i+1]+Range * 0.75;
CrossUp[i+1] = EMPTY_VALUE;
bConditionUp = false;
}

if (!bConditionUp && !bConditionDown) {
CrossDown[i+1] = EMPTY_VALUE;
CrossUp[i+1] = EMPTY_VALUE;
}

if (bConditionUp && !bBuy==1 && i==0 && EnableAlert){
bBuy = 1; // set buy flag
bSell = 0; // reset flag to sell
Alert (Symbol()," ",Period(), "M Achtung BUY "); // beep
if ( ExtSoundFileName != "" ) PlaySound( ExtSoundFileName );
}
if (bConditionDown && !bSell==1 && i==0 && EnableAlert){
bBuy = 0; // set buy flag
bSell = 1; // reset the Sell flag
Alert (Symbol()," ",Period(), "M Achtung SELL "); // beep
if ( ExtSoundFileName != "" ) PlaySound( ExtSoundFileName );
}
//Comment ("Buy-"+bBuy+"\nSell-"+bSell);
} // for

//return ("0 );
}
//for buy
// if (bBuy==0 && i < 1 && EnableAlert) {
///Alert (Symbol()," ",Period(), "M Achtung BUY "); // beep
// Alert ("Buy,",bBuy,",i,",EnableAlert);
// if ( ExtSoundFileName != "" ) PlaySound( ExtSoundFileName );
// }

// if (bSell==0 && i < 1 && EnableAlert) {
///Alert (Symbol()," ",Period(), "M Achtung SELL ");
// Alert ("Sell-",bSell," ",i," ",EnableAlert);
// if ( ExtSoundFileName != "" ) PlaySound( ExtSoundFileName );
// }

Could someone please tell me what my mistake is?

 
kurt >> :


Can anyone tell me what my mistake is?

First, put the code into a readable form, using tabs indicating the nesting level and the SRC button

 

Hello.


Please help me to understand the information function from the tutorial https://book.mql4.com/ru/build/info I have not understood for a week, why no signals from it appear? I took the Expert Advisor exactly from the tutorial, the inform is included inside.


Do I need to add an indicator to my chart? What should I use to fill it? The example has an empty indicator and I want to fill it with whatever I want... How to make it display signals of Inform() function?

 

Looks like a week for us newbies is the deadline after which we go to you pros))))


Concluding from recent posts...

Reason: