[경고, 주제 닫힘!] 포럼을 어지럽히지 않도록 모든 초보자 질문. 프로, 놓치지 마세요. 당신 없이는 어디에도 없습니다. - 페이지 113

 
mukata >> :

그럼 질문은?

매번 함수를 호출하는 것보다 변수에 저장하는 것이 더 빠릅니다.

그건 그렇고, 이것은 테스터에서 쉽게 확인됩니다.

 
StatBars >> :
코드를 어디에 숨겼습니까? 나는 단지 그를 교정하고 싶었지만 그는 이미 ...


//+------------------------------------------------------------------+
//| Copyright © 2009, ::: -- SAMER -- ::: |
//| E-MAIL: camep@inbox.ru icq: 422372555 |
//+------------------------------------------------------------------+

extern double TakeProfit = 500;
extern double Lots = 0.1;
extern double Stoploss = 30;
extern double TrailingStop = 30;
extern int iWPRperiod1 = 50;
extern int iWPRperiod2 = 60;
extern int iWPRperiod3 = 60;
extern int iWPRperiod4 = 50;
extern int slowing = 3;
extern int period = 3;
extern int period2 = 5;

int start()
{
double a;
int b;
int total;
int ticket;
int cnt;
int iWPRperiod1;
int iWPRperiod2;
int iWPRperiod3;
int iWPRperiod4;
int slowing;
int period;
int period2;

if(Bars<100)
{
Print("bars less than 100");
return(0);
}

if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0);
}

total=OrdersTotal();
if(total<1)
{

if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if((iWPR(NULL,0,iWPRperiod1,0)>iWPR(NULL,0, iWPRperiod2,0)) < iStochastic(NULL,0,period2,period,slowing,0,0,0,0) )

{
ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-Stoploss*Point, Ask+TakeProfit*Point,"comment",16384,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(0);
}

if((iWPR(NULL,0,iWPRperiod1,0)>iWPR(NULL,0, iWPRperiod2,0)) > iStochastic(NULL,0,period2,period,slowing,0,0,0,0) )
{
ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+Stoploss*Point,Bid-TakeProfit*Point,"macd sample",16384,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(0);
}
return(0);
}

for(cnt=0; cnt < total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol())

{
if(OrderType()==OP_BUY)
{
if(iWPR(NULL,0,iWPRperiod1,0)>iWPR(NULL,0, iWPRperiod2,0))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet)
return(0);
}

if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
}
else
{
if(iWPR(NULL,0,iWPRperiod3,0)<iWPR(NULL,0, iWPRperiod4,0))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
return(0);
}
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
return(0);
}

 
TheXpert >> :

매번 함수를 호출하는 것보다 변수에 저장하는 것이 더 빠릅니다.

그건 그렇고, 이것은 테스터에서 쉽게 확인됩니다.

감사합니다 저도 그렇게 생각했습니다.

그러나 이 포럼에서 내가 읽은 코드의 양 - 아무도 이것을 하지 않고 모든 사람이 매번 함수를 호출합니다. 나도 거기에 있어.

기능은 명확하지만 배열은 어떻습니까?

추신 최근 여기에 ...

 
//+------------------------------------------------------------------+
//| Copyright © 2009, ::: -- SAMER -- ::: |
//| E-MAIL: camep@inbox.ru icq: 422372555 |
//+------------------------------------------------------------------+

extern double TakeProfit = 500 ;
extern double Lots = 0.1 ;
extern double Stoploss = 30 ;
extern double TrailingStop = 30 ;
extern int iWPRperiod1 = 50 ;
extern int iWPRperiod2 = 60 ;
extern int iWPRperiod3 = 60 ;
extern int iWPRperiod4 = 50 ;
extern int slowing = 3 ;
extern int period = 3 ;
extern int period2 = 5 ;

int start ( )
{
   double a ;
   int b ;
   int total ;
   int ticket ;
   int cnt ;
   int iWPRperiod1 ;
   int iWPRperiod2 ;
   int iWPRperiod3 ;
   int iWPRperiod4 ;
   int slowing ;
   int period ;
   int period2 ;

   if ( Bars < 100 )
   {
       Print ( "bars less than 100" ) ;
       return ( 0 ) ;
   }

   if ( TakeProfit < 10 )
   {
       Print ( "TakeProfit less than 10" ) ;
       return ( 0 ) ;
   }

   total = OrdersTotal ( ) ;
   if ( total < 1 )
   {

       if ( AccountFreeMargin ( ) < ( 1000 * Lots ) )
       {
         Print ( "We have no money. Free Margin = " , AccountFreeMargin ( ) ) ;
         return ( 0 ) ;
       }

       if ( ( iWPR ( NULL , 0 , iWPRperiod1 , 0 ) > iWPR ( NULL , 0 , iWPRperiod2 , 0 ) ) < iStochastic ( NULL , 0 , period2 , period , slowing , 0 , 0 , 0 , 0 ) )
       {
         ticket = OrderSend ( Symbol ( ) , OP_BUY , Lots , Ask , 3 , Ask - Stoploss * Point , Ask + TakeProfit * Point , "comment" , 16384 , 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 ( 0 ) ;
         }
       }
       if ( ( iWPR ( NULL , 0 , iWPRperiod1 , 0 ) > iWPR ( NULL , 0 , iWPRperiod2 , 0 ) ) > iStochastic ( NULL , 0 , period2 , period , slowing , 0 , 0 , 0 , 0 ) )
       {
         ticket = OrderSend ( Symbol ( ) , OP_SELL , Lots , Bid , 3 , Bid + Stoploss * Point , Bid - TakeProfit * Point , "macd sample" , 16384 , 0 , Red ) ;
         if ( ticket > 0 & & OrderSelect ( ticket , SELECT_BY_TICKET , MODE_TRADES ) ) Print ( "SELL order opened : " , OrderOpenPrice ( ) ) ;
         else 
         {
             Print ( "Error opening SELL order : " , GetLastError ( ) ) ;
             return ( 0 ) ;
         }
       }
       return ( 0 ) ;
   }   

   for ( cnt = 0 ; cnt < total ; cnt + + )
   {
       OrderSelect ( cnt , SELECT_BY_POS , MODE_TRADES ) ;
       if ( OrderType ( ) < = OP_SELL & & OrderSymbol ( ) = = Symbol ( ) ) 
       {
         if ( OrderType ( ) = = OP_BUY )
         {
             if ( iWPR ( NULL , 0 , iWPRperiod1 , 0 ) > iWPR ( NULL , 0 , iWPRperiod2 , 0 ) )
             {
               OrderClose ( OrderTicket ( ) , OrderLots ( ) , Bid , 3 , Violet ) ;
               return ( 0 ) ; 
             }
             if ( TrailingStop > 0 )
             {
               if ( Bid - OrderOpenPrice ( ) > Point * TrailingStop )
               {
                   if ( OrderStopLoss ( ) < Bid - Point * TrailingStop )
                   {
                     OrderModify ( OrderTicket ( ) , OrderOpenPrice ( ) , Bid - Point * TrailingStop , OrderTakeProfit ( ) , 0 , Green ) ;
                     return ( 0 ) ;
                   }
               }
             }
         }
         else
         {
             if ( iWPR ( NULL , 0 , iWPRperiod3 , 0 ) < iWPR ( NULL , 0 , iWPRperiod4 , 0 ) )
             {
               OrderClose ( OrderTicket ( ) , OrderLots ( ) , Ask , 3 , Violet ) ;
               return ( 0 ) ;
             }
             if ( TrailingStop > 0 )
             {
               if ( ( OrderOpenPrice ( ) - Ask ) > ( Point * TrailingStop ) )
               {
                   if ( ( OrderStopLoss ( ) > ( Ask + Point * TrailingStop ) ) | | ( OrderStopLoss ( ) = = 0 ) )
                   {
                     OrderModify ( OrderTicket ( ) , OrderOpenPrice ( ) , Ask + Point * TrailingStop , OrderTakeProfit ( ) , 0 , Red ) ;
                     return ( 0 ) ;
                   }
               }
             }
         }
       }
   }
return ( 0 ) ;
}

가장 간단한 구문 오류를 수정했습니다. 가장 "쉬운" 오류인 논리적 오류를 수정해야 합니다. :)

 
if ( ( iWPR ( NULL , 0 , iWPRperiod1 , 0 ) > iWPR ( NULL , 0 , iWPRperiod2 , 0 ) ) < iStochastic ( NULL , 0 , period2 , period , slowing , 0 , 0 , 0 , 0 ) )
if ( ( iWPR ( NULL , 0 , iWPRperiod1 , 0 ) > iWPR ( NULL , 0 , iWPRperiod2 , 0 ) ) > iStochastic ( NULL , 0 , period2 , period , slowing , 0 , 0 , 0 , 0 ) )
이상한 디자인.
 
StatBars >> :

저에게 복사하는 방법^^

프로그램에 복사하면 모든 것이 한 줄(

 
FOREXMASTER писал(а) >>

저에게 복사하는 방법^^

프로그램에 복사하면 모든 것이 한 줄(

파일:
 
StatBars >> :

고맙습니다!)

 
TheXpert >> :

매번 함수를 호출하는 것보다 변수에 저장하는 것이 더 빠릅니다.

그건 그렇고, 이것은 테스터에서 쉽게 확인됩니다.

기능은 명확하지만 배열은 어떻습니까?

또한 테스터에서 구동하기 위해 많이 다시 작성하십시오.

변수를 사용하는 것이 매번 함수를 호출하는 것보다 빠르고 배열 요소가 간단한 변수를 읽는 것만큼 빠릅니까?

이상, 배열입니까, 인덱스로 찾아야합니까, 아니면 변수와 동일합니까?

나는 이러한 미묘함을 이해하지 못한다.

 
mukata >> :

기능은 명확하지만 배열은 어떻습니까?

나는 이러한 미묘함을 이해하지 못한다.

코드 예제로 보여주는 것이 좋습니다.


배열에는 모호함이 있습니다.


EA에는 데이터 해석과 관련된 배열이 포함되어서는 안 된다고 생각합니다. 그들은 지표에 자리가 있습니다.

여기 많은 사람들이 다르게 생각합니다. 그리고 그들은 조언자에게 모든 것을 집어 넣으려고 합니다.

사유: