자, 파이인 언어 전략은 어떻게 다음 문자를 반복할 수 있는지 알려주세요.

저자:CryptoLiu, 창작: 2022-11-14 10:11:47, 업데이트:

//@버전=4 전략 (title=EMA crosses, overlay=true)

// 입력 priceData = input ((title=Price data, type=input.source, defval=hl2) 가격 데이터의 입력값은 ema1Length = input ((title=EMA 1, type=input.integer, defval=12) ema2Length = input ((title=EMA 2, type=input.integer, defval=24) ema3Length = input ((title=EMA 3, type=input.integer, defval=36)

// 계산 값 ema1 = ta.ema ((값데이터, ema1장) ema2 = ta.ema ((값데이터, ema2장) ema3 = ta.ema ((값데이터, ema3Length)

enterLong = ema1 > ema2 그리고 ema2 > ema3 enterShort = ema1 < ema2 그리고 ema2 < ema3

// 플롯 값 그래프 ((시리즈=ema1, 컬러= 컬러.오렌지, 선 너비=2) 그래프 (그림=ema2, 색=색.갈색,선 너비=2) 플롯 (series=ema3)색=색.파란색, 직선 너비=2)

// 주문을 제출 if (enterLong) strategy.entry ((id=Enter Long, long=strategy.long) 로 입력하세요)

if (short 를 입력) strategy.entry ((id=Enter Short, long=strategy.short) 를 입력하세요)

현재 이 코드 세트는 리테스트를 하는 동안 항상 처음부터 하나의 문자를 눌러서 다른 문자가 작동하지 않는 것처럼 보입니다. 어떤 이 정책 루프를 실행시키는 방법을 알려줄 수 있습니까? 감사합니다.


더 많은

작은 꿈strategy.entry ((id="Enter Long", long=strategy.long), 이 함수 호출은 잘못 작성되었습니다. 직접 입력:strategy.entry (("Enter Long", strategy.long, 1) 이렇게 카드를 1 손, 장, 동전으로 입력합니다.

작은 꿈피라미드 상장 옵션:strategy 함수의 피라미딩 매개 변수를 설정해야 한다.

작은 꿈666, 연료를 넣어요

CryptoLiu또한 같은 방향으로 지속적으로 신호를 유발하는 글쓰기를 문의하고 싶습니다. 현재 글쓰기는 한 방향으로 한 포지션을 열 수 있습니다. enterLong이 지속적으로 유발되면 후속 트리거가 표시되지 않습니다.

CryptoLiu이 문이 닫혀있다는 것을 알 수 있습니다.

작은 꿈`` // 주문을 제출 if enterLong and strategy.position_size <= 0 strategy.entry (("Enter_Long", strategy.long, 1)) 로 입력합니다. // strategy.exit (("exit_long", "Enter_Long", when = enterShort) if enter 단축 및 전략.position_size >= 0 strategy.entry (("Enter_Short", strategy.short, 1)) 로 사용되었습니다. // strategy.exit (("exit_short", "Enter_Short", when =enterLong) `` 여기서 설정이 부적절하다고 판단하고, 나는 정상으로 변경했다. 만약 당신이== 0을 쓴다면, 다른 하나는 열기 전에 촉발되지 않을 것입니다. 왜냐하면 보유가 있기 때문에 0이 아닙니다.

CryptoLiu//@version=4 strategy (title="EMA_crosses", overlay=true) // 입력 priceData = input ((title="Price_data", type=input.source, defval=hl2)) 이 입력된 값입니다. ema1Length = input (title="EMA_1", type=input.integer, defval=12) ema2Length = input ((title="EMA_2", type=input.integer, defval=24) ema3Length = input ((title="EMA_3", type=input.integer, defval=36) // 계산 값 ema1 = ta.ema ((priceData, ema1Length) ema2 = ta.ema ((priceData, ema2Length) 의 값 ema3 = ta.ema ((priceData, ema3Length) enterLong = ema1 > ema2 and ema2 > ema3 enterShort = ema1 < ema2 and ema2 < ema3 // 플롯 값 plot (series=ema1, color=color.orange, linewidth=2) plot (series=ema2, color=color.maroon, linewidth=2) plot (series=ema3, color=color.blue, linewidth=2) // 주문을 제출 if enterLong and strategy.position_size == 0 strategy.entry (("Enter_Long", strategy.long, 1)) 로 입력합니다. strategy.exit (("exit_long", "Enter_Long", when = enterShort) "출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출출_장", "출출_장", "출출출_장", "출출_출_출", "출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_출_) if enter 단축 및 전략.position_size == 0 strategy.entry (("Enter_Short", strategy.short, 1)) 로 사용되었습니다. strategy.exit (("exit_short", "Enter_Short", when =enterLong) "출출_단", "출출_단", "출_단", when =enterLong) // 색상 배경 backgroundColour = (strategy.position_size > 0)? color.green: color.red bgcolor ((color=backgroundColour, transp=85)) 이 있습니다. 조금 수정했지만, 정책 시작 시에 한 번만 터치되고, 그 후에는 터치되지 않습니다. /upload/asset/573cd6ad4478a20fdb02.png