#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
extern bool UseTrailingtop = true;
extern int Trailingtop = 30;
extern double fluctuation = 0.00001;
int start()
{
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
//+------------------------------------------------------------------+
//| Variable End |
//+------------------------------------------------------------------+
//Check position
for (int i = 0; i < OrdersTotal(); i ++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol())
{
if(OrderType() == OP_BUY)
{
//Trailin stop
if(UseTrailingtop && ((fluctuation <= iHigh( Symbol(),PERIOD_M1, 0) - iClose( Symbol(),PERIOD_M1, 0)) || (fluctuation <= iClose( Symbol(),PERIOD_M1, 0) - iLow( Symbol(),PERIOD_M1, 0))))
{
if(OrderStopLoss() < Bid - Point * Trailingtop)
{
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * Trailingtop, OrderTakeProfit(), 0, MediumSeaGreen);
continue;
}
}
} else
{
//Close
//Trailing top
if(UseTrailingtop && ((fluctuation <= iHigh( Symbol(),PERIOD_M1, 0) - iClose( Symbol(),PERIOD_M1, 0)) || (fluctuation <= iClose( Symbol(),PERIOD_M1, 0) - iLow( Symbol(),PERIOD_M1, 0))))
{
if((OrderStopLoss() > (Ask + Point * Trailingtop)) || (OrderStopLoss() == 0))
{
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * Trailingtop, OrderTakeProfit(), 0, DarkOrange);
continue;
}
}
}
}
}
/*
for (int j = 0; j < OrdersTotal(); j ++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol())
{
if(OrderType() == OP_BUY)
{
//Trailing profit
a = b-c
if a > a
c = d
desiredprofit = targetprice - orderprice
profit = targetprice - price
while(desiredprofit < profit)
{
targetprice = price + desiredprofit
profit = targetprice - price
}
double abc = OrderOpenPrice() - OrderTakeProfit();
double abc1 = Bid - OrderTakeProfit();
if(abc1 > OrderOpenPrice() - OrderTakeProfit())
{
OrderTakeProfit() = OrderTakeProfit()-(abc1 - spread1);
if(Bid - OrderOpenPrice() < 0)
{
OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), (Bid - OrderOpenPrice())+abc1, 0, MediumSeaGreen);
continue;
}
} else
{
//Close
//Trailing profit
double abc2 = OrderOpenPrice() - OrderTakeProfit();
if((OrderOpenPrice() - Ask) < 0)
{
OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), (OrderOpenPrice() - Ask)+abc2, 0, DarkOrange);
continue;
}
}
}
}
*/
return(0);
}
//+------------------------------------------------------------------+
이건 만지다마 그냥 둔것인데요.
요기서 테이크프로핏이 처음 orderopenprice랑 OrderTakeProfit 차이를 기준으로 계속 수정하게 만들고 싶은데 어떻게 해야 하는지 모르겠습니다.
buy 문구에서 oderopenprice- ordertakeprofit 차이가 50이라면 현재 price - ordertakeprofit이 100으로 변했을때 50 - ordertakeprofit 으로 수정하는 방식으로요.
반대로 50 이하면 수정을 안하고요.
이렇게 할려면 어떻게 해야 하나요?
댓글 영역
획득법
① NFT 발행
작성한 게시물을 NFT로 발행하면 일주일 동안 사용할 수 있습니다. (최초 1회)
② NFT 구매
다른 이용자의 NFT를 구매하면 한 달 동안 사용할 수 있습니다. (구매 시마다 갱신)
사용법
디시콘에서지갑연결시 바로 사용 가능합니다.