Q&A 게시판 HOME > Q&A 게시판
작성자 : 거꾸시 작성일 : 2025-09-15 00:19:05 조회수 : 11
수식문의 드립니다.
이 시스템 식에, 3일>12일>60일 이동평균선 위에 있을때 만 매수하도록 조건문을 추가하고 싶슴니다.


Inputs: RangeLength(5), XAvgLength(50), BarstoEnter(5), Factor(3);
Variables: BuyEntry(0), BuySetup(False), BuyCounter(0), LongExitTarget(0);
Variables: SellEntry(0), SellSetup(False), SellCounter(0), ShortExitTarget(0);

Condition1 = High == Highest(High, RangeLength);
Condition2 = Close > High[2];
Condition3 = ema(Close, XAvgLength) > ema(Close, XAvgLength)[1];
Condition4 = Low == Lowest(Low, RangeLength);
Condition5 = Close < Low[2];
Condition6 = ema(Close, XAvgLength) < ema(Close, XAvgLength)[1]; 

If MarketPosition <> 1 AND Condition1 AND Condition2 AND Condition3 Then Begin
 BuyEntry = MedianPrice[2];
 BuyCounter = 0;
 BuySetup = True;
 LongExitTarget = High + Factor * (High - BuyEntry);
End;

If BuyCounter > BarstoEnter Then
 BuySetup = False;
Else
 BuyCounter = BuyCounter + 1;

If MarketPosition == 1 Then Begin
 BuySetup = False;
 ExitLong("EL_Target",atlimit,LongExitTarget);
End;

If BuySetup Then
 Buy("Buy",atlimit,BuyEntry);
 
If MarketPosition <> -1 AND Condition4 AND Condition5 AND Condition6 Then Begin
 SellEntry = MedianPrice[2];
 SellCounter = 0;
 SellSetup = True;
 ShortExitTarget = Low - Factor * (SellEntry - Low);
 
End;

If SellCounter > BarstoEnter Then
 SellSetup = False;
Else
 SellCounter = SellCounter + 1;

/*If MarketPosition == -1 Then Begin
 SellSetup = False;
 ExitShort("ES_Target",atlimit,ShortExitTarget); 
End;*/

If SellSetup Then
 Sell("EL_sell",atlimit,SellEntry); 

# ATR Protective Stop
Inputs: ProtectiveATRs(3);
var : AtrV(0);

AtrV = ATR(30);

If MarketPosition <> 0 Then {
 ExitLong("EL_Protective Stop", atstop, EntryPrice - AtrV*ProtectiveATRs); 
 ExitShort("ES_Protective Stop", atstop, EntryPrice + AtrV*ProtectiveATRs); 
}
목록 답변