hi Deepak,
yes thought about this later. Some steps are not really necessary, although the
result is the same. Also other small adjustments lower in code. Result is
following, see below. Yes if you really want the alert for a longer time it
could be done. Will look later,
rgds, Ed
// initialisations
starttime = 060000;
endtime = 160000;
timecond = TimeNum() >= starttime AND TimeNum() <= endtime;
firstBarOfDay = TimeNum() >= starttime ;firstBarOfDay = firstBarOfDay -
Ref(firstBarOfDay,-1);
// function to observe
FF = RSI(14);
// calculations
HighFF = ValueWhen( timecond, HighestSince( firstBarOfDay, FF) );
LowFF = ValueWhen( timecond, LowestSince( firstBarOfDay, FF) );
// chart section
SetChartBkColor( ParamColor("Color1",ColorRGB(0,0,0)));
GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
Plot(FF,"\nFF",ParamColor("Color2",ColorRGB(255,100,0)),styleLine);
Plot(HighFF,"\nHighFF",ParamColor("Color3",ColorRGB(255,0,255)),styleDashed);
Plot(LowFF,"\nLowFF",ParamColor("Color4",ColorRGB(255,0,255)),styleDashed);
Plot(timecond, "", ParamColor("Color5",ColorRGB(60,60,60)),
styleArea|styleOwnScale,0,1);
// alert section
staticHigh = Nz(StaticVarGet("sh"));
staticLow = Nz(StaticVarGet("sl"));
"Last High: " + WriteVal(staticHigh);
"Last Low: " + WriteVal(staticLow);
"Timecond: " + WriteVal(LastValue(timecond));
// reset static vars
rstep = ParamTrigger("Reset Static Vars:", "Reset Static Vars");
if(rstep)
{
StaticVarSet( "sh",0);
StaticVarSet( "sl",0);
}
if (LastValue(FF) > staticHigh AND LastValue(timecond))
{
StaticVarSet("sh",Max(LastValue(FF),LastValue(HighFF)) );
// new high alert
Say( "New High" );
}
if ( (LastValue(FF) < staticLow OR staticLow == 0) AND LastValue(timecond))
{
StaticVarSet("sl",Min(LastValue(FF),LastValue(LowFF)) );
// new low alert
Say( "New Low" );
}
SetBarsRequired(sbrAll,sbrAll);
----- Original Message -----
From: Deepak Patade
To: [email protected]
Sent: Friday, January 15, 2010 6:38 PM
Subject: Re: [amibroker] Edward=Can this be written = Complicated i thought
Thanks Edward
There is one requirement in it though.
Whenever a new high or low is acheived it should be plotted on the chart.
That does not happen.
also when about the alert, the alert should be there atleast for a minute or
a substantial time frame.
Deepak Patade,
Nasik.
------------------------------------------------------------------------------
From: Edward Pottasch <[email protected]>
To: [email protected]
Sent: Fri, January 15, 2010 4:25:11 PM
Subject: Re: [amibroker] Can this be written = Complicated i thought
hi,
I coded this. Have a look. I didn't test it properly yet but should work. If
you change the timeframe you need to reset the static variables => right click
mouse, Parameters button and then push "Reset Static Vars". Also you need to
set the startime and endtime for your liking.
let me know if it works,
regards, Ed
// initialisations
starttime = 093000;
endtime = 160000;
timecond = TimeNum() >= starttime AND TimeNum() <= endtime;
firstBarOfDay = TimeNum() >= starttime ;firstBarOfDay = firstBarOfDay -
Ref(firstBarOfDay, -1);
// function to observe
FF = RSI(14);
// calculations
HighFF = ValueWhen( timecond, HighestSince( firstBarOfDay, FF) );
LowFF = ValueWhen( timecond, LowestSince( firstBarOfDay, FF) );
HighFF = TimeFrameCompress(HighFF, inDaily, compressLast);
LowFF = TimeFrameCompress(LowFF, inDaily, compressLast);
HighFF = TimeFrameExpand( HighFF, inDaily, expandFirst );
LowFF = TimeFrameExpand( LowFF, inDaily, expandFirst );
// chart section
SetChartBkColor( ParamColor("Color1",ColorRGB(0,0,0)));
GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
Plot(FF,"\nFF",ParamColor("Color2",ColorRGB(255,100,0)),styleLine);
Plot(HighFF,"\nHighFF",ParamColor("Color3",ColorRGB(255,0,255)),styleDashed);
Plot(LowFF,"\nLowFF",ParamColor("Color4",ColorRGB(255,0,255)),styleDashed);
Plot(timecond, "", ParamColor("Color5",ColorRGB(60,60,60)),
styleArea|styleOwnScale,0,1);
// alert section
staticHigh = Nz(StaticVarGet("sh"));
staticLow = Nz(StaticVarGet("sl"));
"Last High: " + WriteVal(staticHigh) ;
"Last Low: " + WriteVal(staticLow);
"Timecond: " + WriteVal(LastValue(timecond));
// reset static vars
rstep = ParamTrigger("Reset Static Vars:", "Reset Static Vars");
if(rstep)
{
StaticVarSet( "sh",0);
StaticVarSet( "sl",0);
}
if (LastValue(FF) >= staticHigh AND LastValue(timecond))
{
StaticVarSet("sh",Max(LastValue(FF),LastValue(HighFF)) );
// new high alert
Say( "New High" );
}
if ( (LastValue(FF) <= staticLow OR staticLow == 0) AND LastValue(timecond))
{
StaticVarSet("sl",Min(LastValue(FF),LastValue(LowFF)) );
// new low alert
Say( "New Low" );
}
SetBarsRequired(sbrAll,sbrAll);
----- Original Message -----
From: Deepak Patade
To: amibro...@yahoogrou ps.com
Sent: Friday, January 15, 2010 6:03 AM
Subject: [amibroker] Can this be written = Complicated i thought
I want to write the lowest value and the highest value of the day for RSI
in real time.
The value should change if the earlier low or high is breached.
Then I must get a alert if a new high or low is acheived.
Deepak Patade,
Nasik.