Simple Coding Help - No Promise.

I want an Alert for High Volume Bar.
Code:
_SECTION_BEGIN("HighVol");

//Peaking Volumes
HiVolume = IIf(V > (2 * EMA(V,10)), True, False);
LoVolume = IIf(V < (2 * EMA(V,10)), True, False);
HiVolume = ExRem(HiVolume,LoVolume);
LoVolume = ExRem(LoVolume,HiVolume);
IIf(HiVolume, Say (" High Volume be alert"),Null);

PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);

_SECTION_END();
This alert keeps repeating for every bar. I want it only for High Volume Bar. Please help. Thanks
Joshiji,
Let me know if this is what you are looking for.
C-like:
function SayOnCond( Text, SecondSpan )
{
     elapsed = GetPerformanceCounter() / 1000;
     LastElapsed = Nz( StaticVarGet( "#lastsaytime" + Name(), False ) );

     if( ( StaticVarGet( "#Say" + Name(), False ) ) AND ( elapsed - LastElapsed > SecondSpan ) )
     {
         StaticVarSet( "#lastsaytime" + Name(), elapsed, False );
         Say( Text, True );
     }
}

_SECTION_BEGIN("HighVol");
     //Peaking Volumes
     HiVolume = IIf(V > (2 * EMA(V,10)), True, False);
     LoVolume = IIf(V < (2 * EMA(V,10)), True, False);
     HiVolume = ExRem(HiVolume,LoVolume);
     LoVolume = ExRem(LoVolume,HiVolume);

     if( LastValue( HiVolume ) )
     {
         StaticVarSet( "#Say" + Name(), 1, False );
         SayOnCond( "High Volume be alert", 60 );
     }
     else
     {
         StaticVarSet( "#Say" + Name(), 0, False );
     }

     Plot( C, "", colorDefault, styleCandle );
     PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
_SECTION_END();
You can tweak the second argument of the SayOnCond() function while calling it as per your needs.
 
Last edited:

josh1

Well-Known Member
Joshiji,
Let me know if this is what you are looking for.
You can tweak the second argument of the SayOnCond() function while calling it as per your needs.
Thanks. Amibroker 5.5 accepts only 2 arguments for StaticVarSet. Removed third argument. Seems to be working. Let me see tomorrow in Realtime.

_SECTION_BEGIN("HighVol");

//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False);
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
function SayOnCond( Text, SecondSpan )
{
elapsed = GetPerformanceCounter() / 1000;
LastElapsed = Nz( StaticVarGet( "#lastsaytime" + Name(), False ) );

if( ( StaticVarGet( "#Say" + Name(), False ) ) AND ( elapsed - LastElapsed > SecondSpan ) )
{
StaticVarSet( "#lastsaytime" + Name(), False);
Say( Text, True );
}
}
if( LastValue( HiVolume ) )
{
StaticVarSet( "#Say" + Name(), 1 );
SayOnCond( "High Volume be alert", 60 );
}
else
{
StaticVarSet( "#Say" + Name(), 0);
}
_SECTION_END();
 

VJAY

Well-Known Member
Search for code in Varun Sir's thread, my system my trades.
Thanks MB...I have varun's afl....which put lines on chart ...I want only one arrow/other symbol when low volume bar prints....
 

travi

Well-Known Member
bhai, why so much :D:D

Instead of two static variables per symbol, only using 1 per symbol.

Also. your else code will run every time which is extra code execution setting variable to 0 every tick probably in RTD.

Here, loop code executed only when condition true.
Another trick we use is to set with Datetime, so only when a new bar is added we can get a positive.
so we are not bound to any timeframe.

and added symbol to speech :p

@josh1 you can try optimized version of @Loss_Lover
Code:
_SECTION_BEGIN("HighVol");
     //Peaking Volumes
     HiVolume = IIf(V > (2 * EMA(V,10)), True, False);
     LoVolume = IIf(V < (2 * EMA(V,10)), True, False);
     HiVolume = ExRem(HiVolume,LoVolume);
     LoVolume = ExRem(LoVolume,HiVolume);

    if( LastValue( HiVolume ) )
    {
        dt = LastValue( DateTime() );
 
        SayC = Nz( StaticVarGet( "Say" + Name() ) );
        if ( !SayC || dt != SayC )
        {
            StaticVarSet( "Say" + Name(), dt );
            Say( "High in " + Name(), True );
        }
    }

     Plot( C, "", colorDefault, styleCandle );
     PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
_SECTION_END();
The only caveat is that if one is using "LAST Time of TICK" then the timestamp will loose its reliability.
Default setting of START TIME (or any other option) will not have issues.

Joshiji,
Let me know if this is what you are looking for.
C-like:
function SayOnCond( Text, SecondSpan )
{
     elapsed = GetPerformanceCounter() / 1000;
     LastElapsed = Nz( StaticVarGet( "#lastsaytime" + Name(), False ) );

     if( ( StaticVarGet( "#Say" + Name(), False ) ) AND ( elapsed - LastElapsed > SecondSpan ) )
     {
         StaticVarSet( "#lastsaytime" + Name(), elapsed, False );
         Say( Text, True );
     }
}

_SECTION_BEGIN("HighVol");
     //Peaking Volumes
     HiVolume = IIf(V > (2 * EMA(V,10)), True, False);
     LoVolume = IIf(V < (2 * EMA(V,10)), True, False);
     HiVolume = ExRem(HiVolume,LoVolume);
     LoVolume = ExRem(LoVolume,HiVolume);

     if( LastValue( HiVolume ) )
     {
         StaticVarSet( "#Say" + Name(), 1, False );
         SayOnCond( "High Volume be alert", 60 );
     }
     else
     {
         StaticVarSet( "#Say" + Name(), 0, False );
     }

     Plot( C, "", colorDefault, styleCandle );
     PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
_SECTION_END();
You can tweak the second argument of the SayOnCond() function while calling it as per your needs.
 
Last edited:
bhai, why so much :D:D

Instead of two static variables per symbol, only using 1 per symbol.

Also. your else code will run every time which is extra code execution setting variable to 0 every tick probably in RTD.

Here, loop code executed only when condition true.
Another trick we use is to set with Datetime, so only when a new bar is added we can get a positive.
so we are not bound to any timeframe.

and added symbol to speech :p

@josh1 you can try optimized version of @Loss_Lover
Code:
_SECTION_BEGIN("HighVol");
     //Peaking Volumes
     HiVolume = IIf(V > (2 * EMA(V,10)), True, False);
     LoVolume = IIf(V < (2 * EMA(V,10)), True, False);
     HiVolume = ExRem(HiVolume,LoVolume);
     LoVolume = ExRem(LoVolume,HiVolume);

    if( LastValue( HiVolume ) )
    {
        dt = LastValue( DateTime() );

        SayC = Nz( StaticVarGet( "Say" + Name() ) );
        if ( !SayC || dt != SayC )
        {
            StaticVarSet( "Say" + Name(), dt );
            Say( "High in " + Name(), True );
        }
    }

     Plot( C, "", colorDefault, styleCandle );
     PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
_SECTION_END();
The only caveat is that if one is using "LAST Time of TICK" then the timestamp will loose its reliability.
Default setting of START TIME (or any other option) will not have issues.
For personal needs I use AlertIf() which is easier and effective to handle. Was just checking Joshiji's need - he is yet to respond. I too did not like my Else and used Lookup to identify the Bar when it happens but it did not work as I keep track of at what time a bar will close rather than its open.:D
 

josh1

Well-Known Member
bhai, why so much :D:D

Instead of two static variables per symbol, only using 1 per symbol.

Also. your else code will run every time which is extra code execution setting variable to 0 every tick probably in RTD.

Here, loop code executed only when condition true.
Another trick we use is to set with Datetime, so only when a new bar is added we can get a positive.
so we are not bound to any timeframe.

and added symbol to speech :p

@josh1 you can try optimized version of @Loss_Lover
Code:
_SECTION_BEGIN("HighVol");
     //Peaking Volumes
     HiVolume = IIf(V > (2 * EMA(V,10)), True, False);
     LoVolume = IIf(V < (2 * EMA(V,10)), True, False);
     HiVolume = ExRem(HiVolume,LoVolume);
     LoVolume = ExRem(LoVolume,HiVolume);

    if( LastValue( HiVolume ) )
    {
        dt = LastValue( DateTime() );

        SayC = Nz( StaticVarGet( "Say" + Name() ) );
        if ( !SayC || dt != SayC )
        {
            StaticVarSet( "Say" + Name(), dt );
            Say( "High in " + Name(), True );
        }
    }

     Plot( C, "", colorDefault, styleCandle );
     PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
_SECTION_END();
The only caveat is that if one is using "LAST Time of TICK" then the timestamp will loose its reliability.
Default setting of START TIME (or any other option) will not have issues.
For personal needs I use AlertIf() which is easier and effective to handle. Was just checking Joshiji's need - he is yet to respond. I too did not like my Else and used Lookup to identify the Bar when it happens but it did not work as I keep track of at what time a bar will close rather than its open.:D
Losslover's code is working in real time. But it keeps shouting for 3 minutes until bar closes and next one printed. Actually I don't need loVolume and I used exrem to avoid continuous shouting. But that didn't work.
What I want is, AFL should alert when volume is high and stop until next bar with hi volume is printed.
 

Similar threads