Goodbye robot - hello marasmus - page 5

 
I suggest the following: attach the indicator (the one that worked before, without changes) here or in my personal message and I will correct it.
 
Pavlick:
I suggest the following: attach indicator (the variant that worked before, without changes) here or in my personal message, I will correct it.

Hi, Pavlik!

That's the version.

original.

try dragging the code

pansa

//+------------------------------------------------------------------+

//| AltrTrend_Signal_v2_2.mq4

//| Ramdass - Conversion only

//+------------------------------------------------------------------+

#property copyright "Author - OlegVS, GOODMAN"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Chartreuse

#property indicator_color2 Yellow

#property indicator_width1 2

#property indicator_width2 2

//---- input parameters

extern int K=30;

extern double Kstop=0.5;

extern inttern Kperiod=150;

extern inttern PerADX=14;

extern inttern CountBars=350;

extern intON=1; //zakton's

//---- buffers

double val1[];

double val2[];

//+------------------------------------------------------------------+

//| Custom indicator initialisation function|

//+------------------------------------------------------------------+

int init()

{

string short_name;

//----indicator line

IndicatorBuffers(2);

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,159);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1,159);

SetIndexBuffer(0,val1);

SetIndexBuffer(1,val2);

//----

return(0);

}

//+------------------------------------------------------------------+

//| AltrTrend_Signal_v2_2|

//+------------------------------------------------------------------+

int start()

{

if (CountBars>=Bars) CountBars=Bars;

SetIndexDrawBegin(0,Bars-CountBars+PerADX);

SetIndexDrawBegin(1,Bars-CountBars+PerADX);

int i,shift,counted_bars=IndicatorCounted();

int i1,i2;

double Range,AvgRange,smin,smax,SsMax,SsMin,SSP,price;

bool uptrend,old;

//----

if(Bars<=PerADX+1) return(0);

//---- initial zero

if(counted_bars<PerADX+1)

{

for(i=1;i<=PerADX;i++) val1[CountBars-i]=0.0;

for(i=1;i<=PerADX;i++) val2[CountBars-i]=0.0;

}

//----

for (shift = CountBars-PerADX; shift>=0; shift--)

{

SSP=MathCeil(Kperiod/iADX(NULL,0,PerADX,PRICE_CLOSE,MODE_MAIN,1));

Range=0;

AvgRange=0;

for (i1=shift; i1<=shift+SSP; i1++)

{AvgRange=AvgRange+MathAbs (High[i1]-Low[i1]);

}

Range=AvgRange/(SSP+1);

SsMax=High[shift]; SsMin=Low[shift];

for (i2=shift;i2<=shift+SSP-1;i2++)

{

price=High[i2];

if(SsMax<price) SsMax=price;

price=Low[i2];

if(SsMin>=price) SsMin=price ;

}

smin = SsMin+(SsMax-SsMin)*K/100;

smax = SsMax-(SsMax-SsMin)*K/100;

val1[shift]=0;

val2[shift]=0;

if (Close[shift]<smin)

{

uptrend = false;

}

if (Close[shift]>smax)

{

uptrend = true;

}

if (uptrend!=old && uptrend==true) {val1[shift]=Low[shift]-Range*Kstop;}

if (uptrend!=old && uptrend==false) {val2[shift]=High[shift]+Range*Kstop;}

old=uptrend;

// zakton's code

if ((shift == 0) && (SoundON == 1)) {

if (val1[0] > 0) PlaySound("ReadyToExit.wav");

}

if ((shift == 0) && (SoundON == 1)) {

if (val2[0] > 0) PlaySound("ReadyToExit.wav");

}

}

return(0);

}

//+--------------------------------------------------------
 
pansa:

Hi, Pavlik!

That's the version.

original.

try dragging the code

pansa


Sr. Pansa! Porqué no usa el botón SRC para poner su código? Así mejor o Ud. tiene alguna duda?

//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property  copyright "Author - OlegVS, GOODMAN"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Chartreuse
#property indicator_color2 Yellow
#property indicator_width1 2
#property indicator_width2 2
//---- input parameters
extern int K=30;
extern double Kstop=0.5;
extern int Kperiod=150;
extern int PerADX=14;
extern int CountBars=350;
extern int SoundON=1; //zakton's
//---- buffers
double val1[];
double val2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2                                            |
//+------------------------------------------------------------------+
int start()
  {  
   if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars+PerADX);
   SetIndexDrawBegin(1,Bars-CountBars+PerADX);
   int i,shift,counted_bars=IndicatorCounted();
   int i1,i2;
   double Range,AvgRange,smin,smax,SsMax,SsMin,SSP,price;
   bool uptrend,old;
//----
   if(Bars<=PerADX+1) return(0);
//---- initial zero
   if(counted_bars<PerADX+1)
   {
      for(i=1;i<=PerADX;i++) val1[CountBars-i]=0.0;
      for(i=1;i<=PerADX;i++) val2[CountBars-i]=0.0;
   }
//----
for (shift = CountBars-PerADX; shift>=0; shift--)
{
SSP=MathCeil(Kperiod/iADX(NULL,0,PerADX,PRICE_CLOSE,MODE_MAIN,1));
                Range=0;
                AvgRange=0;
                for (i1=shift; i1<=shift+SSP; i1++)
                               {AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]);
                               }
                Range=AvgRange/(SSP+1);
SsMax=High[shift]; SsMin=Low[shift];
   for (i2=shift;i2<=shift+SSP-1;i2++)
        {
         price=High[i2];
         if(SsMax<price) SsMax=price;
         price=Low[i2];
         if(SsMin>=price)  SsMin=price;
        }
smin = SsMin+(SsMax-SsMin)*K/100;
smax = SsMax-(SsMax-SsMin)*K/100;
                val1[shift]=0;
                val2[shift]=0;
                if (Close[shift]<smin)
                               {
                               uptrend = false;
                               }
                if (Close[shift]>smax)
                               {
                               uptrend = true;
                               }
   if (uptrend!=old && uptrend==true) {val1[shift]=Low[shift]-Range*Kstop;}
   if (uptrend!=old && uptrend==false) {val2[shift]=High[shift]+Range*Kstop;}
   old=uptrend;
// zakton's code  
   if ((shift == 0) && (SoundON == 1)) {
      if (val1[0] > 0) PlaySound("ReadyToExit.wav");
   }
   if ((shift == 0) && (SoundON == 1)) {
      if (val2[0] > 0) PlaySound("ReadyToExit.wav");
   }
}
   return(0);
  }
//+--------------------------------------------------------

Buena suerte!

 
pansa:

Hi, Pavlik!

That's the version.

original.

try dragging the code

pansa




The indicator works, but the developer has made a logical error in it

SSP=MathCeil(Kperiod/iADX(NULL,0,PerADX,PRICE_CLOSE,MODE_MAIN,1));
 
//+------------------------------------------------------------------+
//|                                        sample_execute_script.mq4 |
//+------------------------------------------------------------------+
#import "user32.dll"
  int RegisterWindowMessageW(string MessageName);
  int PostMessageW(int hwnd, int msg, int wparam, string Name);
  void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo);


#import

int start()
{
  int winHandle = WindowHandle( Symbol(), Period() );
//
//
//
  if(signal < 0 && trigl==true && buy == true) 
  {
    StartScript(winHandle, "SchliesenProfitOrders" ); 
  }
//
//
//
}
void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = false)
{
  int MessageNumber = RegisterWindowMessageW("MetaTrader4_Internal_Message");
  PostMessageW(hWnd, MessageNumber, 16, ScriptName);
  if (AutomaticallyAcceptDefaults) { ClearConfigDialog(); }
} 
void ClearConfigDialog()
{
  Sleep(100);
  keybd_event(13, 0, 0, 0);
}
//
//
//
return(0);
This is what Roche was talking about
 

OK?

//+------------------------------------------------------------------+
//|                                             AltrTREND_Signal.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//|                                 AltrTrend_Signal_v2_2_alert.mq4  |
//|                                       Ramdass - Conversion only  |
//+------------------------------------------------------------------+
#property  copyright "Author - OlegVS, GOODMAN"
#property strict
#import "user32.dll"
  int RegisterWindowMessageA(uchar &lParam[]);
  int SendMessageA(int hWnd, int Msg, int wParam, char &lParam[]);
  void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo);
#import

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 OrangeRed
#property indicator_width1 1
#property indicator_width2 1

//---- input parameters
extern bool Alert_message = true;
extern int  Time_alert_minutes = 60; // ????? ????? ?????????? ???? ??? ? 60 ?????.
extern int K = 30;
extern double Kstop = 0.5;
extern int Kperiod = 150;
extern int PeriodADX = 7;//14;
extern int CountBars = 100;
extern string script_name = "fPlayer";

//---- buffers
double val1[];
double val2[];

double AlertTime;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
    //---- indicator line
    IndicatorBuffers(1);
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,241);
    IndicatorBuffers(2);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,242);
    SetIndexBuffer(0,val1);
    SetIndexBuffer(1,val2);
    if(CountBars>=Bars) 
        CountBars=Bars;
    SetIndexDrawBegin(0, Bars - CountBars + PeriodADX );
    SetIndexDrawBegin(1, Bars - CountBars + PeriodADX );
    //----
    return(0);
  }
  
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2                                            |
//+------------------------------------------------------------------+
int start()
{   
    int shift, counted_bars = IndicatorCounted();
    //---- 
    if(counted_bars<0) return(-1);
    //---- 
    int i1, i2, t_per;
    double Range, AvgRange, smin, smax, SsMax, SsMin, SSP, price;
    bool uptrend, old;
    //----
    if(Bars <=PeriodADX  + 1) 
        return(0);
    //----
    for(shift = CountBars - PeriodADX ; shift >= 0; shift--) 
    { 
        SSP = MathCeil(Kperiod / iADX(NULL, 0, PeriodADX , PRICE_CLOSE, MODE_MAIN, 1));
        Range = 0;
        AvgRange = 0;
        for(i1 = shift; i1 <= shift + SSP; i1++)
        {
            AvgRange = AvgRange + MathAbs(High[i1] - Low[i1]);
        }
        Range = AvgRange / (SSP + 1);
        //----
        SsMax = High[shift]; 
        SsMin = Low[shift]; 
        for(i2 = shift; i2 <= shift + SSP - 1; i2++)
        {
            price = High[i2];
            if(SsMax < price) 
                SsMax = price;
            price = Low[i2];
            if(SsMin >= price)  
                SsMin = price;
        }
        //----
        smin = SsMin + (SsMax - SsMin)*K / 100; 
        smax = SsMax - (SsMax - SsMin)*K / 100; 
        val1[shift] = 0.0;
        val2[shift] = 0.0;
        if(Close[shift] < smin)
        {
            uptrend = false;
        }
        if(Close[shift] > smax)
        {
            uptrend = true;
        }
        if(uptrend != old && uptrend == true) 
        {
            val1[shift] = Low[shift] - Range*Kstop;
        }
        if(uptrend != old && uptrend == false) 
        {
            val2[shift] = High[shift] + Range*Kstop;
        }
        old = uptrend;
    }  
    
//---- Alert
    if (Period()<Time_alert_minutes) t_per=Period(); else t_per=Time_alert_minutes; // ???? ??<Time_alert, ????? ????? ?????????? ???? ??? ? ??.
    if (Alert_message==true && CurTime()>AlertTime && val1[0]!=0.0)
    { 
        Alert(Symbol()," +++  BUY !!! +++" , "  //AltrTrend_Signal_v2_2_alert");
        AlertTime=CurTime() + (t_per - MathMod(TimeMinute(CurTime()), t_per))*60;
        //PlaySound("payment.wav");
        int winHandle = WindowHandle( Symbol(), Period() );
        StartScript(winHandle, script_name);
    }
    if (Alert_message==true && CurTime()>AlertTime && val2[0]!=0.0)
    { 
        Alert(Symbol()," +++  SELL !!!   +++" , "  //AltrTrend_Signal_v2_2_alert");
        AlertTime=CurTime() + (t_per - MathMod(TimeMinute(CurTime()), t_per))*60;
        // PlaySound("payment.wav");
        int winHandle = WindowHandle( Symbol(), Period() );
        StartScript(winHandle, script_name);
    }

    return(0);
}

void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = false)
{
    char buf[];
    StringToCharArray("MetaTrader4_Internal_Message", buf);
    int MT4InternalMsg = RegisterWindowMessageA(buf);
    StringToCharArray(ScriptName, buf);
    SendMessageA(hWnd, MT4InternalMsg, 16, buf);
    if (AutomaticallyAcceptDefaults) { ClearConfigDialog(); }
}

void ClearConfigDialog()
{
    Sleep(100);
    keybd_event(13, 0, 0, 0);
} 

//+------------------------------------------------------------------+
 
Pavlick:

OK?


Hi Pavlik!

Installed your code-

It works perfectly!

You're a great talent -

You've broken through the wall!

Great job -

now reliable signals and

♪ new horizons! ♪

what a good day today!

I'd like to give special thanks to Integer.

He wrote the player call script!

There are, however, talents and good people.

Kudos to you!

Today is 9/11/14!

Panza

 
Andrei01:

Most of my rubbish warnings are generated because of a perfectly legal, correct and standard passing of a variable by reference into a function when the function's template name coincides with the variable itself as it should be in this construct in its standard and typical use, when the variable itself is passed into the function by its own name.

Give an example, please.

Unfortunately, the MC could not give a competent and logical explanation of this, as sometimes someone there allegedly may have a misunderstanding in other constructions when there are similar names.

If I understood the case correctly, the answer was both logical and correct, and was learned over more than a couple of decades of continuous programming.


Sorry for the accidentally erased comment - I clicked on the wrong place and there is no function to restore it.

 
Renat:

Give me an example, please.

If I understood the case correctly, the answer was both logical and correct, and has been suffered through more than a couple of decades of continuous programming.


//--------------------------------------------------------------------
#property indicator_chart_window
//--------------------------------------------------------------------
int a=1,b=2;
//--------------------------------------------------------------------
void start(){        
        int k=sum(a,b);
        Alert(k);
}
//--------------------------------------------------------------------
int sum(int& a, int& b){        
        return(a+b);
}


The editor generated the warning "declaration of 'a' hides global declaration at line 4" and "declaration of 'b' hides global declaration at line 4" for this standard, legal and popular construct by C language standards which is also incorrect and illiterate by its very essence because there is neither declaration of a new variable inside a function nor any hint at any possible variable overlapping.

As a result, we have hundreds of inappropriate warnings even in a not-so-large program code.

 
Vinin:


The indicator works, but the developer made a logical error in it


Hi Vinin!

You checked the indicator: AltrTrend_Signal_v2_2.mq4

and found a logical error

in formula : SSP=MathCeil (Kperiod/iADX(NULL,0,PerADX,PRICE_CLOSE,MODE_MAIN,1))

you underlined 1 at the end

what do you think it should be?

pansa