I have tried to create this function with the if,else but am having difficulty. I would like for the function to return the number of the "if" criteria that is meet back to the program using checkordertype () .
Is this type of function allowed using " if ,else ", as I am a newbie to functions would you please let me know if it is acceptable to use it this way ?
I have Checked using Alert that the Signalisbuy 1 /signalissell 2 does go to the function using Alerts. If I remove the parenthesis then it will return a number , which isn't useful for the criteria meet .
Thanks for any assistance.
Write down your code in a easy way to read how you do it it is awful
if you did it this way then it was more easy to see what happens
int checkordertype() { static int lastordertype=0; int result; if( signalisbuy==1 && signalisbuy !=lastordertype ) { lastordertype=signalisbuy; // here you make signalisbuy equal to lastordertype result =5; } else { if(signalisbuy==1 && signalisbuy==lastordertype) { result=6; //and result 5 you won't get } else { if(signalissell==2 && signalissell != lastordertype) { lastordertype=signalissell; //here you make signalsell equal to lastordertype result=7; } else { if(signalissell==2 && signalissell==lastordertype) { result=8; //and result 7 you won't get } } } } return(result); }
Write down your code in a easy way to read how you do it it is awful
if you did it this way then it was more easy to see what happens
int checkordertype() { static int lastordertype=0; int result; if( signalisbuy==1 && signalisbuy !=lastordertype ) { lastordertype=signalisbuy; result =5; } else if(signalisbuy==1 && signalisbuy==lastordertype) { result=6; } else if(signalissell==2 && signalissell != lastordertype) { lastordertype=signalissell; result=7; } else if(signalissell==2 && signalissell==lastordertype) { result=8; } return(result); }
And if you use else if as a single statement it becomes even easier to see.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have tried to create this function with the if,else but am having difficulty. I would like for the function to return the number of the "if" criteria that is meet back to the program using checkordertype () .
Is this type of function allowed using " if ,else ", as I am a newbie to functions would you please let me know if it is acceptable to use it this way ?
I have Checked using Alert that the Signalisbuy 1 /signalissell 2 does go to the function using Alerts. If I remove the parenthesis then it will return a number , which isn't useful for the criteria meet .
Thanks for any assistance.