// Downloaded From https://www.WiseStockTrader.com
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;

x=Param("xposn",5,0,1000,1);
y=Param("yposn",545,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}

GfxSelectFont( "Arial", 12, 700, False );
GfxSetTextColor( colorRed );

GfxTextOut( "Time Left :"+SecsToGo+"", x, y );



////////////////////////////////////////////////////////////////
x=Param("dbsxposn",563,0,1000,1);
y=Param("dbsyposn",511,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
d = Now( 4 ) ; 
GfxSelectFont( "Arial", 12, 700, False );

A =BarsSince(Buy);
B= BarsSince(Sell);
C =IIf( a < b,A,b);
GfxSetTextColor(colorBlue);

GfxTextOut( "signal came Day befor Since :"+c+ "", x, y );





///////////////////////////////////////////////
x=Param("dbxposn",563,0,1000,1);
y=Param("dbyposn",531,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
d = Now( 4 ) ; 
GfxSelectFont( "Arial", 12, 700, False );
GfxSetTextColor( colorLime );
A =BarsSince(Buy);
B= BarsSince(Sell);

GfxTextOut( "Buy signal came Day before :"+a+ "", x, y );

x=Param("dsxposn",563,0,1000,1);
y=Param("dsyposn",554,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
d = Now( 4 ) ; 
GfxSelectFont( "Arial", 12, 700, False );
GfxSetTextColor( colorRed );

B= BarsSince(Sell);

GfxTextOut( "Sell signal came Day before :"+b+ "", x, y );

//////////////////////////////////////

//////////////////////////////////////



x=Param("BSxposn",575,0,1000,1);
y=Param("BSyposn",545,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );

GfxSelectFont( "Arial", 12, 700, False );



 
IIf(Buy,GfxSetTextColor( colorLime ),GfxSetTextColor( colorRed ));



x=Param("TSxposn",160,0,1000,1);
y=Param("TSyposn",545,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );

GfxSelectFont( "Arial", 12, 700, False );


IIf(Buy,GfxSetTextColor( colorLime ),GfxSetTextColor( colorRed ));
GfxTextOut( ("Stop loss : " + WriteVal(IIf (BUY,(buyprice-stopLINE),(C-stopLINE)),2.2)), x, y);;


x=Param("PLxposn",350,0,1000,1);
y=Param("PLyposn",545,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );


GfxSelectFont( "Arial", 12, 700, False );
IIf(Buy,GfxSetTextColor( colorLime ),GfxSetTextColor( colorRed ));

GfxTextOut( ("Current P/L : " + WriteVal(IIf (BUY,(buyprice-c),(C-BuyPrice)),2.2)), x, y);;


Exclude =   temaperf >= temapers;



                  
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBrightGreen, 0,L, Offset=-65);



                     
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorRed, 0,H, Offset=-65);



Filter = Buy OR Sell;