我一直在研究一種EA(基於圖表對象按鈕的按下); 以市場價格開立交易,根據我放在圖表上的SL線,根據我的風險%計算手數。使用我放置在圖表上的Entry和SL行設置待定交易(並根據風險%計算正確的手數)。各種類型的關閉功能(全部開放,所有挂件,所有OP,所有利潤,所有損失等...)將交易移至BE 足以覆蓋通信。和交換我一直在研究一個尾隨的SL函數,該函數工作正常並且做了它所支持的但只是第一次。我按下按鈕,它會確定價格在哪裡並相應地移動SL。再次確定基於初始風險的移動量(因為SL移動我使用開放價格和固定的說5:1獲利以計算移動多少因為這些是不會移動的設定因素並且弄亂了Calcs(計算))。 我要做的是設置一個循環的排序,我按下圖表上的按鈕一次,它移動SL。然後,如果價格達到新的水平,它再次移動SL而不必再次觸及尾隨的SL。我意識到如果我改變TF等......我們ReInit我必須重新按下按鈕。可以將此代碼放入循環中,在第一次按下按鈕後繼續檢查並移動SL嗎?我嘗試了一些像使用的東西,但它只是讓事情變得混亂,SL來回反彈。如果我繼續;之後如果那麼它在第一行後停止......
我希望有人能幫幫忙。我確信這是我的一個愚蠢的錯誤或我沒有看到的簡單的事情。我對編碼還很陌生。
插入代碼if(sparam == TSLButton)//已按下Trail SL按鈕{ObjectSetInteger(0,TSLButton,OBJPROP_STATE,false); bool TSL = false; double TickValue = MarketInfo(Symbol(),MODE_TICKVALUE); double GGG = OrderCommission() OrderSwap(); double GGG1 = NormalizeDouble(OrderCommission() OrderSwap(),Digits)* Point; double XXX = GGG1TickValue; double XXY =(OrderOpenPrice() - OrderTakeProfit())/TPFactor; int orders_cnt = 0; int total = OrdersTotal(); for(int i = 0; ilt; total; i ){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)== false)continue; if(OrderSymbol()== Symbol())orders_cnt ; ObjectSetInteger(0,TSLButton,OBJPROP_COLOR,ButtonTxtCLR); ObjectSetInteger(0,TSLButton,OBJPROP_BGCOLOR,紅色); ObjectSetInteger(0,TSLButton,OBJPROP_BORDER_COLOR,紅色); RefreshRates(); if(OrderType()== OP_BUY){if(Bidgt;(OrderOpenPrice() (XXY * 2))){TSL = OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice() - (XXX)),OrderTakeProfit (),0,clrNONE);} if(Bidgt;(OrderOpenPrice() (XXY * 3))){TSL = OrderModify(OrderTicket(),OrderOpenPrice(),((OrderOpenPrice() - (XXX)) ( XXY)),OrderTakeProfit(),0,clrNONE);} if(Bidgt;(OrderOpenPrice() (XXY * 4))){TSL = OrderModify(OrderTicket(),OrderOpenPrice(),((OrderOpenPrice() - ( XXX)) (XXY * 3)),OrderTakeProfit(),0,clrNONE);}} if(OrderType()== OP_SELL){if(Asklt;(OrderOpenPrice() - (XXY * 2))){TSL = OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice() (XXX)),OrderTakeProfit(),0,clrNONE);} if(Asklt;(OrderOpenPrice() - (XXY * 3))){TSL = OrderModify(OrderTicket(),OrderOpenPrice(),((OrderOpenPrice() (XXX)) - (XXY)),OrderTakeProfit(),0,clrNONE);} if(Asklt;(OrderOpenPrice() - (XXY * 4))){TSL = OrderModify(OrderTicket(),OrderOpenPrice(),((OrderOpenPrice() (XXX)) - (XXY * 3)),OrderTakeProfit() ,0,clrNONE);}}}}