raitabadr
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: September 3rd, 2022

Strategy Not executing any trades.

Hello, I've been a coder for over 9 years and been having a tough time implementing my script indicator(which works) in my strategy script. For the sake of making things simple I copied the indicator into my strategy script and referencing it doesnt help much. In fact, the compiler doesnt give out any error messages, but the strategy tester stays blank lol. I'm pretty sure its just a small error that I haven't been able to debug. Please let me know how I can fix it. Thanks!!! :cool:
The script is below:

//@version=5

strategy("My strategy", overlay=true, margin_long=100, margin_short=100)

//Indicator math
sd_g1 = 'Calibration'
sd_g2 = 'Standard Deviation Settings'
length = input(50, 'Distribution Width')
src = input(close, 'Source of Mean')
realtime = input(true, 'Real Time Bar Switch')

s_sd1 = input(true, 'Switch | StDev', inline='sd_a', group=sd_g2), i_sd1 = input.float(1.00, '', inline='sd_a', group=sd_g2, minval = 0, step = 0.01)
s_sd2 = input(true, 'Switch | StDev', inline='sd_b', group=sd_g2), i_sd2 = input.float(2.00, '', inline='sd_b', group=sd_g2, minval = 0, step = 0.01)
s_sd3 = input(true, 'Switch | StDev', inline='sd_c', group=sd_g2), i_sd3 = input.float(1.5, '', inline='sd_c', group=sd_g2, minval = 0, step = 0.01)

sd = ta.stdev(src, length)
z1 = open + (i_sd1 * sd)
z2 = open - (i_sd1 * sd)

z3 = open + (i_sd2 * sd)
z4 = open - (i_sd2 * sd)

z5 = open + (i_sd3 * sd)
z6 = open - (i_sd3 * sd)

//strategy
longCondition = close == z2
longCloseCondition = timenow == time_close

if (longCondition)
strategy.entry("long", strategy.long)

if (longCloseCondition)
strategy.close("long", immediately = true)

Return to “Pine Script Q&A”