需要稍作调整 - 页 3 12345678910...18 新评论 Сергей Дыбленко 2020.06.15 18:18 #21 插上电源-----,它没有工作。 //+------------------------------------------------------------------+ int Order(string _Order) { int i,ticket=0; _sl = 0.0; _tp = 0.0; if(_Order=="BUY") { for(i=0; i<MaxOrderAtOnceTime; i++) { ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,Ask,Slippage,_sl,_tp,"",Magic,0,Blue); } }else { for(i=0; i<MaxOrderAtOnceTime; i++) { ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,Bid,Slippage,_sl,_tp,"",Magic,0,Red); } } return(ticket); } //+------------------------------------------------------------------+ [删除] 2020.06.15 18:24 #22 Сергей Дыбленко:插上这个-----,它没有工作。 在这里你可以掌握https://www.mql5.com/ru/code/23470 //+------------------------------------------------------------------+ //| OrderLimit.mq4 | //| Pavel Shukin | //| fibo.rich@gmail.com | //+------------------------------------------------------------------+ #property copyright "Pavel Shukin " #property link "fibo.rich@gmail.com" #property version "1.00" #property strict #property description "Cкрипт устанавливает лимитный ордер buy или sell." #property description "Если текущая (Bid) цена выше (больше) цены, по которой был бронен скрипт," #property description "то будет установлен Order BuyLimit." #property description "Если текущая (Bid) цена ниже (меньше) цены, по которой был бронен скрипт," #property description "то будет установлен Order SellLimit." #property script_show_inputs input double Lots=0.01;//Volume Position extern int TakeProfit=40; extern int StopLoss=20; input int Slippage=30; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { if(Digits==3 || Digits==5) { TakeProfit*=10; StopLoss*=10; } //--define price setting script double PriceClick=NormalizeDouble(WindowPriceOnDropped(),Digits); //--define current price double PriceCurrent=NormalizeDouble(Bid,Digits); //--условие opening BuyLimit if(PriceClick<PriceCurrent) { BuyLimit(Lots,PriceClick,Slippage); } //--условие opening SellLimit if(PriceClick>PriceCurrent) { SellLimit(Lots,PriceClick,Slippage); } } //+------------------------------------------------------------------+ //Function for opening BuyLimit //+------------------------------------------------------------------+ void BuyLimit(double lots,double open_price,int slippage) { int ticket=OrderSend(Symbol(),OP_BUYLIMIT,lots,open_price,slippage,0,0,"ScriptOrderLimit",0,0,clrNONE); if(ticket<0) Print("Error opening BuyLimit ",GetLastError()); else { double sl=NormalizeDouble(open_price-(StopLoss*Point),Digits); double tp=NormalizeDouble(open_price+(TakeProfit*Point),Digits); if(!OrderModify(ticket,open_price,sl,tp,0,clrNONE)) Print("Error Modify order BuyLimit ",GetLastError()); } } //+------------------------------------------------------------------+ //Function for opening SellLimit //+------------------------------------------------------------------+ void SellLimit(double lots,double open_price,int slippage) { int ticket=OrderSend(Symbol(),OP_SELLLIMIT,lots,open_price,slippage,0,0,"ScriptOrderLimit",0,0,clrNONE); if(ticket<0) Print("Error opening SellLimit ",GetLastError()); else { double sl=NormalizeDouble(open_price+(StopLoss*Point),Digits); double tp=NormalizeDouble(open_price-(TakeProfit*Point),Digits); if(!OrderModify(ticket,open_price,sl,tp,0,clrNONE)) Print("Error Modify Order SellLimit ",GetLastError()); } } //+------------------------------------------------------------------+ scriptOrderLimit www.mql5.com Helpercent Предназначен для ручной торговли. Выставляет сделки с указанным риском. Стоплос - обязательный параметр, при помощи которого автоматически определяется направление ордера. Simple Trading Простая библиотека для MT4, содержащая базовый... Сергей Дыбленко 2020.06.15 18:57 #23 谢谢,我会看一下.........。 Сергей Дыбленко 2020.06.15 19:06 #24 把这个放进去 - 没有结果 //+------------------------------------------------------------------+ //Function for opening BuyLimit //+------------------------------------------------------------------+ void BuyLimit(double lots,double open_price,int slippage) { int ticket=OrderSend(Symbol(),OP_BUYLIMIT,lots,open_price,slippage,0,0,"ScriptOrderLimit",0,0,clrNONE); if(ticket<0) Print("Error opening BuyLimit ",GetLastError()); else { double sl=NormalizeDouble(open_price-(StopLoss*Point),Digits); double tp=NormalizeDouble(open_price+(TakeProfit*Point),Digits); if(!OrderModify(ticket,open_price,sl,tp,0,clrNONE)) Print("Error Modify order BuyLimit ",GetLastError()); } } //+------------------------------------------------------------------+ //Function for opening SellLimit //+------------------------------------------------------------------+ void SellLimit(double lots,double open_price,int slippage) { int ticket=OrderSend(Symbol(),OP_SELLLIMIT,lots,open_price,slippage,0,0,"ScriptOrderLimit",0,0,clrNONE); if(ticket<0) Print("Error opening SellLimit ",GetLastError()); else { double sl=NormalizeDouble(open_price+(StopLoss*Point),Digits); double tp=NormalizeDouble(open_price-(TakeProfit*Point),Digits); if(!OrderModify(ticket,open_price,sl,tp,0,clrNONE)) Print("Error Modify Order SellLimit ",GetLastError()); } } //+------------------------------------------------------------------+ [删除] 2020.06.15 19:30 #25 Сергей Дыбленко :把这个 - 零结果我在这里搞砸了——是的!并更换了拖网,它无法正常工作。 //+------------------------------------------------------------------+ //| InstantExecution.mq4 | //| Copyright 2015, @traderconfident | //| https://confident-trader.blogspot.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, @traderconfident" #property link "https://confident-trader.blogspot.com" #property version "1.0" #property strict //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ input string _Orders_= " --- Set Order ---" ; input double Lots = 0.05 ; input int StopLoss = 1400 ; input int TakeProfit = 700 ; input int TrailingStart = 200 ; input double TrailingStop = 300 ; // Фиксированный размер трала input double TrailingStep = 50 ; // Шаг трала input string _OrdersLimit= " --- Set OrderLimit ---" ; input int TakeProfitLimit = 40 ; input int StopLossLimit = 20 ; input int Slippage = 30 ; input int Magic = 90910 ; //------- bool AllPositions = false ; // Управлять всеми позициями bool ProfitTrailing = true ; // Тралить только профит bool UseSound = true ; // Использовать звуковой сигнал string NameFileSound = "expert.wav" ; // Наименование звукового файла double _sl,_tp,_pip; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit () { _pip= Point ; if ( Digits == 3 || Digits == 5 ) _pip= 10 * Point ; //--- ObjectCreate ( 0 , "CloseButton" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_XDISTANCE , 10 ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_XSIZE , 100 ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "CloseButton" , OBJPROP_TEXT , "Close Orders" ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_BGCOLOR ,Red); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_BORDER_COLOR ,Red); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_FONTSIZE , 12 ); //Exit ObjectCreate ( 0 , "OrderLimit" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_XDISTANCE , 120 ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_XSIZE , 80 ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "OrderLimit" , OBJPROP_TEXT , "OrderLimit" ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_BGCOLOR ,Green); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_BORDER_COLOR ,Green); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_FONTSIZE , 12 ); //Buy ObjectCreate ( 0 , "Buy" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_XDISTANCE , 210 ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_XSIZE , 50 ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "Buy" , OBJPROP_TEXT , "Buy" ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "Buy" , OBJPROP_BGCOLOR ,Blue); ObjectSetInteger ( 0 , "Buy" , OBJPROP_BORDER_COLOR ,Blue); ObjectSetInteger ( 0 , "Buy" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_FONTSIZE , 12 ); //Sell ObjectCreate ( 0 , "Sell" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_XDISTANCE , 270 ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_XSIZE , 50 ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "Sell" , OBJPROP_TEXT , "Sell" ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "Sell" , OBJPROP_BGCOLOR ,Gray); ObjectSetInteger ( 0 , "Sell" , OBJPROP_BORDER_COLOR ,Gray); ObjectSetInteger ( 0 , "Sell" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_FONTSIZE , 12 ); //Closed at Profit ObjectCreate ( 0 , "CloseAtProfit" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_XDISTANCE , 330 ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_XSIZE , 100 ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "CloseAtProfit" , OBJPROP_TEXT , "Close Profit" ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_BGCOLOR ,Green); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_BORDER_COLOR ,Green); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_FONTSIZE , 12 ); //--- return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int start() { if (TrailingStart> 0 ) TrailStopOrders(); OnChartEvent1(); return ( 0 ); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent1() { int ticket; if ( ObjectGetInteger ( 0 , "CloseAtProfit" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_STATE , 0 ); CloseAtProfit(); } if ( ObjectGetInteger ( 0 , "CloseButton" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_STATE , 0 ); CloseALL(); } if ( ObjectGetInteger ( 0 , "OrderLimit" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_STATE , 0 ); OnStartLimit(); } if ( ObjectGetInteger ( 0 , "Buy" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "Buy" , OBJPROP_STATE , 0 ); { ticket= OrderSend ( Symbol (),OP_BUY,Lots,Ask, 3 ,Bid-StopLoss* Point ,Ask+TakeProfit* Point , "" ,Magic, 0 ,Green); if (ticket> 0 ) { if ( OrderSelect (ticket,SELECT_BY_TICKET,MODE_TRADES)) Print ( "BUY order opened : " ,OrderOpenPrice()); } else Print ( "Error opening BUY order : " , GetLastError ()); return ; } } if ( ObjectGetInteger ( 0 , "Sell" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "Sell" , OBJPROP_STATE , 0 ); { ticket= OrderSend ( Symbol (),OP_SELL,Lots,Bid, 3 ,Ask+StopLoss* Point ,Bid-TakeProfit* Point , "" ,Magic, 0 ,Red); if (ticket> 0 ) { if ( OrderSelect (ticket,SELECT_BY_TICKET,MODE_TRADES)) Print ( "SELL order opened : " ,OrderOpenPrice()); } else Print ( "Error opening SELL order : " , GetLastError ()); } return ; } } //+------------------------------------------------------------------+ void TrailStopOrders() { for ( int i= 0 ; i< OrdersTotal (); i++) { if ( OrderSelect (i,SELECT_BY_POS, MODE_TRADES)) { if (AllPositions || OrderSymbol()== Symbol ()) { TrailingPositions(); } } } } //+------------------------------------------------------------------+ //| Сопровождение позиции простым тралом | //+------------------------------------------------------------------+ void TrailingPositions() { double pBid,pAsk,pp; pp=MarketInfo(OrderSymbol(),MODE_POINT); if (OrderType()==OP_BUY) { pBid=MarketInfo(OrderSymbol(),MODE_BID); if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) { if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep- 1 )*pp) { ModifyStopLoss(pBid-TrailingStop*pp); return ; } } } if (OrderType()==OP_SELL) { pAsk=MarketInfo(OrderSymbol(),MODE_ASK); if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) { if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep- 1 )*pp || OrderStopLoss()== 0 ) { ModifyStopLoss(pAsk+TrailingStop*pp); return ; } } } } //+------------------------------------------------------------------+ //| Перенос уровня StopLoss | //| Параметры: | //| ldStopLoss - уровень StopLoss | //+------------------------------------------------------------------+ void ModifyStopLoss( double ldStopLoss) { bool fm; fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(), 0 ,CLR_NONE); if (fm && UseSound) PlaySound (NameFileSound); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CloseAtProfit() { int ticket= 0 ; RefreshRates(); for ( int cnt= 0 ; cnt< OrdersTotal (); cnt++) { ticket= OrderSelect (cnt,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol()== Symbol () && OrderType()==OP_BUY && Bid>OrderOpenPrice()) { ticket=OrderClose(OrderTicket(),OrderLots(),Bid, 0 ,Violet); } if (OrderSymbol()== Symbol () && OrderType()==OP_SELL && OrderOpenPrice()>Ask) { ticket=OrderClose(OrderTicket(),OrderLots(),Ask, 0 ,Violet); } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CloseALL() { int Close_ticket= 0 ; int total= OrdersTotal (); int i = 0 ; for (i = total; i >= 0 ; i--) { if ( OrderSelect (i,SELECT_BY_POS) && OrderSymbol()== Symbol ()) { //OrderSelect(i,SELECT_BY_POS); if (OrderSymbol()== Symbol () && (OrderType()==OP_BUY || OrderType()==OP_SELL)) { Close_ticket = OrderClose(OrderTicket(),OrderLots(),MarketInfo( Symbol (),MODE_ASK), 5 ); Close_ticket = OrderClose(OrderTicket(),OrderLots(),MarketInfo( Symbol (),MODE_BID), 5 ); } } } } //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStartLimit() { //--define price setting script double PriceClick= NormalizeDouble (WindowPriceOnDropped(), Digits ); //--define current price double PriceCurrent= NormalizeDouble (Bid, Digits ); //--условие opening BuyLimit if (PriceClick<PriceCurrent) { BuyLimit(Lots,PriceClick,Slippage); } //--условие opening SellLimit if (PriceClick>PriceCurrent) { SellLimit(Lots,PriceClick,Slippage); } } //+------------------------------------------------------------------+ //Function for opening BuyLimit //+------------------------------------------------------------------+ void BuyLimit( double lots, double open_price, int slippage) { int ticket= OrderSend ( Symbol (),OP_BUYLIMIT,lots,open_price,slippage, 0 , 0 , "ScriptOrderLimit" , 0 , 0 , clrNONE ); if (ticket< 0 ) Print ( "Error opening BuyLimit " , GetLastError ()); else { double sl= NormalizeDouble (open_price-(StopLossLimit* Point ), Digits ); double tp= NormalizeDouble (open_price+(TakeProfitLimit* Point ), Digits ); if (!OrderModify(ticket,open_price,sl,tp, 0 , clrNONE )) Print ( "Error Modify order BuyLimit " , GetLastError ()); } } //+------------------------------------------------------------------+ //Function for opening SellLimit //+------------------------------------------------------------------+ void SellLimit( double lots, double open_price, int slippage) { int ticket= OrderSend ( Symbol (),OP_SELLLIMIT,lots,open_price,slippage, 0 , 0 , "ScriptOrderLimit" , 0 , 0 , clrNONE ); if (ticket< 0 ) Print ( "Error opening SellLimit " , GetLastError ()); else { double sl= NormalizeDouble (open_price+(StopLossLimit* Point ), Digits ); double tp= NormalizeDouble (open_price-(TakeProfitLimit* Point ), Digits ); if (!OrderModify(ticket,open_price,sl,tp, 0 , clrNONE )) Print ( "Error Modify Order SellLimit " , GetLastError ()); } } //+------------------------------------------------------------------+ 附加的文件: InstantExecution.mq4 28 kb Сергей Дыбленко 2020.06.15 19:55 #26 我昨天吃了这个。 //+------------------------------------------------------------------+ //| RSI.mq4 | //| Copyright © 2016, Хлыстов Владимир | //| cmillion@narod.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2016, Хлыстов Владимир" #property link "cmillion@narod.ru" #property strict #property description "советник по RSI" #property description "sell при пересечение сверху вниз 70 и на buy снизу вверх 30" #property description "стопы и тейки можно выстовить в настройках советника" //-------------------------------------------------------------------- extern int period_RSI = 56, stoploss = 0, takeprofit = 250, slippage = 0, buy_level = 52, sell_level = 52, Magic = 777; extern double Lot = 0.1; //-------------------------------------------------------------------- void OnTick() { for (int i=0; i<OrdersTotal(); i++) if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if (OrderSymbol()==Symbol() && Magic==OrderMagicNumber()) return; double RSI0 = iRSI(NULL,0,period_RSI,PRICE_OPEN,0); double RSI1 = iRSI(NULL,0,period_RSI,PRICE_OPEN,1); double SL=0,TP=0; if (RSI0 > buy_level && RSI1 < buy_level) { if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss* Point,Digits); if (OrderSend(Symbol(),OP_BUYLIMIT, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,NULL,Magic)==-1) Print(GetLastError()); if (OrderSend(Symbol(),OP_BUYSTOP, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,NULL,Magic)==-1) Print(GetLastError()); } if (RSI0 < sell_level && RSI1 > sell_level) { if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss* Point,Digits); if (OrderSend(Symbol(),OP_SELLLIMIT,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP,NULL,Magic)==-1) Print(GetLastError()); if (OrderSend(Symbol(),OP_SELLSTOP,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP,NULL,Magic)==-1) Print(GetLastError()); } } //-------------------------------------------------------------------- [删除] 2020.06.15 20:07 #27 Сергей Дыбленко :我昨天搞砸了我不明白他是如何设定限制的,而且并不总是设定限制并改变了一点//+------------------------------------------------------------------+ //| InstantExecution.mq4 | //| Copyright 2015, @traderconfident | //| https://confident-trader.blogspot.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, @traderconfident" #property link "https://confident-trader.blogspot.com" #property version "1.0" #property strict //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ input string _Orders_= " --- Set Order ---" ; input double Lots = 0.05 ; input int StopLoss = 1400 ; input int TakeProfit = 700 ; input int TrailingStart = 200 ; input double TrailingStop = 300 ; // Фиксированный размер трала input double TrailingStep = 50 ; // Шаг трала input int Magic = 90910 ; //------- int Slippage = 30 ; bool AllPositions = false ; // Управлять всеми позициями bool ProfitTrailing = true ; // Тралить только профит bool UseSound = true ; // Использовать звуковой сигнал string NameFileSound = "expert.wav" ; // Наименование звукового файла double _sl,_tp,_pip; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit () { _pip= Point ; if ( Digits == 3 || Digits == 5 ) _pip= 10 * Point ; //--- ObjectCreate ( 0 , "CloseButton" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_XDISTANCE , 10 ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_XSIZE , 100 ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "CloseButton" , OBJPROP_TEXT , "Close Orders" ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_BGCOLOR ,Red); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_BORDER_COLOR ,Red); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_FONTSIZE , 12 ); //Exit ObjectCreate ( 0 , "OrderLimit" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_XDISTANCE , 120 ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_XSIZE , 80 ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "OrderLimit" , OBJPROP_TEXT , "OrderLimit" ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_BGCOLOR ,Green); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_BORDER_COLOR ,Green); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_FONTSIZE , 12 ); //Buy ObjectCreate ( 0 , "Buy" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_XDISTANCE , 210 ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_XSIZE , 50 ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "Buy" , OBJPROP_TEXT , "Buy" ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "Buy" , OBJPROP_BGCOLOR ,Blue); ObjectSetInteger ( 0 , "Buy" , OBJPROP_BORDER_COLOR ,Blue); ObjectSetInteger ( 0 , "Buy" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "Buy" , OBJPROP_FONTSIZE , 12 ); //Sell ObjectCreate ( 0 , "Sell" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_XDISTANCE , 270 ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_XSIZE , 50 ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "Sell" , OBJPROP_TEXT , "Sell" ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "Sell" , OBJPROP_BGCOLOR ,Gray); ObjectSetInteger ( 0 , "Sell" , OBJPROP_BORDER_COLOR ,Gray); ObjectSetInteger ( 0 , "Sell" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "Sell" , OBJPROP_FONTSIZE , 12 ); //Closed at Profit ObjectCreate ( 0 , "CloseAtProfit" , OBJ_BUTTON , 0 , 0 , 0 ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_XDISTANCE , 330 ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_YDISTANCE , 15 ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_XSIZE , 100 ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_YSIZE , 25 ); ObjectSetString ( 0 , "CloseAtProfit" , OBJPROP_TEXT , "Close Profit" ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_COLOR ,White); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_BGCOLOR ,Green); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_BORDER_COLOR ,Green); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_BORDER_TYPE , BORDER_FLAT ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_STATE , false ); ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_FONTSIZE , 12 ); //--- return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int start() { if (TrailingStart> 0 ) TrailStopOrders(); OnChartEvent1(); return ( 0 ); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent1() { int ticket; if ( ObjectGetInteger ( 0 , "CloseAtProfit" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "CloseAtProfit" , OBJPROP_STATE , 0 ); CloseAtProfit(); } if ( ObjectGetInteger ( 0 , "CloseButton" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "CloseButton" , OBJPROP_STATE , 0 ); CloseALL(); } if ( ObjectGetInteger ( 0 , "OrderLimit" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "OrderLimit" , OBJPROP_STATE , 0 ); OnStartLimit(); } if ( ObjectGetInteger ( 0 , "Buy" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "Buy" , OBJPROP_STATE , 0 ); { ticket= OrderSend ( Symbol (),OP_BUY,Lots,Ask, 3 ,Bid-StopLoss* Point ,Ask+TakeProfit* Point , "" ,Magic, 0 ,Green); if (ticket> 0 ) { if ( OrderSelect (ticket,SELECT_BY_TICKET,MODE_TRADES)) Print ( "BUY order opened : " ,OrderOpenPrice()); } else Print ( "Error opening BUY order : " , GetLastError ()); return ; } } if ( ObjectGetInteger ( 0 , "Sell" , OBJPROP_STATE )!= 0 ) { ObjectSetInteger ( 0 , "Sell" , OBJPROP_STATE , 0 ); { ticket= OrderSend ( Symbol (),OP_SELL,Lots,Bid, 3 ,Ask+StopLoss* Point ,Bid-TakeProfit* Point , "" ,Magic, 0 ,Red); if (ticket> 0 ) { if ( OrderSelect (ticket,SELECT_BY_TICKET,MODE_TRADES)) Print ( "SELL order opened : " ,OrderOpenPrice()); } else Print ( "Error opening SELL order : " , GetLastError ()); } return ; } } //+------------------------------------------------------------------+ void TrailStopOrders() { for ( int i= 0 ; i< OrdersTotal (); i++) { if ( OrderSelect (i,SELECT_BY_POS, MODE_TRADES)) { if (AllPositions || OrderSymbol()== Symbol ()) { TrailingPositions(); } } } } //+------------------------------------------------------------------+ //| Сопровождение позиции простым тралом | //+------------------------------------------------------------------+ void TrailingPositions() { double pBid,pAsk,pp; pp=MarketInfo(OrderSymbol(),MODE_POINT); if (OrderType()==OP_BUY) { pBid=MarketInfo(OrderSymbol(),MODE_BID); if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) { if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep- 1 )*pp) { ModifyStopLoss(pBid-TrailingStop*pp); return ; } } } if (OrderType()==OP_SELL) { pAsk=MarketInfo(OrderSymbol(),MODE_ASK); if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) { if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep- 1 )*pp || OrderStopLoss()== 0 ) { ModifyStopLoss(pAsk+TrailingStop*pp); return ; } } } } //+------------------------------------------------------------------+ //| Перенос уровня StopLoss | //| Параметры: | //| ldStopLoss - уровень StopLoss | //+------------------------------------------------------------------+ void ModifyStopLoss( double ldStopLoss) { bool fm; fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(), 0 ,CLR_NONE); if (fm && UseSound) PlaySound (NameFileSound); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CloseAtProfit() { int ticket= 0 ; RefreshRates(); for ( int cnt= 0 ; cnt< OrdersTotal (); cnt++) { ticket= OrderSelect (cnt,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol()== Symbol () && OrderType()==OP_BUY && Bid>OrderOpenPrice()) { ticket=OrderClose(OrderTicket(),OrderLots(),Bid, 0 ,Violet); } if (OrderSymbol()== Symbol () && OrderType()==OP_SELL && OrderOpenPrice()>Ask) { ticket=OrderClose(OrderTicket(),OrderLots(),Ask, 0 ,Violet); } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CloseALL() { int Close_ticket= 0 ; int total= OrdersTotal (); int i = 0 ; for (i = total; i >= 0 ; i--) { if ( OrderSelect (i,SELECT_BY_POS) && OrderSymbol()== Symbol ()) { //OrderSelect(i,SELECT_BY_POS); if (OrderSymbol()== Symbol () && (OrderType()==OP_BUY || OrderType()==OP_SELL)) { Close_ticket = OrderClose(OrderTicket(),OrderLots(),MarketInfo( Symbol (),MODE_ASK), 5 ); Close_ticket = OrderClose(OrderTicket(),OrderLots(),MarketInfo( Symbol (),MODE_BID), 5 ); } } } } //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStartLimit() { if ( Digits == 3 || Digits == 5 ) { } //--define price setting script double PriceClick= NormalizeDouble (WindowPriceOnDropped(), Digits ); //--define current price double PriceCurrent= NormalizeDouble (Bid, Digits ); //--условие opening BuyLimit if (PriceClick<PriceCurrent) { BuyLimit(Lots,PriceClick,Slippage); } //--условие opening SellLimit if (PriceClick>PriceCurrent) { SellLimit(Lots,PriceClick,Slippage); } } //+------------------------------------------------------------------+ //Function for opening BuyLimit //+------------------------------------------------------------------+ void BuyLimit( double lots, double open_price, int slippage) { int ticket= OrderSend ( Symbol (),OP_BUYLIMIT,lots,open_price,slippage, 0 , 0 , "ScriptOrderLimit" , 0 , 0 , clrNONE ); if (ticket< 0 ) Print ( "Error opening BuyLimit " , GetLastError ()); else { double sl= NormalizeDouble (open_price-(StopLoss* Point ), Digits ); double tp= NormalizeDouble (open_price+(TakeProfit* Point ), Digits ); if (!OrderModify(ticket,open_price,sl,tp, 0 , clrNONE )) Print ( "Error Modify order BuyLimit " , GetLastError ()); } } //+------------------------------------------------------------------+ //Function for opening SellLimit //+------------------------------------------------------------------+ void SellLimit( double lots, double open_price, int slippage) { int ticket= OrderSend ( Symbol (),OP_SELLLIMIT,lots,open_price,slippage, 0 , 0 , "ScriptOrderLimit" , 0 , 0 , clrNONE ); if (ticket< 0 ) Print ( "Error opening SellLimit " , GetLastError ()); else { double sl= NormalizeDouble (open_price+(StopLoss* Point ), Digits ); double tp= NormalizeDouble (open_price-(TakeProfit* Point ), Digits ); if (!OrderModify(ticket,open_price,sl,tp, 0 , clrNONE )) Print ( "Error Modify Order SellLimit " , GetLastError ()); } } //+------------------------------------------------------------------+ 附加的文件: InstantExecution.mq4 27 kb Сергей Дыбленко 2020.06.15 20:20 #28 我将尝试另一个演示,然后我想今天就到此为止了............。 [删除] 2020.06.15 20:23 #29 Сергей Дыбленко: 我将在演示中再试一次,然后可能会退出,因为日............。 添加这个。当你删除一个专家时,这些按钮仍然是 //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- ObjectsDeleteAll(); } //+------------------------------------------------------------------+ Сергей Дыбленко 2020.06.15 20:23 #30 演示中的hm.........,不显示限制(()。 12345678910...18 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
插上电源-----,它没有工作。
插上这个-----,它没有工作。
在这里你可以掌握https://www.mql5.com/ru/code/23470
把这个放进去 - 没有结果
把这个 - 零结果
我在这里搞砸了——是的!并更换了拖网,它无法正常工作。
我昨天吃了这个。
我昨天搞砸了
我不明白他是如何设定限制的,而且并不总是设定限制
并改变了一点
我将在演示中再试一次,然后可能会退出,因为日............。
添加这个。当你删除一个专家时,这些按钮仍然是