1083 vizualizações
185
1083 2
Hi Everyone,

Do you guys know how can I add an exit strategy to this hilo .
I would like it to exit either with hilo invertion (already does) or with profit/loss (it doesn't work)

Thank you
Remover dos Scripts Favoritos Adicionar para Scripts Favoritos
I had better results eliminating the if conditions prior to entry. Assuming you want to have no pyramiding, so only 1 trade open.

try to use a boolean in the below manner excluding the if statements triggering the entry.

strategy.entry("long", when=longCondition and testPeriod())

After removing the if , then try removing the // comments prior to the exit to see if it works.

I dunno if I'm correct (I could be wrong) but i'm assuming that the profit / loss is a float that wouldn't be search if untill your if statement is fullfilled while in between the movements are not calculated while your if is false.

It fixed up a mess of 2 weeks for me ... try it ...
Resposta
neuwert89 AlAlawiAlawi
@AlAlawiAlawi, Hello! That's a great idea. It's better one trade. But I'm not able to fix the script. Can you help me AlAlawiAlawi? What do I need to do?

This is my script:

length = input(9, minval=0)
displace = input(0, minval=0)
highsma = sma(high, length)
lowsma = sma(low, length)

if testPeriod()
longCondition = close > highsma and strategy.position_size <= 0
if (longCondition)
strategy.entry("long", true, comment="compra")
strategy.exit("exit", "long", profit=31, loss=10, comment="saida compra")


shortCondition = close < lowsma and strategy.position_size >= 0
if (shortCondition)
strategy.entry("short", false, comment="venda")
strategy.exit("exit", "short", profit=30, loss=10, comment="saida venda")
Resposta
PT Português
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
HE עברית
Início Rastreador de Fundamentos Rastreador Forex Rastreador de Sinais Criptomoedas Calendário econômico Como Funciona Recursos gráficos Regras da Casa Moderadores Soluções para Corretoras & Websites Widgets Biblioteca Gráfica de Ações Solicitação de recurso Notícias do & blog FAQ Ajuda & Wiki Twitter
Perfil Configurações de perfil Conta e cobrança Enviar feedback Ideias Publicadas Seguidores Seguindo Mensagens Privadas Conversa Deslogar