TradingView strategy not executing, not launching real time alerts but yes backtesting

Viewed 28

Hi this is the problem... It works well backtesting but not on real time operations. I have removed the defaul order size, but it still dont work. I will be gratefull if could anybode help, thanks in advance:

Here's how I define strategy and alerts:


entryPrice = close


slLongPrice = entryPrice * (1 - max_risk_percentage / 100)

slShortPrice = entryPrice * (1 - max_risk_percentage / 100)

strategyLong = (((buySignal and ichiBuyCond) or (goLong and buySignal)) and strategy.position_size == 0)
strategyShort = ((sellSignal or ichiSellCond) or (goShort or sellSignal)) and strategy.position_size > 0

var float lastEntryPrice = 0



strategy.entry('Long', strategy.long, when=strategyLong, stop=close * (1 - max_risk_percentage / 100))

//strategy.entry("Short", strategy.short, when=(sellSignal or ichiSellCond or shortCondition) and strategy.position_size == 0, stop=close* (1 - max_risk_percentage/100))

// STEP 3:
// Submit exit orders based on take profit price
var float lastClosePrice = 0

strategy.close('Long', when=strategyShort)


// shorts
openShort = (ichiSellCond or goShort) and shortCondition and strategy.position_size == 0
closeShort = (buySignal or ichiBuyCond or longCondition) and strategy.position_size < 0

var float lastShortEntryPrice = 0



strategy.entry("Short", strategy.short, when=openShort, stop=close * (1 + max_risk_percentage/100))

var float lastCloseShortPrice = 0
strategy.close("Short", when=closeShort)

// alerts
if strategyLong
    lastEntryPrice:=close
    alertsyntax_golong='9c1ce21f-3214-42a5-a077-f23fd65bf8de'
    alert(message=alertsyntax_golong, freq=alert.freq_all)
if strategyShort
    lastClosePrice:=close
    alertsyntax_goshort='3b3899cd-aba9-4a26-be45-855d6e375d4b'
    alert(message=alertsyntax_goshort, freq=alert.freq_all)
if openShort
    lastShortEntryPrice:=close
    alertsyntax_openShort='416e4e24-b24a-4bcd-a20f-2019fcee0c3a'
    alert(message=alertsyntax_openShort, freq=alert.freq_all)
if closeShort
    lastCloseShortPrice:=close
    alertsyntax_closeShort='e6e82850-fd0d-4acd-b9c9-864be92004bb'
    alert(message=alertsyntax_closeShort, freq=alert.freq_all)

Conditions are set and also alert sending but no alerts are launched,

I have no much more details to give just that is a combination of some indicators joined via boolean attributes to set conditions

0 Answers
Related