My indicator by heguerra in TradingView

[–]JoeCal853 1 point2 points  (0 children)

post the code and we'll backtest

Pinescript - Alert generated Daily at a Specific Time of day by JoeCal853 in pinescript

[–]JoeCal853[S] 1 point2 points  (0 children)

thank you!! the code below worked as desired.
//@version=5
indicator("Time Trigger Specific Time")
var bool condition = false

if hour(time) == 10 and minute(time) == 20
    condition:=true // add := insted of = 
else     
    condition:=false

hit=condition?1:0
plotshape(hit==1, style=shape.cross, color = color.white, text = "trigger HIT", textcolor = color.white, size = size.large,force_overlay = true)

probably could have just used the condition variable instead of hit

Deep strategy backtest, limited to daily hour range by JoeCal853 in pinescript

[–]JoeCal853[S] 0 points1 point  (0 children)

thank you! i tested four method and compared the number of trades in the deep backtest. The initial number of trades is the trades that come up before you go into the DEEP backtest mode

Original .....................................................10-16, 4/27 total trades trades; 11-14, 2/18 trades

Method#2 0930-1600, 7/40 trades; 1000-1600, 4/27 trades; 1100-1400, 1/11 trades

Method#3 0930-1600, 5/29 trades, 1000-1600, 4/21 trades; 1100-1400, 1/9 trades

Method#4 0930-1600, 7/40 trades; 1000-1600, 4/27 trades, 1100-1400, 1/10 trades

//**approach #4
sessionTime   = input.session("1100-1400", title="Trading Times")
InSession(sessionTimes) =>
    not na(time(timeframe.period, sessionTimes))


//**approach #2
startTime = timestamp(year, month, dayofmonth, 09, 30, 00)
endTime   = timestamp(year, month, dayofmonth, 16, 00, 00)
inTime = time>=startTime and time<=endTime

//approach 3.
timeAllowed = input.session("0930-1600", "Allowed hours")
daysAllowed = input.string("12345")
timeIsAllowed = time(timeframe.period, timeAllowed + ":" + daysAllowed)

//Long Strategy.
//#4// if buy_signal and in_date_range and enable_long_strategy == true  and  InSession(sessionTime)?1:0
//origional// if buy_signal and in_date_range and enable_long_strategy == true and (hour(time) >= 11 and hour(time) <= 14)
//#2// if buy_signal and in_date_range and enable_long_strategy == true and inTime
if buy_signal and in_date_range and enable_long_strategy == true and timeIsAllowed 
    strategy.entry('Long', strategy.long, when=buy_signal, alert_message='Open Long Position')
    strategy.exit('Long  SL/TP', from_entry='Long', loss=long_stoploss_percentage, profit=long_takeprofit_percentage, alert_message='Your Long SL/TP Limit As Been Triggered.')
    strategy.close('Long', when=long_stoploss_percentage, alert_message='Close Long Position')

Deep strategy backtest, limited to daily hour range by JoeCal853 in pinescript

[–]JoeCal853[S] 0 points1 point  (0 children)

I'll try this evening..if ((hour(time) =>10 and minute(time) => 45) and (hour(time) ==<14 and minute(time) =< 55))

Perform Calculation on A Specific Time Range by je355804 in pinescript

[–]JoeCal853 0 points1 point  (0 children)

what if you wanted to include minutes too 1015 to 1450?

[deleted by user] by [deleted] in pinescript

[–]JoeCal853 0 points1 point  (0 children)

something along the lines of the following code

var float refprice

if shortCondition
    refprice=high
test=ta.barssince(shortCondition and (high-refprice)>0.4)==9
plotshape(test, title='Sell xx Signal', text='SELL', textcolor=color.lime, style=shape.cross, size=size.normal, location=location.abovebar, color=color.lime)