电竞比分网-中国电竞赛事及体育赛事平台

分享

動(dòng)態(tài)移動(dòng)止損、止盈代碼

 Levy_X 2018-03-23


if(OrderType() == OP_BUY) { dSl=OrderStopLoss(); if( dSl == 0 ) if( dInitialSL != 0) dSl = dnAsk - dInitialSL; ArrayResize(arrSL,5); ArrayInitialize(arrSL,dSl); LogSL('OP_BUY-check',dSl,arrSL[0],arrSL[1],arrSL[2],arrSL[3]); if( dPropSLRatio > 0 ) { if( Bid >= (OrderOpenPrice() dPropSLThreshold) ) { dSl = NormalizeDouble( OrderOpenPrice() dPropSLRatio*(Bid - OrderOpenPrice()) - dSpread,4 ); if(OrderStopLoss() < dSl) arrSL[1]=dSl; } else { if(dTrailingStop != 0) arrSL[2]=dnBid - dTrailingStop; } } dSl=arrSL[ArrayMaximum(arrSL)]; LogSL('OP_BUY - max',dSl,arrSL[0],arrSL[1],arrSL[2],arrSL[3]); if( dSl > OrderStopLoss() || OrderStopLoss() == 0 ) { OrderModify(OrderTicket(), OrderOpenPrice(), dSl, OrderTakeProfit(), 0, Yellow); Log('Buy - modify', OrderOpenPrice(), dSl, OrderTakeProfit()); } // Escape buy //if( dEscape != 0 && dnBid < OrderOpenPrice() - dEscape - 5 * Point ) if( nUseEscape == 1 && dnBid < OrderOpenPrice() - dEscapeLevel - 5 * Point ) { OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice() dEscapeTP, 0, Aqua); Log('Buy - EscapeLevel', OrderOpenPrice(), dSl, OrderTakeProfit()); }



上述代碼中,使用dSl = NormalizeDouble( OrderOpenPrice() dPropSLRatio*(Bid - OrderOpenPrice()) - dSpread,4 );進(jìn)行動(dòng)態(tài)調(diào)整,dPropSLRatio可以考慮設(shè)置為0.382這個(gè)黃金比例。 另外當(dāng)現(xiàn)價(jià)低于一定程度時(shí),設(shè)置一個(gè)較小的止盈目標(biāo)位,及時(shí)逃脫。


    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多