少し調整が必要 - ページ 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 うーん............デモでは限界が表示されない(( 12345678910...18 新しいコメント 取引の機会を逃しています。 無料取引アプリ 8千を超えるシグナルをコピー 金融ニュースで金融マーケットを探索 新規登録 ログイン スペースを含まないラテン文字 このメールにパスワードが送信されます エラーが発生しました Googleでログイン WebサイトポリシーおよびMQL5.COM利用規約に同意します。 新規登録 MQL5.com WebサイトへのログインにCookieの使用を許可します。 ログインするには、ブラウザで必要な設定を有効にしてください。 ログイン/パスワードをお忘れですか? Googleでログイン
プラグを差し込む---作動しない
これを差し込むと---うまくいかない。
ここでは、https://www.mql5.com/ru/code/23470 をマスターすることができます。
これを入れる - 結果なし
これを入れてください-ゼロの結果
私はここを台無しにしました-はい!トロールを交換したところ、正しく機能しませんでした。
昨日はこれを食べました。
私は昨日これを台無しにしました
彼がどのように制限を設定しているか理解できず、常に制限を設定するとは限りません
少し変更しました
デモでもう一度やってみて、多分その日は辞めると思います......。
エキスパートを削除しても、ボタンは残ります。