the counter is reset every time the start function is called.
2 solutions
1) set the counter static
int start() { static int Counter=0; if ( IsTradeAllowed() ) { Counter=Counter+1; Print("Counter = ",Counter); } return(0); }
2) set the counter global
int Counter = 0; int start(){ if ( IsTradeAllowed() ) { Counter=Counter+1; Print("Counter = ",Counter); } return(0); }
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
Hello,
i want to write a simple code that prints out the value of a counter variable that starts at zero and then counts upwards by 1 each time a tick comes through. My code does not work for some reason and i am stuck. here is the code i'm using:
int start()
{
int Counter;
if ( IsTradeAllowed() ) {
Counter=Counter+1;
Print("Counter = ",Counter);
}
return(0);
}
Thanks in advance to any one that can help me write this simple code.
Regards
Rod