Ciao a tutti,

Ho una sceneggiatura che colloca il trade in sospeso. Mette il commercio sui prezzi alti e bassi precedenti per gli acquisti e le vendite ... Voglio che questo script modifichi e aggiunga dei semi nel commercio in sospeso ... per esempio voglio mettere in attesa il commercio di 15 pips lontano dal prezzo alto e basso di candela precedente ...



Grazie

Codice inserito #import stdlib.ex4 stringa ErrorDescription (int e); #import #include lt; stdlib.mqhgt; #include lt; WinUser32.mqhgt;/- Ordini da aprire #define PendingOrders 1/Quantità di ordini in sospeso da aggiungere/- Gestione del denaro #define MoneyManagement 1/Utilizzare la gestione del denaro #define LotSize 0.1/In caso contrario, utilizzare questo #define RiskPercent 0.5/Rischio per il commercio iniziale #define RiskDecrease 0.25/Riduzione del rischio per il prossimo scambio/- ATR e moltipliori #define ATRPeriod 30/ATR Periodo di utilizzo #define ATRStopMultiplier 2/Moltipliore per lo stop-loss iniziale #define ATROrderMultiplier 0.5/Moltipliore per ulteriori ordini in attesa/- Non cambiarmi #define ShortName Acquista Stop #define MagicNumber 5001 #define Slippage 6 #define Shift 1/- Internal double LastOrderLots = EMPTY_VALUE; double LastOrderPrice; double DecimalPip;/ ----------------------------------------------- ------------------- /| Funzione di avvio Script personalizzato/ ------------------------------------------- ----------------------- int start () {//Conferma se (MessageBox (ShortName - Vuoi veramente piazzare (PendingOrders 1 ) BUYSTOP orders ?, Script, MB_YESNO | MB_ICONQUESTION)! = IDYES) return (1);/Pip value DecimalPip = GetDecimalPip ();/Bars double CLOSE = iClose (Symbol (), 0, Shift); double HIGH = iHigh (Symbol (), 0, Shift); double LOW = iLow (Symbol (), 0, Shift);/-/- Posiziona il primo ordine/- if (Bid gt; HIGH) {PlaceOrder (OP_BUY, GetLotSize ()); } else {PlaceOrder (OP_BUYSTOP, GetLotSize (), HIGH); }/-/- Posiziona ordini in sospeso/- per (int it = 0; it lt; PendingOrders; it ) PlaceOrder (OP_BUYSTOP, GetLotSize (), LastOrderPrice iATR (Symbol (), 0, ATRPeriod, shift) * ATROrderMultiplier);/Ciao! Commento (Copyright http://www.pointzero-trading.com);/Ciao ritorno (0); }/ ---------------------------------------------- -------------------- /| Le mie funzioni/ --------------------------------------------- --------------------- ** * Calcola la dimensione del lotto in base al rischio * @return double *double GetLotSize () {//Lots double l_lotz = LotSize ;/Lotsize e restrictions double l_minlot = MarketInfo (Symbol (), MODE_MINLOT); double l_maxlot = MarketInfo (Symbol (), MODE_MAXLOT); double l_lotstep = MarketInfo (Symbol (), MODE_LOTSTEP); int vp = 0; if (l_lotstep == 0.01) vp = 2; else vp = 1;/Applica la gestione del denaro se (MoneyManagement == true) l_lotz = MathFloor (AccountBalance () * RiskPercent100.0)1000.0;/Aspettare! Controlla se stiamo piramidando se (LastOrderLots! = EMPTY_VALUELastOrderLots gt; 0) l_lotz = LastOrderLots * RiskDecrease;/Normalize to lotstep l_lotz = NormalizeDouble (l_lotz, vp);/Controlla qui maxminlot se (l_lotz lt; l_minlot) l_lotz = l_minlot; if (l_lotz gt; l_maxlot) l_lotz = l_maxlot;/Ciao! return (l_lotz); }** * Inserisce un ordine * @param int Tipo * @param double Lotz * @param double PendingPrice *void PlaceOrder (int Type, doppio Lotz, double PendingPrice = 0) {//Local int err; colore l_color; doppio l_stoploss, l_price, l_sprice = 0; double stoplevel = getStopLevelInPips (); RefreshRates ();/Prezzo e colore per il tipo di trade se (Type == OP_BUY) {l_price = Ask; l_color = Blu; } if (Type == OP_SELL) {l_price = Bid; l_color = Rosso; } if (Type == OP_BUYSTOP) {l_price = PendingPrice; if (l_price lt; = Ask stoplevel * DecimalPip) l_price = Ask stoplevel * DecimalPip; l_color = LightBlue; } if (Type == OP_SELLSTOP) {l_price = PendingPrice; if (l_price gt; = Bid-stoplevel * DecimalPip) l_price = Bid ??????- stoplevel * DecimalPip; l_color = Salmone; }/Evita le collusioni mentre (IsTradeContextBusy ()) Sleep (1000); int l_datetime = TimeCurrent ();/Invia ordine int l_ticket = OrderSend (Symbol (), Type, Lotz, MyNormalizeDouble (l_price), Slippage, 0, 0,, ??????MagicNumber, 0, l_color);/Rety if failure if (l_ticket == -1) {while (l_ticket == -1 TimeCurrent () - l_datetime lt; 5! IsTesting ()) {err = GetLastError (); se (err == 148) ritorno; Il sonno (1000); while (IsTradeContextBusy ()) Sleep (1000); RefreshRates (); l_ticket = OrderSend (Symbol (), Type, Lotz, MyNormalizeDouble (l_price), Slippage, 0, 0,, ??????MagicNumber, 0, l_color); } if (l_ticket == -1) Stampa (ShortName (OrderSend Error) ErrorDescription (GetLastError ())); } if (l_ticket! = -1) {LastOrderLots = Lotz; LastOrderPrice = l_price; if (OrderSelect (l_ticket, SELECT_BY_TICKET, MODE_TRADES)) {l_stoploss = MyNormalizeDouble (GetStopLoss (Type, PendingPrice)); if (! OrderModify (l_ticket, OrderOpenPrice (), l_stoploss, 0, 0, Green)) Stampa (ShortName (OrderModify Error) ErrorDescription (GetLastError ())); }}}** * Restituisce stoploss iniziale * @param int Tipo * @param double ForcedPrice * @return double *double GetStopLoss (int Type, double ForcedPrice = 0) {double l_sl = 0; if (Type == OP_BUY) l_sl = Ask - iATR (Symbol (), 0, ATRPeriod, Shift) * ATRStopMultiplier - (Ask - Bid); if (Type == OP_SELL) l_sl = Bid ?????? iATR (Symbol (), 0, ATRPeriod, Shift) * ATRStopMultiplier (Ask - Bid); if (Type == OP_BUYSTOP) l_sl = ForcedPrice - iATR (Symbol (), 0, ATRPeriod, Shift) * ATRStopMultiplier - (Ask - Bid); if (Type == OP_SELLSTOP) l_sl = ForcedPrice iATR (Symbol (), 0, ATRPeriod, Shift) * ATRStopMultiplier (Ask - Bid); return (l_sl); }** * Restituisce il valore pip decimale * @return double*double GetDecimalPip () {switch (Digits) {case 5: return (0,0001); caso 4: ritorno (0,0001); caso 3: ritorno (0,001); default: return (0,01); }}** * Normalizza prezzo * @param prezzo doppio * @return double *double MyNormalizeDouble (prezzo doppio) {return (NormalizeDouble (price, Digits)); }** * Ottieni la baseline più la deviazione * @return double *double getStopLevelInPips () {double s = MarketInfo (Symbol (), MODE_STOPLEVEL) 1.0; if (cifre == 5) s = s10; ritorna); }