Code for first bar of the day

murthyavr

Well-Known Member
#1
I want to plot yesterday's close on current day's intra-day chart.

And I want only the latest previous close to be plotted, across current day's candles.

I have written the code like this:

-----------------------------------------------------------------------
Coy=TimeFrameGetPrice( "C", inDaily, -1 );

Ccolor=ParamColor("COY Color",ColorRGB(0,128,255));

x0=LastValue(BarIndex())-75;
x1=LastValue(BarIndex());
y0=LastValue(Coy);
y1=LastValue(Coy);

Line = LineArray( x0, y0, x1, y1, 1 );
Plot( Line, "PrevClose", Ccolor,styleNoLabel );
-----------------------------------------------------------------------

I wrote the above code, compromising on the value of x0, to make it somehow
work. Actually, i need the line to start with the first candle of the current day.

1. How should I modify the code to get the value of the variable x0, so that it
represents the first bar of current day?

2. Is it possible to plot the line beyond the last candle on the chart?

Thanks..
 
#2
I want to plot yesterday's close on current day's intra-day chart.

And I want only the latest previous close to be plotted, across current day's candles.

I have written the code like this:

-----------------------------------------------------------------------
Coy=TimeFrameGetPrice( "C", inDaily, -1 );

Ccolor=ParamColor("COY Color",ColorRGB(0,128,255));

x0=LastValue(BarIndex())-75;
x1=LastValue(BarIndex());
y0=LastValue(Coy);
y1=LastValue(Coy);

Line = LineArray( x0, y0, x1, y1, 1 );
Plot( Line, "PrevClose", Ccolor,styleNoLabel );
-----------------------------------------------------------------------

I wrote the above code, compromising on the value of x0, to make it somehow
work. Actually, i need the line to start with the first candle of the current day.

1. How should I modify the code to get the value of the variable x0, so that it
represents the first bar of current day?

2. Is it possible to plot the line beyond the last candle on the chart?

Thanks..


Sir
first of all I am great fan of your VWAP Afl ..

You can try this Afl .....
In this Afl You can get Open, High, low ,Close everything ....on a day
And if you want previous day Close price then change 2nd last line of this Afl

ThisPlot = TimeFrameGetPrice(ThisPrice, TF); to

ThisPlot = TimeFrameGetPrice(ThisPrice, TF, -1);



I got this On TJ ...
http://www.traderji.com/amibroker/74893-afl-expert-plz-help-me.html


Regards
AnAtheist:)

the code is

Code:
ThisTF    = ParamList("TimeFrame", "Daily|Weekly|Monthly");
ThisPrice = ParamList("Price", "O|H|L|C", 3);
ThisColor = ParamColor("Color", colorBlue);
ThisStyle = ParamStyle("Style", styleNoLabel|styleDots|styleNoLine, maskAll);

switch (ThisTF)
{
  case "Monthly": 
        TF = inMonthly; 
        ThisTitle = "M_";
        break;
  case "Weekly":  
        TF = inWeekly; 
        ThisTitle = "W_";
        break;
  
   default:
       TF = inDaily; 
       ThisTitle = "D_";
       break;
}

ThisTitle = ThisTitle + ThisPrice;
ThisPlot = TimeFrameGetPrice(ThisPrice, TF); 
Plot(ThisPlot, ThisTitle,  ThisColor, ThisStyle);
 
Last edited:
#3
Code:
Plot(myLine=IIf(DateNum()==SelectedValue(DateNum()),TimeFrameGetPrice("C",inDaily,-1),Null),"yHoD",colorDarkGreen,styleThick);
Enjoy!



EDIT:to plot the line beyond the last candle on the chart, add this code


Code:
Plot(myLine,"",colorDarkGreen,styleThick|styleNoLabel,0,0,10);
 
Last edited:

murthyavr

Well-Known Member
#5
Sir You can try this Afl .....

I got this On TJ ...
http://www.traderji.com/amibroker/74893-afl-expert-plz-help-me.html


Regards
AnAtheist:)

the code is

Code:
ThisTF    = ParamList("TimeFrame", "Daily|Weekly|Monthly");
ThisPrice = ParamList("Price", "O|H|L|C", 3);
ThisColor = ParamColor("Color", colorBlue);
ThisStyle = ParamStyle("Style", styleNoLabel|styleDots|styleNoLine, maskAll);

switch (ThisTF)
{
  case "Monthly": 
        TF = inMonthly; 
        ThisTitle = "M_";
        break;
  case "Weekly":  
        TF = inWeekly; 
        ThisTitle = "W_";
        break;
  
   default:
       TF = inDaily; 
       ThisTitle = "D_";
       break;
}

ThisTitle = ThisTitle + ThisPrice;
ThisPlot = TimeFrameGetPrice(ThisPrice, TF); 
Plot(ThisPlot, ThisTitle,  ThisColor, ThisStyle);
Thank you very much..

The code offers to plot closing prices of different time frames also.

Thanks a lot!
 

casoni

Well-Known Member
#8
I want to plot yesterday's close on current day's intra-day chart.

And I want only the latest previous close to be plotted, across current day's candles.

I have written the code like this:

-----------------------------------------------------------------------
Coy=TimeFrameGetPrice( "C", inDaily, -1 );

Ccolor=ParamColor("COY Color",ColorRGB(0,128,255));

x0=LastValue(BarIndex())-75;
x1=LastValue(BarIndex());
y0=LastValue(Coy);
y1=LastValue(Coy);

Line = LineArray( x0, y0, x1, y1, 1 );
Plot( Line, "PrevClose", Ccolor,styleNoLabel );
-----------------------------------------------------------------------

I wrote the above code, compromising on the value of x0, to make it somehow
work. Actually, i need the line to start with the first candle of the current day.

1. How should I modify the code to get the value of the variable x0, so that it
represents the first bar of current day?

2. Is it possible to plot the line beyond the last candle on the chart?

Thanks..
pls check this

O1= TimeFrameGetPrice("O",inDaily,-1);
H1= TimeFrameGetPrice("H",inDaily,-1);
L1= TimeFrameGetPrice("L",inDaily,-1);
C1= TimeFrameGetPrice("C",inDaily,-1);

tn=TimeNum();
tm=91500;
end=152500;
cur=Day()==LastValue(Day());
mode2 = ParamList("Disp Lev ", " All | Today ",1);

switch( mode2 )
{
case " All ":
tcond=(Tn >= tm AND Tn<= end) ;
break;
case " Today ":
tcond=cur;
break;
}
Plot(IIf(tcond,O1,Null),"",colorPaleBlue,8|styleNoRescale|styleNoLabel);
Plot(IIf(tcond,H1,Null),"",colorGreen,8|styleNoRescale|styleNoLabel);
Plot(IIf(tcond,L1,Null),"",colorRed,8|styleNoRescale|styleNoLabel);
Plot(IIf(tcond,C1,Null),"",colorGold,8|styleNoRescale|styleNoLabel);

Thank you