ผมต้องการโค้ดการเทลลิ่งสต๊อปแบบกำหนดช่วงอะคับ แต่ผมเขียนไม่เป็นนะคับ ถอดโค้ดเค้ามาและเข้าใจนิ๊ดดดดดดดเดียว
อยากสร้างโค้ดเองประมาณนี้คับ
1.เมื่อกำไรมากกว่า 50 จุดให้เบรคอีเว้น (กำไร 1 จุด) โดยไม่ต้องใช้คำสั่งเทลลิ่งสตอป
2.เมื่อกำไรมากกว่า 120 จุดให้ปรับเส้นสตอปลอตมาที่กำไร 30 จุดและทำการเทลลิ่งสตอป ให้เทลลิ่งตามไปเรื่อยๆโดยห่าง 90 จุด
3.เมื่อกำไรมากกว่า 300 จุดให้ปรับเส้นสตอปลอตมาที่กำไร 230 จุดและทำการเทลลิ่งสตอป ให้เทลลิ่งตามไปเรื่อยๆโดยห่าง 70 จุด คำสั่งข้างล่างได้ไหมคับ
(ตัวอย่างคำสั่งอยู่ที่ตัวอักษรสีแดงนะครับ)
อันนี้ก๊อปมาและอยากให้ได้ตามนี้คับ จินตนาการออก แต่เขียนไม่เป็นคับ ตรงไหนบกพร่องแนะนำด้วยคับ ใส่โค้ดเพิ่ม (ผมมั่วนะพี่ไหวเหรอ อิอิ)
extern bool UseOneAccount = true;
extern bool UseCloseOneThird = true;
extern int LevelProfit1 = 50;
extern int LevelMoving1 = 1;
extern int LevelProfit2 = 120;
extern int LevelMoving2 = 30;
extern int LevelProfit3 = 300;
extern int LevelMoving3 = 230;
extern int TrailingStop1 = 90;
extern int TrailingStop2 = 70;
extern int TrailingStep = 1;
extern int Slippage = 2;
extern bool ShowComment = true;
extern bool UseSound = true;
string var_132 = "expert.wav";
-------------
void ThreeLevelSystemOfOutput()
{
int profit = ProfitPosition();
int sl = StopLossInPoint();
int spread = MarketInfo(OrderSymbol(),MODE_SPREAD);
if (profit > LevelProfit1)
{
ModifyStopLossInPoint(LevelMoving1);
if (UseCloseOneThird) CloseOneThird();
}
if (profit > LevelProfit2)
{
ModifyStopLossInPoint(LevelMoving2);
if (profit > LevelMoving2 + TrailingStop1 + TrailingStep) TrailingPositions();
}
if (profit > LevelProfit3)
{
ModifyStopLossInPoint(LevelMoving3);
if (profit > LevelMoving3 + TrailingStop2 + TrailingStep) TrailingPositions();
}