Debugging Formula for Intraday Low

I am trying to program a code in which it can detect a signal making intraday day's low, but my present signal considering its previous day's value too, so some signals are not being detected. Please help


_SECTION_BEGIN(" Line Calculations");

 dn =  DateNum();
 newDay = dn != Ref( dn,-1);

count = BarsSince(newDay!= Ref(newDay,1))+1;
daych=Day()!=Ref(Day(),-1);

prl=Ref(LLV(Low,count)-1,-1);
llbr=IIf(Low<prl,1,0);	
stkprice=IIf(L>150 AND L<1900,1,0);	

tm=IIf(TimeNum()>=093500 AND TimeNum()<=103000,1,0);

cond=IIf( llbr AND stkprice AND tm ,1,0);

PlotShapes(IIf(cond, shapeDownArrow, shapeNone),colorYellow, 0,H, Offset=-30);
Filter=cond;

AddColumn( DateTime(), "Date /mmhhss Time", formatDateTime );

AddColumn(L,"ShortPrice",1.2,colorRed);
_SECTION_END();

_SECTION_BEGIN(" Price");
Plot(C, "", IIf(C>O,colorBrightGreen, colorRed), styleCandle,2);
Title =StrFormat("{{DATE}} Op %g, Hi %g, Lo %g, Cl %g (%.1f%%) ",O,H,llbr,V, SelectedValue( ROC(C,1)) )+EncodeColor(colorBlack);
_SECTION_END();

The way I compute Low of the day is like this:

DL = TimeFrameGetPrice("L", inDaily, 0);
// Day Low, thats all.

NearPc = 0.002;    // Sensitivity
// Percentage of how near LAST Price is to Low

LPc = (1 - DL/C) * 100;
// Actual pc from Low

SigL = (C - DL) < (NearPc * C);

Filter = SigL;

AddColumn( LPc, "L%", 1.2);

Now you just need to adjust NearPc to see get scrips near DL because you cant have L == C all the time.

Thanks, your solution solved my problem but partially.
I was looking for an event candle of breaking low since 09:15 am of a day.
So that I can Explorer for any past days too, because as you know TimeFrameGetPrice("L", inDaily, 0); works for only day low,
while I am looking for== breaking low since 09:15 am of that day so it might break low many times in a day since 09:15 am. Hope you getting what I want to say.
Thanks!

My code was actually not a solution but just a pointer of what i'd do because price tends to hover around a zone, say a Low or High (or support / Resistance) etc but in intraday, its beter to keep an eye on the price near those levels for those symbols.

You've posted what you are looking for but its still not clear. this part

Is it a candle that breaks the 9:15 BAR low ?
bcos in your code, your looking for a window between 9:35 and 10:30.

Just do the whole thing in detail with a snapshot so there aren't any doubts.

Sorry, I changed my time window in above questions.
Actually I am looking for a red candle close or low breaking low since 09:15...
And... I need to look it up in a window of say 09:35 to 10:30.
Means I am looking for a scrip candle breaking low in window of 09:35 to 10:30 and the low will be of lowest since 09:15 am.

@shivam_singh similar topic is covered in the Knowledge Base article and on this forum. This information should help you solve your problem.

Hi,
I am still looking for the solution.
I am looking for a red candle, say: hammer shape, who's low breaking low of all candles since 09:15.
This is what I am trying to code. Plz advice.
Thanks !

Here is sample code (you need to insert your formula for hammer in first line)
I used new day as start.
If you want start at 9:15 then uncomment
start = TimeNum() == 091500;
of below code

/// @link https://forum.amibroker.com/t/debugging-formula-for-intraday-low/10932/8
hammer = /*your formula for hammer here */;

redcandle = C < O AND hammer;// hammer and red candle

// new day flag
dn = DateNum();
newday = dn != Ref( dn, -1);

// start flag (either new day flag or time flag)
start = newday;
//start = TimeNum() == 091500;

// Lowest since start
ll = LowestSince(newday, L);

// true if red candle and candle low lower than 
// prev. bar's lowest low since start
ll_break = redcandle AND L < Ref(ll,-1);

// Plot
Plot( C, "Price", colorDefault, styleCandle );
PlotShapes( ll_break * shapeSmallSquare,  colorRed, layer = 0, y = H, 20 );

And here is picture

Thanks! but this code you gave above is not showing any signal when I explore.

You have been handed a good working code on silver platter.
You need to tweak the rest and Add Columns or filter for Exploration.

1 Like

Grrrr.....
Read here https://www.amibroker.com/guide/h_exploration.html
Please show some effort(s) on your own!

!!!

The code works!
And if you add Exploration code then it will work also.

And if you get working code then hit thanks button (to distinguish contributors from non contributors in user list).
And if a topic is solved (which it is) then you hit solution button.
And if wanting to ask a question then read here before.
I am not accepting lazy copy&paste artistry anymore.
Begging for code, copy&pasting code, not reading forum rules... what else?


As aside.... replacing

ll = LowestSince(newday, L);

with

ll = LowestSince(start, L);

/// @link https://forum.amibroker.com/t/debugging-formula-for-intraday-low/10932/12
hammer = /*your formula for hammer here */;

redcandle = C < O AND hammer;// hammer and red candle

// new day flag
dn = DateNum();
newday = dn != Ref( dn, -1);

// start flag (either new day flag or time flag)
start = newday;
//start = TimeNum() == 091500;

// Lowest since start
ll = LowestSince(start, L);

// true if red candle and candle low lower than 
// prev. bar's lowest low since start
ll_break = redcandle AND L < Ref(ll,-1);

// Plot
Plot( C, "Price", colorDefault, styleCandle );
PlotShapes( ll_break * shapeSmallSquare,  colorRed, layer = 0, y = H, 20 );

/// YOUR Exploration code here below....
3 Likes