最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

期貨量化交易軟件:已打開頭寸的兩步修改

2023-08-16 17:32 作者:bili_45793681098  | 我要投稿

簡介

“T.DeMark 的技術(shù)分析方法”一文中,包含了推薦的修正長度系數(shù),具體為 0.382 和 0.618。在打開頭寸時使用這些系數(shù),可以避免鄰近趨勢時不必要的關(guān)閉和重新打開頭寸。該功能效果很好,尤其在出現(xiàn)偏離的情況下。

在重新設(shè)置獲利值的情況下,這種方法幫助檢測“有利”趨勢的出現(xiàn)。例如,圖 1 和圖 2 所示。




編輯

功能算法

對訂單的第一個改動由指定 TrailingStop 值執(zhí)行,隨后的改動設(shè)置的 StopLoss 比可能的修正水平低 1 到 2 個點(diǎn)(在這種情況,修正系數(shù)=0,382 "Coeff_")。在每個步長上按照,例如,TrailingStop 值的一半(你也可以選擇其他值?。┰黾?TakeProfit 值。TakeProfit 的值也可以更改。為此,在程序開始時應(yīng)該設(shè)置 extern double March = 0; 的零值。

對于喜歡在交易時直接執(zhí)行特定程序的地址分析支持操作的交易者,最好將 MagicNumber 變量轉(zhuǎn)移到 Expert Advisor 自身打開頭寸的代碼中。關(guān)于具體的地址支持,可以在赫茲量化網(wǎng)站上發(fā)布的 S. Kovalyov 的書籍 中閱讀更多詳情。

編輯切換為居中

赫茲量化來仔細(xì)檢查 EA 中預(yù)期函數(shù)的建議代碼和其中的注釋:

//+------------------------------------------------------------------+ //| ? ? ?Two-stage variant of TrailingStop ? ? ? Modify_2step v5.mq4 | //| ? Orders modification: re-placing StopLoss and TakeProfit ? ? ? ?| //+------------------------------------------------------------------+ #property copyright "Copyright ? 2008, GenKov" #property link ? ? ?Genkov@bk.ru //+------------------------------------------------------------------+ /* Magic=N

Magic=N - 此運(yùn)算符應(yīng)在建倉時于程序自身(Expert Advisor)中的條件依從控制運(yùn)算符之后插入,以及在函數(shù)中插入?;蛟S鑒于市場的不可預(yù)測性,我無法創(chuàng)建一個通用修飾符,所以應(yīng)該為每種類型的頭寸打開條件(按 Magic=N)編寫跟蹤函數(shù)(S/L 和 T/P 的走勢)以及頭寸關(guān)閉條件。

extern double ? ?March ? ? ? ? = ?1; ?// step of increasing TakeProfit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// step 0 doesn't increase T/P.


S/L 必須小于 TrailingStop 1 個點(diǎn),以在第一次觸發(fā)時使 S/L 處于安全水平。利用這種方式,赫茲量化可以確保免于可能的損失(資本管理)。

extern double ? ?StopLoss ? ? ?= 15; ? extern double ? ?TrailingStop ?= 16; ? extern double ? ?TakeProfit ? ?= 60; ?// fitting with the tester //+------------------------------------------------------------------+ //void TrailingStop() ?int start() ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? { ? //----------------------------------------------------------------+ ? int point ?= MarketInfo(Symbol(),MODE_POINT); ? ? ?// Point size ? int StopLev= MarketInfo(Symbol(),MODE_STOPLEVEL); ? ? double half_Trail = MathRound(TrailingStop/2);//half TrailingStop ? double Step = March*half_Trail; ?//value of TakeProfit increase ?if (TrailingStop<0) return; ? { ? for (int i=0; i<OrdersTotal(); i++) ? ?{ ? ?if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; ? ?if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; ? ?if (OrderType()==OP_BUY) ? ? {

買入頭寸改動的第一步

if(OrderStopLoss()<OrderOpenPrice())//if S/L is less than the order open price ? ? ?{ ? // and if the difference between the current price and the position opening price is greater than T/S ? ? ?if(Bid-OrderOpenPrice()>TrailingStop*Point) // && ? ? ? { ? ? // and if OrderStopLoss() is less than the difference between the current price and T/S ? ? ? if(OrderStopLoss()<Bid-TrailingStop*Point) ? ? ? ?{ ? ?// calculate new T/P value ? ? ? ?double Now_T_P=(OrderTakeProfit()+Step*Point); ? ? ? { ? ? ? OrderModify(OrderTicket(),OrderOpenPrice(), ? ? ? OrderStopLoss()+TrailingStop*Point, ? ? ? OrderTakeProfit()+Step*Point,0,Aqua); // increasing T/P value ? ? ?return; ? ? ?} ? ? } ? ?} ? }

但是,可能發(fā)生以下情形:TakeProfit 偏移高于之前計劃的獲利水平 2-3 個點(diǎn),停止并開始慢慢下降。



編輯切換為居中



為避免損失獲利,赫茲量化輸入情形控制的運(yùn)算符,以在計劃的獲利水平關(guān)閉訂單。如果價格持續(xù)增長,則 StopLoss 和 TakeProfit 的偏移將繼續(xù)。

if(Bid-OrderOpenPrice()>=TakeProfit*Point && (Pr_Op_1-Pr_Op_0)>2*Point) ? { ? ?// Print(" Bid= ",Bid," >= ",OrderTakeProfit()," Magic= ",Magic); ? ?OrderClose(OrderTicket(),Lots,Bid,2,Red); ? ?}

// Second stage of BUY position modification


?if(OrderStopLoss()>=OrderOpenPrice()) // StopLoss is on a lossless level ? { ? ?// calculate correction coefficient ? ?double Coeff_up = NormalizeDouble((Bid-OrderOpenPrice())*0.382,Digits); ? ?// and if the differnece between the current and the open price of the position is greater than corr. coefficient ? ?if(Bid-OrderOpenPrice()>Coeff_up) ? ? { ? ?// calculate the value of new StopLoss with the margin of 2 points ? ? ?double New_S_Loss = Bid-Coeff_up-2*Point; ? ? ?// and if the value of new StopLoss is higer than the current one ? ? ?if(New_S_Loss-OrderStopLoss()>3*Point) ? ? ? { ? ? // move S/L and T/P ? ? ? ?OrderModify(OrderTicket(),OrderOpenPrice(), ? ? ? ?New_S_Loss,OrderTakeProfit()+Step*Point,0,Yellow); ? ? ? ?} // ? ? ? ?Print(" Bid-OrderOpenPrice()= ",Bid-OrderOpenPrice()); // ? ? ? ?Print(" ?2 ? Coeff_up= ",Coeff_up," Order_S_Los= ",New_S_Loss," Bid= ",Bid); ? ? ? return; ? ? ? } ? ? ?} ? ? }

做空頭寸的方法跟上面一樣,所以注釋變少了。

// ---------------------------- 1 stage of modification -----SELL-------------& ? else ?if(OrderType()==OP_SELL) ? ?{ ? if(OrderStopLoss()>OrderOpenPrice())//if S/L is greater than order open price ? ? { ? ? if(OrderOpenPrice()-Ask>TrailingStop*Point && ? ? ? ?OrderStopLoss()>Ask+TrailingStop*Point) ? ? { ? ? ?OrderModify(OrderTicket(),OrderOpenPrice(), ? ? ?Ask+TrailingStop*Point,OrderTakeProfit()-Step*Point,0,SkyBlue); ? ? ?return; ? ? ?} ? ? } if(OrderOpenPrice()-Ask>=TakeProfit*Point && (Pr_Op_0-Pr_Op_1)>2*Point) ? { ? ?OrderClose(OrderTicket(),Lots,Bid,2,Red); ? ?} ? ? // ---------------------------- 2 stage of modification -----SELL-------------& ? if(OrderStopLoss()<=OrderOpenPrice()) // StopLoss is on a lossless level ? ?{ // calculate correction coefficient ? ? double Coeff_down = NormalizeDouble((OrderOpenPrice()-Ask)*0.382,Digits); ? ? // and if the difference between the price of position opening and the current price is greater than corr. coefficient ? ?if(OrderOpenPrice()-Ask>Coeff_down) ? ? { ? ?// calculate the value of new StopLoss with the margin of 2 points ? ? ?New_S_Loss = Ask+Coeff_down+2*Point; ? ? ?// and if the value of new StopLoss is less than the current value ? ? ?if(New_S_Loss-OrderStopLoss()>3*Point) ? ? ? { ? ? // move S/L and T/P ? ? ? ? OrderModify(OrderTicket(),OrderOpenPrice(), ? ? ? New_S_Loss,OrderTakeProfit()-Step*Point,0,Khaki); ? ? ?return; ? ? ?} ? ? } ? ?} ? } ?} // ?-----------------------------------------------------------------------------------


期貨量化交易軟件:已打開頭寸的兩步修改的評論 (共 條)

分享到微博請遵守國家法律
时尚| 五大连池市| 咸丰县| 乐山市| 桦甸市| 建始县| 阳原县| 伊吾县| 吉隆县| 监利县| 黑河市| 大同县| 延川县| 濮阳县| 黄骅市| 正安县| 太和县| 沙田区| 犍为县| 元朗区| 周口市| 北票市| 普格县| 青浦区| 仲巴县| 木兰县| 昭觉县| 朝阳市| 德庆县| 轮台县| 龙游县| 安多县| 扎兰屯市| 马山县| 邢台县| 南靖县| 新田县| 华阴市| 民和| 望谟县| 故城县|