- AbdelEl: I would appreciate it if someone clarifies what should I use to store these values.
Why do you think you need to store them at all? Just read the indicator for the M5 bar index you want.
Your code if((m==0||m==5||m==10||m==15||m==20||m==25||m==30||m==35||m==40||m==45||m==50||m==55) && (s==0))
Simplified if((m % 5==0 ) && (s==0))
Your code if((m==59||m==4||m==9||m==14||m==19||m==24||m==29||m==34||m==39||m==44||m==49||m==54) && (s==59))
Simplified if((m % 5 == 4 ) && (s==59))
- If s is seconds, what happens if there is no tick that second? What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart.
-
Why do you think you need to store them at all? Just read the indicator for the M5 bar index you want.
Your code Simplified Your code Simplified - If s is seconds, what happens if there is no tick that second? What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart.
Thank you for your reply. I took in consideration the simplified version in 2 and 3.
About 1, I need to store these three values because I compare the two previous values (for two previous candles) at that specific time with the actual value.
About 4, it doesn't pose a problem if there are no ticks that second.. all what matters is that I keep saving these three values like in the scenario.
Thank you!
Thank you for your reply. I took in consideration the simplified version in 2 and 3.
About 1, I need to store these three values because I compare the two previous values (for two previous candles) at that specific time with the actual value.
About 4, it doesn't pose a problem if there are no ticks that second.. all what matters is that I keep saving these three values like in the scenario.
Thank you!
I thought about what you said (@William Roeder) in point 1, I have tried to read the indicator as follows: (shift 1,2,3)
CurrentIndicator=iINDICATOR(NULL,PERIOD_M5,x,y,z,..,0); PreviousIndicator5m=iINDICATOR(NULL,PERIOD_M5,x,y,z,..,1); SecondPreviousIndicator5m=iINDICATOR(NULL,PERIOD_M5,x,y,z,..,2);
I tried to make sure if it shows the values as I want but it got me very confusing. I am not sure if the values stored in my variables are at the start of the candle or the last value recorded with the candle..
I will keep trying to figure it out and if found, I will reply to confirm :)
Kind regards
Always last unless your indicator is doing something unusual.
Always last unless your indicator is doing something unusual.
My query is solved. I simply used the shift in the indicator. It did the work without the need to calculate all that stuff..
Thank you @William Roeder.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
I am having a hard time writing the perfect code for what I want. Basically I have the following scenario:
I am trying to store current value=10, previous value=8 and the candle one last value=5.5. (Logic behind this: I work on 5min chart and I want to store candle's actual value, previous candle's last value, second previous candle's last value)
I have successfully coded for two values and I have been using it without problems however for three, I got confused as I don't know whether it's appropriate to use arrays or there are other better ways.. Below is what I coded:
I would appreciate it if someone clarifies what should I use to store these values.
Kind regards,
Abdel