Give the correct variable

To add comments, please log in or register
Naqibjan
44
Naqibjan  
I got a little confused on this indicator I can't get the right values
And the expert does not emit any signal
I asked the programmers for guidance on this
Thanks everyone
//+------------------------------------------------------------------+


extern int       MaPeriod         = 20;           // Hama ma period
extern bool      alertsOn         = false;        // Turn alerts on?
extern bool      alertsOnCurrent  = true;         // Alerts on current (still opened) bar?
extern bool      alertsMessage    = true;         // Alerts should show pop-up message?
extern bool      alertsSound      = false;        // Alerts should play alert sound?
extern bool      alertsNotify     = false;        // Alerts should send push notification?
extern bool      alertsEmail      = false;        // Alerts should send email?
extern string    soundFile        = "alert2.wav"; // Alerts sound file to use
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
double b1_shift1=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,0,1);
double b1_shift2=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,1,1);
double b1_shift3=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,2,1);
double b1_shift4=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,3,1);
double b1_shift5=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,4,1);
double b1_shift6=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,5,1);

double b2_shift1=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,0,2);
double b2_shift2=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,1,2);
double b2_shift3=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,2,2);
double b2_shift4=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,3,2);
double b2_shift5=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,4,2);
double b2_shift6=iCustom(Symbol(),0,"HamaSystem",MaPeriod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsNotify,alertsEmail,soundFile,5,2);


Comment(b1_shift1,"\n",b1_shift2,"\n",b1_shift3,"\n",b1_shift4,"\n",b1_shift5,"\n",b1_shift6,
           "\n",b2_shift1,"\n",b2_shift2,"\n",b2_shift3,"\n",b2_shift4,"\n",b2_shift5,"\n",b2_shift6);

if(Volume[0]<=1)
{
  if(b1_shift1!=1 && b2_shift1==1)
 {
  Alert("buy signal");
  Print("buy signal");
  }
 if(b1_shift2!=1 && b2_shift2==1)
 {
  Alert("sell signal");
  Print("sell signal");
  }
 }

   return(0);
  }
//+------------------------------------------------------------------+

values

Mladen Rakic
148074
Mladen Rakic  

Why do you thing that b2_shift1 or b2_shift2 will ever be 1? It will (in 99.9999999999999999999% of cases) not

Check your conditions and what exactly you are comparing

Naqibjan
44
Naqibjan  
Mladen Rakic:

Why do you thing that b2_shift1 or b2_shift2 will ever be 1? It will (in 99.9999999999999999999% of cases) not

Check your conditions and what exactly you are comparing

Dear Mladen,

My problem is with this parameter
I have used everything I remember but no signal

  if(b1_shift1!=1 && b2_shift1==1)
 {
  Alert("buy signal");
  Print("buy signal");
Mladen Rakic
148074
Mladen Rakic  
Naqibjan:

Dear Mladen,

My problem is with this parameter
I have used everything I remember but no signal

Please read my previous answer to you
Naqibjan
44
Naqibjan  
Mladen Rakic:
Please read my previous answer to you

I read your text, dear friend
I want to compare color # 0 with color # 1
And whenever the color values in the first and second candles are ignored, a warning is issued
But I can't believe the values
I just tried numbers # 1 but I know that's not right

color

Mladen Rakic
148074
Mladen Rakic  
Naqibjan:

I read your text, dear friend
I want to compare color # 0 with color # 1
And whenever the color values in the first and second candles are ignored, a warning is issued
But I can't believe the values
I just tried numbers # 1 but I know that's not right

Where in the data window you ever saw value 1?

I shall repeat : check your conditions since none of those values will ever be 1. I rest my case now

William Roeder
19628
William Roeder  
if(Volume[0]<=1)
{
  if(b1_shift1!=1 && b2_shift1==1)
  1. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              New candle - MQL4 programming forum

  2. Doubles are rarely equal. Understand the links in:
              The == operand. - MQL4 programming forum
Naqibjan
44
Naqibjan  
William Roeder:
  1. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              New candle - MQL4 programming forum

  2. Doubles are rarely equal. Understand the links in:
              The == operand. - MQL4 programming forum

I have this function

if(b1_shift1!=1 && b2_shift1==1)

I used this function instead

if (MathAbs(b1_shift1 - b2_shift1) < Point / 2)


But the wrong signals give too much attention to the photo
Am I wrong again?

worong
I'm new to programming

Seng Joo Thio
1104
Seng Joo Thio  
Naqibjan:

I have this function

I used this function instead

But the wrong signals give too much attention to the photo
Am I wrong again?

Given that buffers 0 and 1 should be a histogram, to identify color change, you can just do this:

      if (b1_shift1>b2_shift1 && b1_shift2<b2_shift2)
         // Sell;
      if (b1_shift1<b2_shift1 && b1_shift2>b2_shift2)
         // Buy;
PS. Earlier comments on comparing doubles are all valid, and your attempt to compare them in post #7 is correct. But to achieve your objective, you need not deal with their equality...  
Naqibjan
44
Naqibjan  
Seng Joo Thio:

Given that buffers 0 and 1 should be a histogram, to identify color change, you can just do this:

PS. Earlier comments on comparing doubles are all valid, and your attempt to compare them in post #7 is correct. But to achieve your objective, you need not deal with their equality...  

Hi dear friend
I realized my mistake
I should have compared the colors, not the candles
Thank you dear friend
.

(Your cod is working Good)

To add comments, please log in or register