// Downloaded From https://www.WiseStockTrader.com
Bars=1 + BarsSince( Day()!= Ref(Day(), -1));
NewDay = Day() != Ref(Day(), -1);

Plot(C,"",colorLime,128+styleNoLabel );

ExitTime = TimeNum()==134000;
RangeHigh = ValueWhen(NewDay, H);
RangeLow = ValueWhen(NewDay, L);
Buy = H > RangeHigh AND TimeNum()<134000;
Short = L < RangeLow AND TimeNum()<134000;
Sell=Short OR exittime;
Cover=Buy OR exittime;
Buy=ExRem(Buy,Sell); 
Sell=ExRem(Sell,Buy); 
Short=ExRem(Short,Cover); 
Cover=ExRem(Cover,Short);
PlotShapes(IIf(Buy,shapeHollowUpTriangle,shapeNone),colorRed,0,L,IIf(Buy,-30,-25));
PlotShapes(IIf(Short,shapeDownTriangle,shapeNone),colorBlue,0,H,IIf(Short,-30,-25));
PlotShapes(IIf(exittime,shapeSmallSquare,shapeNone),colorBrightGreen,0,H,IIf(Sell,-30,-25));

BuyentryPrice=IIf(bars==1,O, RangeHigh );
ShortentryPrice=IIf(bars==1,O, RangeLow );

BT=fopen("c:backtest.csv","w");

y = Year(); 

m = Month(); 

d = Day();

for( i = 0; i < BarCount; i++ )

{

if( Buy[i] )

{

BTE=StrFormat("%02.0f/%02.0f/%02.0f,B,%.0f\n",Y[i],M[i],D[i],BuyentryPrice[i]);

fputs(BTE,BT);

}

if( Short[i] ) 

{

BTE=StrFormat("%02.0f/%02.0f/%02.0f,S,%.0f\n",Y[i],M[i],D[i],ShortentryPrice[i]);

fputs(BTE,BT);

}

if( exittime[i] ) 

{

BTE=StrFormat("%02.0f/%02.0f/%02.0f,S,%.0f\n",Y[i],M[i],D[i],C[i]);

fputs(BTE,BT);

}
}


fclose(BT);