icustom + while function need correction

 

Hello,

Could you please help me to correct the following ea :


double MHLong = iCustom(NULL,0,"Indicator",1000,1,0);

double MHShort = iCustom(NULL,0,"Indicator",1000,0,0); 


check 4last candles to know if indicator is long or short :

  int i =0;

   while(i<=4)
{
    Print(i);
    i++;

}


if MHLong = true ; trade allowed

if MHshort = true ; trade allowed


Thanks for your help

 
fredofrompaca:

Hello,

Could you please help me to correct the following ea :

<CODE DELETED>

Please read some other posts before posting . . .

Please edit your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 

 
fredofrompaca:

Hello,

Could you please help me to correct the following ea :

MHLong and MHshort are double type not bool . . . so this makes no sense . . .

if MHLong = true ; trade allowed

if MHshort = true ; trade allowed

  . .  don't think you can just change the type from double to bool . . . that won't help,  iCustom() returns a double.

 

thanks Raptor.

To be honest with my main problem for the moment is to try to understand how the information is linked between

double MHLong = iCustom(NULL,0,"Indicator",1000,1,0);

double MHShort = iCustom(NULL,0,"Indicator",1000,0,0); 

and

 int i =0;

   while(i<=4)
{
    Print(i);
    i++;

} 

 I mean how the last shift of my MHLong and MHshort will be changed thanks to the reaserch in the 4 last candles.

I hope you will understand what I mean, English is not my mother tongue

 
fredofrompaca:

thanks Raptor.

To be honest with my main problem for the moment is to try to understand how the information is linked between

and

 I mean how the last shift of my MHLong and MHshort will be changed thanks to the reaserch in the 4 last candles.

I hope you will understand what I mean, English is not my mother tongue


There is no link at all.  You call iCustom()  twice and then your loop happens . . .  perhaps your iCustom() calls should go in you loop and you should use  i  for the shift (last parameter)  in the iCustom call ?  it's a little hard to know as you haven't said what it is that you are trying to achieve.
 

So, my strategy is based on 4 indicators (RSI, MACD, volatilty and one indicator arrow.)

As you know,all indicators don't switch in the same time, in the same way.

That's the reason why I would keep in mind what was the last sense of the arrow.

Once the 3 other indicators go for a long trade, I would get the finale confirmation from arrow that's this trade is allowed.


Is it clearer for you ?

 int i =0;

   while(i<=4)
{
    Print(i);
    i++;
    
  double MHLong = iCustom(NULL,0,"Arrows_mh",1000,0,i); 
  double MHShort = iCustom(NULL,0,"Arrows_mh",1000,1,i); 
} 
   
 
fredofrompaca: Is it clearer for you ?
The question is it clearer for you? You get the long/short of shift i, but do nothing with them.
 

Yes I do something with :

For the long :

     if (MHLong != EMPTY_VALUE && MHLong != 0)&& (MHShort == 0 || MHShort == EMPTY_VALUE ) &&  

for the short :

     if (MHShort != EMPTY_VALUE && MHShort != 0)&& (MHLong == 0 || MHLong == EMPTY_VALUE ) &&
 
fredofrompaca:

So, my strategy is based on 4 indicators (RSI, MACD, volatilty and one indicator arrow.)

As you know,all indicators don't switch in the same time, in the same way.

That's the reason why I would keep in mind what was the last sense of the arrow.

Once the 3 other indicators go for a long trade, I would get the finale confirmation from arrow that's this trade is allowed.


Is it clearer for you ?

Explain what the loop is for ?
 

Hello,

I am arrived to fix the problem about the icustom.

i++ was before the icustom. Please find below the solution.

 int i =0;

   while(i<=4)
{
    Print(i);
    
  double MHLong = iCustom(NULL,0,"Arrows_mh",1000,0,i); 
  double MHShort = iCustom(NULL,0,"Arrows_mh",1000,1,i); 

i++;
} 


Something looks odd, when my ea run without this new indicator, ie positions are opened thanks  rsi, macd et volatilitY:

if RSI = true &&
   macd = true &&
   volatilité = true &&
=> trade allowed 

I have a first trade at 15h30.


whereas, when my indicators MHShort and MHLong are added to the above one :

for the  shorts
if     (MHShort ~ EMPTY_VALUE && MHShort ~ 0)
for the long
if     (MHLong ~ EMPTY_VALUE && MHLong ~ 0) 


my trade is opened at 14h00. It didn't take in account all the condition for the opening (in this case the volatility index was not enough strong).

Do you have an idea of what could happened ?


 
Stop posting isolated snippets of code - we are not mind readers. Your loop does nothing with MHLong/short. Your last post isn't even MQL4 code.
Reason: