Inputs : initialQuantity(100),gridDistance(10),numberOfOrders(5);
vars: currentQuantity(0),totalOrders(0), totalProfit(0), gridLevel(0);
if totalOrders < numberOfOrders then begin
// 현재 그리드 레벨 및 주문 수량 설정
gridLevel = totalOrders + 1;
currentQuantity = initialQuantity * gridLevel;
// 그리드 매매 주문 실행
if marketposition == 1 then begin
// 매수 주문
buy("GridBuy", currentQuantity) next bar at entryPrice - gridDistance * gridLevel stop;
// 매도 주문
sell("GridSell", currentQuantity) next bar at entryPrice + gridDistance * gridLevel stop;
// 주문 수 증가
totalOrders = totalOrders + 1;
end;
end;
답변 2
예스스탁
예스스탁 답변
2023-12-20 14:12:57
Inputs : initialQuantity(100),gridDistance(10),numberOfOrders(5);
vars: currentQuantity(0),totalOrders(0), totalProfit(0), gridLevel(0);
if totalOrders < numberOfOrders then begin
// 현재 그리드 레벨 및 주문 수량 설정
gridLevel = totalOrders + 1;
currentQuantity = initialQuantity * gridLevel;
// 그리드 매매 주문 실행
if marketposition == 1 then
begin
// 매수 주문
buy("GridBuy",AtStop,entryPrice - gridDistance * gridLevel, currentQuantity);
// 매도 주문
sell("GridSell",AtStop,entryPrice + gridDistance * gridLevel, currentQuantity);
// 주문 수 증가
totalOrders = totalOrders + 1;
end;
end;
> 유경완 님이 쓴 글입니다.
> 제목 : 그리드매매 수식중 매수/매도 부분의 문법에러 발생 수정 요청 드립니다
> Inputs : initialQuantity(100),gridDistance(10),numberOfOrders(5);
vars: currentQuantity(0),totalOrders(0), totalProfit(0), gridLevel(0);
if totalOrders < numberOfOrders then begin
// 현재 그리드 레벨 및 주문 수량 설정
gridLevel = totalOrders + 1;
currentQuantity = initialQuantity * gridLevel;
// 그리드 매매 주문 실행
if marketposition == 1 then begin
// 매수 주문
buy("GridBuy", currentQuantity) next bar at entryPrice - gridDistance * gridLevel stop;
// 매도 주문
sell("GridSell", currentQuantity) next bar at entryPrice + gridDistance * gridLevel stop;
// 주문 수 증가
totalOrders = totalOrders + 1;
end;
end;
if marketposition == 1 then 을 "0"으로 하면 매수는 되는데,
매도가 안되는 이유가 뭔가요?
gridDistance(10) 을 (3) 정도로 수정하면 1~2차 까지는 매수매도를 하는데,
전종목을 돌려보아도 그이상은 매매를 하지 않고 매수한 수량을 끝까지 가지고 갑니다.
그 이유를 알려주시거나 수정해 주시면 감사하겠습니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 그리드매매 수식중 매수/매도 부분의 문법에러 발생 수정 요청 드립니다
>
Inputs : initialQuantity(100),gridDistance(10),numberOfOrders(5);
vars: currentQuantity(0),totalOrders(0), totalProfit(0), gridLevel(0);
if totalOrders < numberOfOrders then begin
// 현재 그리드 레벨 및 주문 수량 설정
gridLevel = totalOrders + 1;
currentQuantity = initialQuantity * gridLevel;
// 그리드 매매 주문 실행
if marketposition == 1 then
begin
// 매수 주문
buy("GridBuy",AtStop,entryPrice - gridDistance * gridLevel, currentQuantity);
// 매도 주문
sell("GridSell",AtStop,entryPrice + gridDistance * gridLevel, currentQuantity);
// 주문 수 증가
totalOrders = totalOrders + 1;
end;
end;
> 유경완 님이 쓴 글입니다.
> 제목 : 그리드매매 수식중 매수/매도 부분의 문법에러 발생 수정 요청 드립니다
> Inputs : initialQuantity(100),gridDistance(10),numberOfOrders(5);
vars: currentQuantity(0),totalOrders(0), totalProfit(0), gridLevel(0);
if totalOrders < numberOfOrders then begin
// 현재 그리드 레벨 및 주문 수량 설정
gridLevel = totalOrders + 1;
currentQuantity = initialQuantity * gridLevel;
// 그리드 매매 주문 실행
if marketposition == 1 then begin
// 매수 주문
buy("GridBuy", currentQuantity) next bar at entryPrice - gridDistance * gridLevel stop;
// 매도 주문
sell("GridSell", currentQuantity) next bar at entryPrice + gridDistance * gridLevel stop;
// 주문 수 증가
totalOrders = totalOrders + 1;
end;
end;