MQL4 및 MQL5에 대한 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론 - 페이지 1371 1...136413651366136713681369137013711372137313741375137613771378...1953 새 코멘트 Сергей Дыбленко 2021.01.30 10:36 #13701 MakarFX : 고문의 맨 아래까지 불행히도, 그것은 곱하지 않습니다!((( Tretyakov Rostyslav 2021.01.30 10:41 #13702 Сергей Дыбленко : 불행히도, 그것은 곱하지 않습니다!((( 이 기능은 여유 증거금과 지정된 위험에 대한 로트를 계산합니다! 무슨 곱셈을 말씀하시는 건가요? Сергей Дыбленко 2021.01.30 10:47 #13703 MakarFX : 이 기능은 여유 증거금과 지정된 위험에 대한 로트를 계산합니다! 무슨 곱셈을 말씀하시는 건가요? 각 이익 후에 제비를 늘리는 것에 대해! Tretyakov Rostyslav 2021.01.30 10:52 #13704 Сергей Дыбленко : 각 이익 후에 제비를 늘리는 것에 대해! 이 기능은 이익 후에 로트를 늘리지만 이익이 허용하는 경우 최소 로트 단계 [삭제] 2021.01.30 10:54 #13705 Сергей Дыбленко : 각 이익 후에 제비를 늘리는 것에 대해! 다음은 최대 10,000 잔액의 예입니다. 로트는 0.5 로트로 10,000에서 20,000까지 0.1이 열립니다. 20,000에서 40,000(로트 1.0 포함)에서 40,000 이상(로트 2.0 포함) //+------------------------------------------------------------------+ //| Moving Average.mq4 | //| Copyright 2005-2014, MetaQuotes Software Corp. | //| http://www.mql4.com | //+------------------------------------------------------------------+ #property copyright "2005-2014, MetaQuotes Software Corp." #property link "http://www.mql4.com" #property description "Moving Average sample expert advisor" #define MAGICMA 20131111 //--- Inputs input double InpLots = 0.1 ; input int MovingPeriod = 12 ; input int MovingShift = 6 ; //+------------------------------------------------------------------+ //| Calculate open positions | //+------------------------------------------------------------------+ int CalculateCurrentOrders( string symbol) { int buys= 0 ,sells= 0 ; //--- for ( int i= 0 ; i< OrdersTotal (); i++) { if ( OrderSelect (i,SELECT_BY_POS,MODE_TRADES)== false ) break ; if (OrderSymbol()== Symbol () && OrderMagicNumber()==MAGICMA) { if (OrderType()==OP_BUY) buys++; if (OrderType()==OP_SELL) sells++; } } //--- return orders volume if (buys> 0 ) return (buys); else return (-sells); } //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double LotsOptimized() { double Lots=InpLots; double ab=AccountBalance(); if (ab>= 10000 && ab< 20000 ) Lots= 0.5 ; if (ab>= 20000 && ab< 40000 ) Lots= 1.0 ; if (ab>= 40000 ) Lots= 2.0 ; return (Lots); } //+------------------------------------------------------------------+ //| Check for open order conditions | //+------------------------------------------------------------------+ void CheckForOpen() { double ma; int res; //--- go trading only for first tiks of new bar if (Volume[ 0 ]> 1 ) return ; //--- get Moving Average ma= iMA ( NULL , 0 ,MovingPeriod,MovingShift, MODE_SMA , PRICE_CLOSE , 0 ); //--- sell conditions if (Open[ 1 ]>ma && Close[ 1 ]<ma) { res= OrderSend ( Symbol (),OP_SELL, LotsOptimized() ,Bid, 3 , 0 , 0 , "" ,MAGICMA, 0 ,Red); return ; } //--- buy conditions if (Open[ 1 ]<ma && Close[ 1 ]>ma) { res= OrderSend ( Symbol (),OP_BUY, LotsOptimized() ,Ask, 3 , 0 , 0 , "" ,MAGICMA, 0 ,Blue); return ; } //--- } //+------------------------------------------------------------------+ //| Check for close order conditions | //+------------------------------------------------------------------+ void CheckForClose() { double ma; //--- go trading only for first tiks of new bar if (Volume[ 0 ]> 1 ) return ; //--- get Moving Average ma= iMA ( NULL , 0 ,MovingPeriod,MovingShift, MODE_SMA , PRICE_CLOSE , 0 ); //--- for ( int i= 0 ; i< OrdersTotal (); i++) { if ( OrderSelect (i,SELECT_BY_POS,MODE_TRADES)== false ) break ; if (OrderMagicNumber()!=MAGICMA || OrderSymbol()!= Symbol ()) continue ; //--- check order type if (OrderType()==OP_BUY) { if (Open[ 1 ]>ma && Close[ 1 ]<ma) { if (!OrderClose(OrderTicket(),OrderLots(),Bid, 3 ,White)) Print ( "OrderClose error " , GetLastError ()); } break ; } if (OrderType()==OP_SELL) { if (Open[ 1 ]<ma && Close[ 1 ]>ma) { if (!OrderClose(OrderTicket(),OrderLots(),Ask, 3 ,White)) Print ( "OrderClose error " , GetLastError ()); } break ; } } //--- } //+------------------------------------------------------------------+ //| OnTick function | //+------------------------------------------------------------------+ void OnTick () { //--- check for history and trading if ( Bars < 100 || IsTradeAllowed()== false ) return ; //--- calculate open orders by current symbol if (CalculateCurrentOrders( Symbol ())== 0 ) CheckForOpen(); else CheckForClose(); //--- } //+------------------------------------------------------------------+ Tretyakov Rostyslav 2021.01.30 11:05 #13706 SanAlex : 다음은 최대 10,000 잔액의 예입니다. 로트는 0.5 로트로 10,000에서 20,000까지 0.1이 열립니다. 20,000에서 40,000(로트 1.0 포함)에서 40,000 이상(로트 2.0 포함) 이것은 고정 로트 증가입니다. 이익이 다음보다 크거나 같으면 MarketInfo( Symbol (), MODE_MARGINREQUIRED)*MarketInfo( Symbol (), MODE_LOTSTEP) 그러면 많이 증가할 것입니다. 그러나 마진을 사용하는 다른 미결 주문이 없는 경우. [삭제] 2021.01.30 11:13 #13707 MakarFX : 이것은 고정 로트 증가입니다. 이익이 다음보다 크거나 같으면 그러면 많이 증가할 것입니다. 그러나 마진을 사용하는 다른 미결 주문이 없는 경우. 그래서 속임수를 썼습니다. 포지션이 빨간색이면 로트가 늘어날 것입니다. //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double OptimizedBuy( void ) { double PROFIT_BUY= 0.00 ; for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) // returns the number of open positions { if ( OrderSelect (i,SELECT_BY_POS) && OrderSymbol()== Symbol ()) { if (OrderSymbol()== Symbol () && OrderType()==OP_BUY) { PROFIT_BUY=PROFIT_BUY+ NormalizeDouble (OrderProfit(), 2 ); } } } double Lots=InpLots; double ab=PROFIT_BUY; if (ab<- 1 && ab>=-InpLots_01) Lots=InpLots1; if (ab<-InpLots_01 && ab>=-InpLots_02) Lots=InpLots2; if (ab<-InpLots_02 && ab>=-InpLots_03) Lots=InpLots3; if (ab<-InpLots_03) Lots=InpLots4; //--- return trading volume return (Lots); } //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double OptimizedSell( void ) { double PROFIT_SELL= 0.00 ; for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) // returns the number of open positions { if ( OrderSelect (i,SELECT_BY_POS) && OrderSymbol()== Symbol ()) { if (OrderSymbol()== Symbol () && OrderType()==OP_SELL) { PROFIT_SELL=PROFIT_SELL+ NormalizeDouble (OrderProfit(), 2 ); } } } double Lots=InpLots; double ab=PROFIT_SELL; if (ab<- 1 && ab>=-InpLots_01) Lots=InpLots1; if (ab<-InpLots_01 && ab>=-InpLots_02) Lots=InpLots2; if (ab<-InpLots_02 && ab>=-InpLots_03) Lots=InpLots3; if (ab<-InpLots_03) Lots=InpLots4; //--- return trading volume return (Lots); } //+------------------------------------------------------------------+ Сергей Дыбленко 2021.01.30 11:32 #13708 도움을 주신 모든 분들께 감사드립니다. 하지만 제 두뇌는 제가 필요한 일을 하기에 충분하지 않습니다! Tretyakov Rostyslav 2021.01.30 11:39 #13709 Сергей Дыбленко : 도움을 주신 모든 분들께 감사드립니다. 하지만 제 두뇌는 제가 필요한 일을 하기에 충분하지 않습니다! 당신은 당신이 필요로하는 것을 설명합니다. 진행 중인 주문 수, 동시에 거래하는 쌍 수, 거래당 위험(있는 경우) 글쎄, 나 자신의 다른 것) Tretyakov Rostyslav 2021.01.30 11:42 #13710 SanAlex : 그래서 속임수를 썼습니다 - 포지션이 빨간색이면 로트가 늘어날 것입니다. 계수에 의해 많이 증가하도록 사샤를 약간 수정했습니다. input double factor= 1.05 ; // коофициент умножения //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double OptimizedSell( void ) { double Lots = 0.00 ; double PROFIT_BUY = 0.00 ; double LOT_BUY = 0.00 ; double PROFIT_SELL= 0.00 ; double LOT_SELL = 0.00 ; for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) // returns the number of open positions { if ( OrderSelect (i,SELECT_BY_POS,MODE_HISTORY)== true ) { if (OrderSymbol()== Symbol ()) { if (OrderType()==OP_BUY) { PROFIT_BUY=PROFIT_BUY+ NormalizeDouble (OrderProfit(), 2 ); LOT_BUY =LOT_BUY+ NormalizeDouble (OrderLots(), 2 ); } if (OrderType()==OP_SELL) { PROFIT_SELL=PROFIT_SELL+ NormalizeDouble (OrderProfit(), 2 ); LOT_SELL =LOT_SELL+ NormalizeDouble (OrderLots(), 2 ); } } } } if (PROFIT_BUY< 0 ) Lots=LOT_BUY*factor; else Lots=LOT_BUY; if (PROFIT_SELL< 0 ) Lots=LOT_SELL*factor; else Lots=LOT_SELL; //--- return trading volume return (Lots); } //+------------------------------------------------------------------+ 1...136413651366136713681369137013711372137313741375137613771378...1953 새 코멘트 트레이딩 기회를 놓치고 있어요: 무료 트레이딩 앱 복사용 8,000 이상의 시그널 금융 시장 개척을 위한 경제 뉴스 등록 로그인 공백없는 라틴 문자 비밀번호가 이 이메일로 전송될 것입니다 오류 발생됨 Google으로 로그인 웹사이트 정책 및 이용약관에 동의합니다. 계정이 없으시면, 가입하십시오 MQL5.com 웹사이트에 로그인을 하기 위해 쿠키를 허용하십시오. 브라우저에서 필요한 설정을 활성화하시지 않으면, 로그인할 수 없습니다. 사용자명/비밀번호를 잊으셨습니까? Google으로 로그인
고문의 맨 아래까지
불행히도, 그것은 곱하지 않습니다!(((
불행히도, 그것은 곱하지 않습니다!(((
이 기능은 여유 증거금과 지정된 위험에 대한 로트를 계산합니다!
무슨 곱셈을 말씀하시는 건가요?
이 기능은 여유 증거금과 지정된 위험에 대한 로트를 계산합니다!
무슨 곱셈을 말씀하시는 건가요?
각 이익 후에 제비를 늘리는 것에 대해!
각 이익 후에 제비를 늘리는 것에 대해!
이 기능은 이익 후에 로트를 늘리지만 이익이 허용하는 경우 최소 로트 단계
각 이익 후에 제비를 늘리는 것에 대해!
다음은 최대 10,000 잔액의 예입니다. 로트는 0.5 로트로 10,000에서 20,000까지 0.1이 열립니다.
20,000에서 40,000(로트 1.0 포함)에서 40,000 이상(로트 2.0 포함)
다음은 최대 10,000 잔액의 예입니다. 로트는 0.5 로트로 10,000에서 20,000까지 0.1이 열립니다.
20,000에서 40,000(로트 1.0 포함)에서 40,000 이상(로트 2.0 포함)
이것은 고정 로트 증가입니다.
이익이 다음보다 크거나 같으면
그러면 많이 증가할 것입니다.
그러나 마진을 사용하는 다른 미결 주문이 없는 경우.
이것은 고정 로트 증가입니다.
이익이 다음보다 크거나 같으면
그러면 많이 증가할 것입니다.
그러나 마진을 사용하는 다른 미결 주문이 없는 경우.
그래서 속임수를 썼습니다. 포지션이 빨간색이면 로트가 늘어날 것입니다.
도움을 주신 모든 분들께 감사드립니다. 하지만 제 두뇌는 제가 필요한 일을 하기에 충분하지 않습니다!
당신은 당신이 필요로하는 것을 설명합니다.
진행 중인 주문 수, 동시에 거래하는 쌍 수, 거래당 위험(있는 경우)
글쎄, 나 자신의 다른 것)
그래서 속임수를 썼습니다 - 포지션이 빨간색이면 로트가 늘어날 것입니다.
계수에 의해 많이 증가하도록 사샤를 약간 수정했습니다.