// Entry Condition: When Short EMA crosses above Long EMA longCondition = ta.crossover(emaShort, emaLong)
// Exit Condition: When Short EMA crosses below Long EMA exitCondition = ta.crossunder(emaShort, emaLong)
// Strategy Logic if (longCondition) // Open a new long position if not already in one strategy.entry("Long", strategy.long)
// If we want to automatically exit the long position via Stop Loss and Take Profit: strategy.exit( "Exit Long", from_entry = "Long", stop_loss = strategy.position_avg_price * (1 - stopLossPerc/100), limit = strategy.position_avg_price * (1 + takeProfitPerc/100) )
// Also, if exit condition is triggered by EMA cross: if (exitCondition) strategy.close("Long")
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.