_SECTION_BEGIN( "Highest/Lowest Close in Daily" );
if( Interval( 0 ) < inDaily )
{
HighestC = Null;
LowestC = Null;
fvb = Status( "FirstVisibleBar" );
lvb = Min( Status( "LastVisibleBar" ), BarCount - 1 );
NewDay = Day() != Ref( Day(), -1 );
//for( i = 1; i <= BarCount - 1; i++ )
for( i = fvb; i < lvb; i++ ) // If using as an Indicator, otherwise, if want to explore, then use for-loop for all bars i.e. i = 1; i <= BarCount - 1; i++
{
HighestC[ i ] = HighestC[ i - 1 ];
LowestC[ i ] = LowestC[ i - 1 ];
if( NewDay[ i ] )
{
HighC = C[ i ];
LowC = C[ i ];
j = i + 1;
while( NOT NewDay[ j ] AND j < BarCount - 1 )
{
if( C[ j ] > HighC ) HighC = C[ j ];
if( C[ j ] < LowC ) LowC = C[ j ];
j++;
}
HighestC[ i ] = LastValue( HighC );
LowestC[ i ] = LastValue( LowC );
}
}
Plot( C, "", colorWhite, styleCandle );
HighestC = IIf( NOT NewDay, HighestC, Null );
Plot( HighestC, "", colorGreen );
Plot( HighestC, "", colorGreen, styleLine, Null, Null, -1 );
Plot( HighestC, "", colorGreen, styleLine, Null, Null, 1 );
LowestC = IIf( NOT NewDay, LowestC, Null );
Plot( LowestC, "", colorBrown );
Plot( LowestC, "", colorBrown, styleLine, Null, Null, -1 );
Plot( LowestC, "", colorBrown, styleLine, Null, Null, 1 );
}
else
{
Title = "";
GfxSetCoordsMode( 0 );
SetChartBkColor( colorRose );
Text = "Set the time-frame less than Daily";
x = Status( "PxChartWidth" ) / 2 - GfxGetTextWidth( Text );
y = Status( "PxChartHeight" ) / 2;
GfxSetBkColor( colorRose );
GfxSelectFont( "Courier New", 20, 700 );
GfxTextOut( Text, x, y );
}
_SECTION_END();
//Coded by @Loss_Lover for https://www.traderji.com/community/threads/simple-coding-help-no-promise.90119/post-1347633
// It is ideal to use a separate pane to display Volume; this is for demonstration only
// Arrays are several times faster than Looping (https://www.amibroker.com/guide/h_understandafl.html)
// Looping must be avoided if not deadly needed by the strategy
_SECTION_BEGIN( "Identifying Bars where Vol is greater than its 20 S.M.A." );
SetChartOptions( 0, chartShowDates | chartShowArrows );
AvgPer = Param( "Volume Average Period", 20, 1, 100, 1 );
VolSubPaneHgtPrcnt = Param( "Percentage of Vol sub-pane height", 25, 1, 100, 1 );
VolSubPaneMin = LowestVisibleValue( V );
VolSubPaneMax = HighestVisibleValue( V ) * 100 / VolSubPaneHgtPrcnt;
// Using Array form
//AvgVol = MA( V, AvgPer );
// Using Loop
_SumVol = 0;
for( i = 0; i < BarCount; i++ )
{
_SumVol += V[ i ];
if( i >= AvgPer ) _SumVol -= V[ i - AvgPer ];
if( i >= AvgPer - 1 ) SumVol[ i ] = _SumVol;
}
AvgVol = SumVol / AvgPer;
Plot( C, "Close", colorDefault, styleBar | styleThick );
Plot( V, "Volume", colorGrey50, styleHistogram | styleOwnScale | styleNoLabel, VolSubPaneMin, VolSubPaneMax, 0, 0, 2 );
Plot( AvgVol, "Avg. Vol", colorLightOrange, styleLine | styleOwnScale | styleNoLabel, VolSubPaneMin, VolSubPaneMax, 0, 0, 2 );
PlotShapes( IIf( V >= AvgVol, shapeSmallCircle, shapeNone ), colorSkyblue, 0, Status( "AxisMinY" ) );
_SECTION_END();
// Coded by @Loss_Lover for https://www.traderji.com/community/threads/simple-coding-help-no-promise.90119/post-1348633
_SECTION_BEGIN( "VWAP" );
SetChartOptions( 0, chartShowDates );
DispTyp = ParamToggle( "VWAP Display Type", "Anchored|Moving", 0 );
Price = ( H + L ) / 2;
if( DispTyp )
{
Value = Volume * Price;
NewDay = Day() != Ref( Day(), -1 );
BarsFromTodayBegin = 1 + BarsSince( NewDay );
TotalValue = Sum( Value, BarsFromTodayBegin );
TotalVolume = Sum( V, BarsFromTodayBegin );
VWAP = TotalValue / TotalVolume;
Plot( IIf( NOT NewDay, VWAP, Null ), "VWAP", colorLightOrange, styleStaircase | styleThick, Null, Null, 0, 0 );
}
else
{
bi = BarIndex();
BiBegin = BeginValue( bi ); // First Double-click on any bar (https://www.amibroker.com/guide/afl/beginvalue.html)
BiEnd = EndValue( bi ); // Second Double-click on any bar after the first selecteed bar (https://www.amibroker.com/guide/afl/endvalue.html)
fvb = Status( "FirstVisibleBar" );
lvb = Min( Status( "LastVisibleBar" ), BarCount - 1 );
if( BiBegin != 0 AND BiEnd != BarCount - 1 AND BiBegin >= fvb AND BiEnd <= lvb )
{
ValInRang = IIf( BiBegin <= bi AND bi <= BiEnd, V * Price, Null );
TotalValue = Cum( ValInRang );
VolInRng = IIf( BiBegin <= bi AND bi <= BiEnd, V, Null );
TotalVol = Cum( VolInRng );
AVWAP = TotalValue / TotalVol;
Plot( IIf( BiBegin <= bi AND bi <= BiEnd, AVWAP, Null ), "AVWAP", colorLightOrange, styleStaircase | styleThick, Null, Null, 0, 0 );
}
RequestMouseMoveRefresh();
}
Plot( C, "C", colorDefault, styleBar, Null, Null, 0, 0, 2 );
_SECTION_END();
// Coded by @Loss_Lover for https://www.traderji.com/community/threads/simple-coding-help-no-promise.90119/post-1348117
_SECTION_BEGIN( "Highest/Lowest Close in Daily" );
if( Interval( 0 ) < inDaily )
{
HighestC = Null;
LowestC = Null;
fvb = Status( "FirstVisibleBar" );
lvb = Min( Status( "LastVisibleBar" ), BarCount - 1 );
NewDay = Day() != Ref( Day(), -1 );
//for( i = fvb; i < lvb; i++ ) // If using as an Indicator, otherwise, if want to explore, then use for-loop for all bars i.e. i = 1; i <= BarCount - 1; i++
for( i = 1; i <= BarCount - 1; i++ )
{
HighestC[ i ] = HighestC[ i - 1 ];
LowestC[ i ] = LowestC[ i - 1 ];
if( NewDay[ i ] )
{
HighC = C[ i ];
LowC = C[ i ];
j = i + 1;
while( NOT NewDay[ j ] AND j < BarCount - 1 )
{
if( C[ j ] > HighC ) HighC = C[ j ];
if( C[ j ] < LowC ) LowC = C[ j ];
j++;
}
HighestC[ i ] = LastValue( HighC );
LowestC[ i ] = LastValue( LowC );
}
}
Plot( C, "", colorWhite, styleCandle );
HighestC = IIf( NOT NewDay, HighestC, Null );
Plot( HighestC, "", colorGreen, styleNoLabel );
Plot( HighestC, "", colorGreen, styleLine | styleNoLabel, Null, Null, -1 );
Plot( HighestC, "", colorGreen, styleLine | styleNoLabel, Null, Null, 1 );
LowestC = IIf( NOT NewDay, LowestC, Null );
Plot( LowestC, "", colorBrown, styleNoLabel );
Plot( LowestC, "", colorBrown, styleLine | styleNoLabel, Null, Null, -1 );
Plot( LowestC, "", colorBrown, styleLine | styleNoLabel, Null, Null, 1 );
}
else
{
Title = "";
GfxSetCoordsMode( 0 );
SetChartBkColor( colorRose );
Text = "Set the time-frame less than Daily";
x = Status( "PxChartWidth" ) / 2 - GfxGetTextWidth( Text );
y = Status( "PxChartHeight" ) / 2;
GfxSetBkColor( colorRose );
GfxSelectFont( "Courier New", 20, 700 );
GfxTextOut( Text, x, y );
}
_SECTION_END();
//Coded by @Loss_Lover for https://www.traderji.com/community/threads/simple-coding-help-no-promise.90119/post-1347633