StockFibber
New member
Hi, I want to add an order at the first candle of each trading day, but currently what I have is only posting an order on the first day and none of the subsequent days. I plotted "dayopen", "daytime" and "secondstillTime(start)" to see if they are doin what I expect and it looks like they are. When I have a 5 day, 1 minute chart setup, only the first day gets an order, how do I get an order on the first candle every day?
Code:
# day_open1
def na = Double.NaN;
# open/close times (EST)
input start = 0930;
input end = 1600;
input shares = 5;
input ProfitTargetPcnt=0.05;
def dayopen = if secondstillTime(start) == 0 then 1 else 0;
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;
def openbar = if !daytime then na
else if dayopen then hlc3
else openbar[1];
AddOrder(OrderType.BUY_TO_OPEN,dayopen, open[-1], shares, Color.YELLOW, Color.YELLOW);
plot z1 = openbar;
z1.SetDefaultColor(Color.green);
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z1.hideBubble();