Never try array?
deysmacro:
Never try array?
Never try array?
Yes, it is an array. GapStep[10].
but how can I fill it using less lines?
c3po: fibonacci steps - 8,12,18,27, these blocks take up way too many lines.
gapstep[1] = firstgap; gapstep[2] = gapstep[1] + gapstep[1]/2; gapstep[3] = gapstep[2] + gapstep[1]; gapstep[4] = gapstep[3] + gapstep[2]; :
Your code doesn't generate 8,12,18,27 it generates 8,12,20,32- Use a for loop
gapstep[1] = firstgap; gapstep[2] = gapstep[1] + gapstep[1]/2; gapstep[3] = gapstep[2] + gapstep[1]; gapstep[4] = gapstep[3] + gapstep[2]; gapstep[5] = gapstep[4] + gapstep[3]; gapstep[6] = gapstep[5] + gapstep[4]; gapstep[7] = gapstep[6] + gapstep[5]; gapstep[8] = gapstep[7] + gapstep[6]; gapstep[9] = gapstep[8] + gapstep[7];
gapstep[1] = firstgap; gapstep[2] = gapstep[1] + gapstep[1]/2; for(int i=3; i<10 ++i) gapstep[i] = gapstep[i-2] + gapstep[i-2];
gapstep[1] = firstgap; gapstep[2] = gapstep[1] * 2; gapstep[3] = gapstep[2] * 2; gapstep[4] = gapstep[3] * 2; gapstep[5] = gapstep[4] * 2; gapstep[6] = gapstep[5] * 2; gapstep[7] = gapstep[6] * 2; gapstep[8] = gapstep[7] * 2; gapstep[9] = gapstep[8] * 2;
gapstep[1] = firstgap; for(int i=2; i<10; ++i) gapstep[i] = gapstep[i-1] * 2;
- If the firstgap was a constant 8 you could just create a constant array
int gapStep[]={8,12,20,32...} int gapStep[]={8,16,32,64...}
- For variable size use firstgap * step[]
double step[]={1, 1.5, 2.5, 4.0...}; //*8=8,12,20,32... int step[]={1, 2, 4, 8...}; //*8=8,16,32,64...
WHRoeder:
- Your code doesn't generate 8,12,18,27 it generates 8,12,20,30
- Use a for loop
Oh i had a little miscalculation in my example, but you understood the principle i was looking for, Thank you so much WHR.
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, I made this code to create increasing gaps between next orders.
Can someone help me understand how to compact this? Thank you as always I appreciate it.
(ps i intentionally left out index 0 in the examples)