Declare the variable as a static or global variable
Keith Watford:
Declare the variable as a static or global variable
Sorry, but do i do that?
Declare the variable as a static or global variable
JRFerreira: Sorry, but do i do that?
| Perhaps you should read the manual. |
I already did that, but the issue maintains. That's why i ask how could i do that.... The issue is that if the next candle don't equals that function, returns 0 and not the value that it should have (1 or 2), until it reach the other function.
static int Flag;
if(iEnvelopes(NULL,0,14,MODE_SMA,0,PRICE_CLOSE,Deviation,MODE_LOWER,1)>Close[1] ){
Flag = 1;
}
if (Flag == 1)
{
....
}
if(iEnvelopes(NULL,0,14,MODE_SMA,0,PRICE_CLOSE,Deviation,MODE_UPPER,1)<Close[1]){
Flag = 2;
}
if (Flag == 2 )
{
.....
}
return (Flag);
Comment("Flag: "+Flag);
if(iEnvelopes(NULL,0,14,MODE_SMA,0,PRICE_CLOSE,Deviation,MODE_LOWER,1)>Close[1] ){
Flag = 1;
}
if (Flag == 1)
{
....
}
if(iEnvelopes(NULL,0,14,MODE_SMA,0,PRICE_CLOSE,Deviation,MODE_UPPER,1)<Close[1]){
Flag = 2;
}
if (Flag == 2 )
{
.....
}
return (Flag);
Comment("Flag: "+Flag);
static int Flag=0;
if( iEnvelopes(NULL,0,14,MODE_SMA,0,PRICE_CLOSE,Deviation,MODE_LOWER,1)>Close[1] )
{
if(Flag == 1)
return(0);
else
{
Flag=1;
//Anything else that you may want to do when Flag is reset
return(1);
}
}
if(iEnvelopes(NULL,0,14,MODE_SMA,0,PRICE_CLOSE,Deviation,MODE_UPPER,1)<Close[1])
{
if (Flag == 2 )
return(0);
else
{
Flag = 2;
//Anything else that you may want to do when Flag is reset
return(2);
}
}
Hi Keith,
I think that it worked. Thanks a lot!

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi there,
I need some help. How can i put a value on a variable, and chage it when a new signal shows?
Let me explain a little bit more:
I have this code...
Flag = 1;
}
and i want that Flag = 1 until happens this (and vise versa):
Flag = 2;
The problem is that it only put 1 or 2 if the last bar is bigger/slower than the Envelopes channels indi, and i need it to maintain the value until it pass to 2 (if Flag = 1) or vise versa.
How can i do that?
Thanks in advance,
Regards and good trading