Ganesan
December 12, 2019, 11:26am
#1
dear friends,
i want to counting bars in15minute chart current day only.
same as below Price at given bar Number
bc = BarCount - 1;
ago = 10; // bars ago
price = C; // price or O H L
price10 = 0;
if ( bc > ago ) {
price10 = price[ bc - ago ];
}
but i want first candle high low value & 5th candle high low value & 10th candle high low value.
thanks to help
fxshrat
December 12, 2019, 6:21pm
#2
i want first candle high low value & 5th candle high low value & 10th candle high low value.
You may do like this using modulo operator
function f_every_nth(start_cond, H_string, L_String, every_n, max_n) {
/// source at forum.amibroker.com
/// @link https://tinyurl.com/vw9k9ju
local i, bars, every_nth, cs, cond, num;
bars = BarsSince(start_cond)+1;
every_nth = bars % every_n == 0 AND bars <= max_n OR start_cond;
cs = SumSince(start_cond, every_nth) + 1;
num = floor(max_n/every_n) + 1;
for ( i = 1; i <= num; i++ ) {
cond = every_nth AND cs == i;
VarSet(H_string+i, ValueWhen(cond, H));
VarSet(L_String+i, ValueWhen(cond, L));
}
return num;
}
dn = DateNum();
new_day = dn != Ref(dn, -1);
num = f_every_nth(new_day, "HH", "LL", every_n = 5, max_n = 10);
Plot( C, "Price", colorDefault, styleBar );
Plot( new_day, "", colorRed, styleHistogram | styleOwnScale | styleDashed, 0, 1 );
for ( i = 1; i <= num; i++ ) {
Plot( VarGet("HH"+i), "HH"+i, colorGreen, styleStaircase );
Plot( VarGet("LL"+i), "LL"+i, colorRed, styleStaircase );
}
If you want to output at last day only then use LastValue for Plot. Do you get that one done yourself?
5 Likes
Ganesan
December 16, 2019, 1:39pm
#8
@fxshrat i am looking forward to your reply
Milosz
December 16, 2019, 2:59pm
#9
Ganesan:
we need to...
@Ganesan stop being pushy! This forum is a place where users respond only when they have time and if they decide to. Nobody here is forced to do anything. Fxshrat has already provided you with a code addressing your problem with a screenshot and explanation. So the first thing you should have done was responding with "Thank you" - but you didn't do that! Instead you simply wrote what else he needs to do... Fxshrat doesn't need to do anything because it is not his problem and because he has already helped you - which you didn't appreciate in any way.
5 Likes
Ganesan
December 16, 2019, 5:56pm
#10
sorry for the forced. i am more expecting the reply from @fxshrat ,
first of all thank you for quick response.
i will wait
any one help me.
Ganesan
December 17, 2019, 12:47pm
#11
dear friend,
i had try to add condition as below. i got some problem in the Tools>Code Check & Profit. could you please help
SAME_CANDLE_H = H == HighestSince( new_day, H);
num = f_every_nth(SAME_CANDLE_H, "HH", "HL", every_n = 5, max_n = 10);
Plot( C, "Price", colorDefault, styleBar );
Plot( new_day, "", colorRed, styleHistogram | styleOwnScale | styleDashed, 0, 1 );
for ( i = 1; i <= num; i++ ) {
Plot( VarGet("HH"+i), "HH"+i, colorGreen, styleStaircase );
Plot( VarGet("LL"+i), "LL"+i, colorRed, styleStaircase );
}
fxshrat
December 17, 2019, 4:58pm
#12
i got some problem
There is just one real problem... and that's your posts . That's the problem here.
Do you think people here have mind reading powers??? What is "problem"?
Code of post #2 has no problem.
Secondly the code you posted is incomplete!
And picture shows different code being used (e.g. two times call of "f_every_nth function" and other stuff).
Read thread about "How to ask good question" . It is pinned one.
Otherwise posts will be ignored.
BTW,
we need to first candle define 2 way.
Who is "we"? Are you the Borg from Star Trek looking for assimilation?
Sorry, I won't be your guest. I am flying other direction at warp 15.
2 Likes
Tomasz
December 18, 2019, 10:56am
#13
@Ganesan - please follow this advice: How to ask a good question If you post code, it must be complete code ready to be copy-pasted and run without ANY missing parts, undefined functions/variables/includes, etc.
1 Like