baru
May 17, 2021, 1:35pm
1
Hello gurus ,
I am trying to do a simple exploration ,when a bar rises a certain points ( different for different symbols). I get a alert or a say .
Here is my code .
text = "not increased";
color = colorRed;
dif1 = abs( ( Prevbarclose ) - ( C ) );
diff = abs( dif1 );
bir = Status( "barinrange" );
for( i = 1; i < BarCount; i++ )
{
if( Name() == "BANKNIFTY" AND( diff[i] >= 10 ) )
{
text = "Bank Nifty Increased";
Say( "Bank Nifty Increased more than" + 10, True );
color = colorGreen;
}
}
AddColumn( C, " Current Close", 1.2 );
I dont know what went wrong , Its taking forever when i am running the exploration for 1 recent day .
Its running perfectly for 1 recent bar .
Thanks for helping,
Baru
PrevBarClose is unknown variable. That's why you get error.
But loop is not required.
Use AddMultiTextColumn
to get bar-by-bar text output.
Prevbarclose = Ref(C,-1);
diff = abs(Prevbarclose - C );
is_range = diff >= 10;
// If LAST value of analysis range is true
// then do something
if ( SelectedValue(is_range) )
Say( Name() + " increased more than " + 10, True );
Filter = 1;
text = Name()+" has NOT increased\n"+Name()+" has increased";
bgcolor = IIf(is_range, colorGreen, colorRed);
AddMultiTextColumn(is_range, text, "Status", 1, colorDefault, bgcolor, 200);
AddColumn(C, "Current Close", 1.2 );
AddColumn(Diff, "Difference", 1.2 );
2 Likes
baru
May 17, 2021, 2:56pm
3
Thank you ... for your inputs .
I did initialize Prevbarclose.
I am pasting my whole code
Filter = 1 ;
//intraday
Points_bk = Param( "BankNifty Points " , 100, 10, 1000, 10 );
Points_Nty = Param( "Nifty Points " , 50, 10, 1000, 10 );
points_Rel = Param( "Reliance Points " , 10, 10, 500, 10 );
points_midcap = Param( "Mid Cap Points " , 120, 10, 500, 10 );
Prevbarclose = Ref( Close, -1 );
text = "not increased";
color = colorRed;
dif1 = abs( ( Prevbarclose ) - ( C ) );
diff = abs( dif1 );
bir = Status( "barinrange" );
for( i = 1; i < BarCount; i++ )
{
if( Name() == "BANKNIFTY" AND( diff[i] >= Points_bk ) )
{
text = "Bank Nifty Increased";
Say( "Bank Nifty Increased more than" + Points_bk, True );
color = colorGreen;
}
if( Name() == "NIFTY" AND( diff[i] >= Points_Nty ) )
{
text = " Nifty Increased";
Say( " Nifty Increased more than" + Points_Nty, True );
color = colorGreen;
}
if( Name() == "NIFTYMIDCAP50" AND( diff[i] ) >= points_midcap )
{
text = "NIFTYMIDCAP50 Increased";
Say( "NIFTYMIDCAP50 Increased more than" + points_midcap, True );
color = colorGreen;
}
}
AddColumn( C, " Current Close", 1.2 );
AddColumn( Prevbarclose, " Previous bar close Close", 1.2 );
AddColumn( diff, "Diff " , 1.3 );
AddTextColumn( text, "Comments...... ", 1.2, colorBlack, color );
Thank you
baru
system
Closed
August 25, 2021, 2:57pm
4
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.