B 밴드와 B 너비를 기반으로 하는 EA, 긴급 도움이 필요합니다!! - 페이지 2

 
surubabs :

맞춤법 오류가 있어 죄송합니다,

나는 이것을 위해 밴드의 너비를 원합니다. 다음과 같은 계산이 필요합니다.

폭=(상단대역-하대역)/기저대역

그래서 ea 내부에서 이 계산을 할 수 있습니까?

이것을 정의하는 방법? 내가 오류를 얻으려고했을 때,

너비[]=(상단대역[ ]-하대대역[ ])/기저대역[ ],

조언 부탁드립니다

시도하고 있는 실제 코드를 보여주세요.
 
angevoyageur :
시도하고 있는 실제 코드를 보여주세요.
아직 작업 중입니다. 내 게시물을 다시 볼 때 작업 중인 내용을 게시합니다.
 //+------------------------------------------------------------------+
//|                                            Bolinger_Width_EA.mq5 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link       "http://www.mql5.com"
#property version   "1.00"

//--- input parameters
input int bands_period= 20 ;         // Bollinger Bands period
input int bands_shift = 0 ;         // Bollinger Bands shift
input double deviation= 2 ;         // Standard deviation
input double    Lot= 1 ;             // Lots to trade
input ENUM_APPLIED_PRICE   applied_price= PRICE_CLOSE ; //type of price or handle
//--- global variables
int BolBandsHandle;                 // Bolinger Bands handle
double iBBUp[],iBBLow[],iBBMidle[];   // dynamic arrays for numerical values of Bollinger Bands
double width;
double             inputs[];         // array for storing inputs
double             weight[ 20 ];         // array for storing weights
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
  
//--- Do we have sufficient bars to work
   if ( Bars ( _Symbol , _Period )< 60 ) // total number of bars is less than 60?
     {
       Alert ( "We have less than 60 bars on the chart, an Expert Advisor terminated!!" );
       return (- 1 );
     }
//--- get handle of the Bollinger Bands and Width indicators
   BolBandsHandle= iBands ( NULL , PERIOD_M1 ,bands_period,bands_shift,deviation, PRICE_CLOSE );
//--- Check for Invalid Handle
   if (BolBandsHandle< 0 )
     {
       Alert ( "Error in creation of indicators - error: " , GetLastError (), "!!" );
       return (- 1 );
     }

   return ( 0 );
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
//--- release indicator handles
   IndicatorRelease (BolBandsHandle);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
//--- we will use the static Old_Time variable to serve the bar time.
//--- at each OnTick execution we will check the current bar time with the saved one.
//--- if the bar time isn't equal to the saved time, it indicates that we have a new tick.

   static datetime Old_Time;
   datetime New_Time[ 1 ];
   bool IsNewBar= false ;

//--- copying the last bar time to the element New_Time[0]
   int copied= CopyTime ( _Symbol , _Period , 0 , 1 ,New_Time);
   if (copied> 0 ) // ok, the data has been copied successfully
     {
       if (Old_Time!=New_Time[ 0 ]) // if old time isn't equal to new bar time
        {
         IsNewBar= true ;   // if it isn't a first call, the new bar has appeared
         if ( MQL5InfoInteger ( MQL5_DEBUGGING )) Print ( "We have new bar here " ,New_Time[ 0 ], " old time was " ,Old_Time);
         Old_Time=New_Time[ 0 ];             // saving bar time
        }
     }
   else
     {
       Alert ( "Error in copying historical times data, error =" , GetLastError ());
       ResetLastError ();
       return ;
     }

//--- EA should only check for new trade if we have a new bar
   if (IsNewBar== false )
     {
       return ;
     }

//--- do we have enough bars to work with
   int Mybars= Bars ( _Symbol , _Period );
   if (Mybars< 60 ) // if total bars is less than 60 bars
     {
       Alert ( "We have less than 60 bars, EA will now exit!!" );
       return ;
     }

   MqlRates mrate[];           // To be used to store the prices, volumes and spread of each bar   

/*
     Let's make sure our arrays values for the Rates and Indicators 
     is stored serially similar to the timeseries array
*/

// the rates arrays
   ArraySetAsSeries (mrate, true );
// the indicator arrays
   ArraySetAsSeries (iBBUp, true );
   ArraySetAsSeries (iBBLow, true );
   ArraySetAsSeries (iBBMidle, true );

//--- Get the details of the latest 3 bars
   if ( CopyRates ( _Symbol , _Period , 0 , 3 ,mrate)< 0 )
     {
       Alert ( "Error copying rates/history data - error:" , GetLastError (), "!!" );
       return ;
     }
   int err1= 0 ;
   
   err1= CopyBuffer (BolBandsHandle, 0 , 0 , 3 ,iBBMidle) || CopyBuffer (BolBandsHandle, 1 , 0 , 3 ,iBBUp)
      || CopyBuffer (BolBandsHandle, 2 , 0 , 3 ,iBBLow);
       if (err1< 0 )
     {
       Print ( "Failed to copy data from the indicator buffer" );
       return ;

     }
   double d1=- 1.0 ; //lower limit of the normalization range
   double d2= 1.0 ;   //upper limit of the normalization range
      
       double x_min= MathMin (iBBMidle[ ArrayMinimum (iBBMidle)],iBBUp[ ArrayMinimum (iBBUp)],iBBLow[ ArrayMinimum (iBBLow)]); //minimum value over the range
       double x_max= MathMax (iBBMidle[ ArrayMaximum (iBBMidle)],iBBUp[ ArrayMaximum (iBBUp)],iBBLow[ ArrayMaximum (iBBLow)]); //minimum value ove
         
     for ( int i= 0 ;i< ArraySize (inputs);i++)
     {
      inputs[i]=(((((iBBUp[i]-iBBLow[i])/iBBMidle[i])-x_min)*(d2-d1))/(x_max-x_min))+d1;
     }
//--- store the neuron calculation result in the out variable
   out=(inputs,weight);
     
   double Ask = SymbolInfoDouble ( _Symbol , SYMBOL_ASK );   // Ask price
   double Bid = SymbolInfoDouble ( _Symbol , SYMBOL_BID );   // Bid price

//--- Declare bool type variables to hold our Buy and Sell Conditions
   bool Buy_Condition =(mrate[ 1 ].close > iBBUp[ 1 ] && mrate[ 1 ].open < iBBUp[ 1 ] &&   // White (bull) candle crossed the Lower Band from below to above
                        (iBBUp[ 0 ] - iBBLow[ 0 ])>(iBBUp[ 1 ] - iBBLow[ 1 ]) && (iBBUp[ 1 ] - iBBLow[ 1 ])>(iBBUp[ 2 ] - iBBLow[ 2 ])); // and Width is growing up

   bool Sell_Condition = (mrate[ 1 ].close < iBBLow[ 1 ] && mrate[ 1 ].open > iBBLow[ 1 ] &&   // Black (bear) candle crossed the Upper Band from above to below
                          (iBBUp[ 0 ] - iBBLow[ 0 ])>(iBBUp[ 1 ] - iBBLow[ 1 ]) && (iBBUp[ 1 ] - iBBLow[ 1 ])>(iBBUp[ 2 ] - iBBLow[ 2 ])); // and Width is falling down

   bool Buy_Close=(mrate[ 1 ].close<iBBMidle[ 1 ] && mrate[ 1 ].open>iBBMidle[ 1 ]);               // Black candle crossed the Upper Band from above to below

   bool Sell_Close=(mrate[ 1 ].close>iBBMidle[ 1 ] && mrate[ 1 ].open<iBBMidle[ 1 ]);           // White candle crossed the Lower Band from below to above

   if (Buy_Condition && ! PositionSelect ( _Symbol ))     // Open long position
     {                                               // Width is growing up
      LongPositionOpen();                           // and white candle crossed the Lower Band from below to above
     }

   if (Sell_Condition && ! PositionSelect ( _Symbol ))   // Open short position
     {                                               // Width is falling down
      ShortPositionOpen();                           // and Black candle crossed the Upper Band from above to below
     }

   if (Buy_Close && PositionSelect ( _Symbol ))         // Close long position
     {                                               // Black candle crossed the Upper Band from above to below
      LongPositionClose();
     }

   if (Sell_Close && PositionSelect ( _Symbol ))         // Close short position
     {                                               // White candle crossed the Lower Band from below to above
      ShortPositionClose();
     }

   return ;
  }
//+------------------------------------------------------------------+
//| Open Long position                                               |
//+------------------------------------------------------------------+
void LongPositionOpen()
  {
   MqlTradeRequest mrequest;                             // Will be used for trade requests
   MqlTradeResult mresult;                               // Will be used for results of trade requests
   
   ZeroMemory (mrequest);
   ZeroMemory (mresult);
   
   double Ask = SymbolInfoDouble ( _Symbol , SYMBOL_ASK );     // Ask price
   double Bid = SymbolInfoDouble ( _Symbol , SYMBOL_BID );     // Bid price

   if (! PositionSelect ( _Symbol ))
     {
      mrequest.action = TRADE_ACTION_DEAL ;               // Immediate order execution
      mrequest.price = NormalizeDouble (Ask, _Digits );     // Lastest Ask price
      mrequest.sl = 0 ;                                   // Stop Loss
      mrequest.tp = 0 ;                                   // Take Profit
      mrequest.symbol = _Symbol ;                         // Symbol
      mrequest.volume = Lot;                             // Number of lots to trade
      mrequest.magic = 0 ;                                 // Magic Number
      mrequest.type = ORDER_TYPE_BUY ;                     // Buy Order
      mrequest.type_filling = ORDER_FILLING_FOK ;         // Order execution type
      mrequest.deviation= 5 ;                               // Deviation from current price
       OrderSend (mrequest,mresult);                       // Send order
     }
  }
//+------------------------------------------------------------------+
//| Open Short position                                              |
//+------------------------------------------------------------------+
void ShortPositionOpen()
  {
   MqlTradeRequest mrequest;                             // Will be used for trade requests
   MqlTradeResult mresult;                               // Will be used for results of trade requests
   
   ZeroMemory (mrequest);
   ZeroMemory (mresult);
   
   double Ask = SymbolInfoDouble ( _Symbol , SYMBOL_ASK );     // Ask price
   double Bid = SymbolInfoDouble ( _Symbol , SYMBOL_BID );     // Bid price

   if (! PositionSelect ( _Symbol ))
     {
      mrequest.action = TRADE_ACTION_DEAL ;               // Immediate order execution
      mrequest.price = NormalizeDouble (Bid, _Digits );     // Lastest Bid price
      mrequest.sl = 0 ;                                   // Stop Loss
      mrequest.tp = 0 ;                                   // Take Profit
      mrequest.symbol = _Symbol ;                         // Symbol
      mrequest.volume = Lot;                             // Number of lots to trade
      mrequest.magic = 0 ;                                 // Magic Number
      mrequest.type= ORDER_TYPE_SELL ;                     // Sell order
      mrequest.type_filling = ORDER_FILLING_FOK ;         // Order execution type
      mrequest.deviation= 5 ;                               // Deviation from current price
       OrderSend (mrequest,mresult);                       // Send order
     }
  }
//+------------------------------------------------------------------+
//| Close Long position                                              |
//+------------------------------------------------------------------+
void LongPositionClose()
  {
   MqlTradeRequest mrequest;                             // Will be used for trade requests
   MqlTradeResult mresult;                               // Will be used for results of trade requests
   
   ZeroMemory (mrequest);
   ZeroMemory (mresult);
   
   double Ask = SymbolInfoDouble ( _Symbol , SYMBOL_ASK );     // Ask price
   double Bid = SymbolInfoDouble ( _Symbol , SYMBOL_BID );     // Bid price

   if ( PositionGetInteger ( POSITION_TYPE )== POSITION_TYPE_BUY )
     {
      mrequest.action = TRADE_ACTION_DEAL ;               // Immediate order execution
      mrequest.price = NormalizeDouble (Bid, _Digits );     // Lastest Bid price
      mrequest.sl = 0 ;                                   // Stop Loss
      mrequest.tp = 0 ;                                   // Take Profit
      mrequest.symbol = _Symbol ;                         // Symbol
      mrequest.volume = Lot;                             // Number of lots to trade
      mrequest.magic = 0 ;                                 // Magic Number
      mrequest.type= ORDER_TYPE_SELL ;                     // Sell order
      mrequest.type_filling = ORDER_FILLING_FOK ;         // Order execution type
      mrequest.deviation= 5 ;                               // Deviation from current price
       OrderSend (mrequest,mresult);                       // Send order
     }
  }
//+------------------------------------------------------------------+
//| Close Short position                                             |
//+------------------------------------------------------------------+
void ShortPositionClose()
  {
   MqlTradeRequest mrequest;                             // Will be used for trade requests
   MqlTradeResult mresult;                               // Will be used for results of trade requests
   
   ZeroMemory (mrequest);
   ZeroMemory (mresult);
   
   double Ask = SymbolInfoDouble ( _Symbol , SYMBOL_ASK );     // Ask price
   double Bid = SymbolInfoDouble ( _Symbol , SYMBOL_BID );     // Bid price

   if ( PositionGetInteger ( POSITION_TYPE )== POSITION_TYPE_SELL )
     {
      mrequest.action = TRADE_ACTION_DEAL ;               // Immediate order execution
      mrequest.price = NormalizeDouble (Ask, _Digits );     // Latest ask price
      mrequest.sl = 0 ;                                   // Stop Loss
      mrequest.tp = 0 ;                                   // Take Profit
      mrequest.symbol = _Symbol ;                         // Symbol
      mrequest.volume = Lot;                             // Number of lots to trade
      mrequest.magic = 0 ;                                 // Magic Number
      mrequest.type = ORDER_TYPE_BUY ;                     // Buy order
      mrequest.type_filling = ORDER_FILLING_FOK ;         // Order execution type
      mrequest.deviation= 5 ;                               // Deviation from current price
       OrderSend (mrequest,mresult);                       // Send order
     }
  }
//+------------------------------------------------------------------+
 
surubabs :
아직 작업 중입니다. 내 게시물을 다시 볼 때 작업 중인 내용을 게시합니다.
  • 왜 문서를 읽지 않았습니까? MathMax 및 MathMin은 2개의 인수만 사용합니다.
  • 아웃이란 무엇입니까=(inputs,weight); ?
 
angevoyageur :
  • 왜 문서를 읽지 않았습니까? MathMax 및 MathMin은 2개의 인수만 사용합니다.
  • 아웃이란 무엇입니까=(inputs,weight); ?

나는 수학 함수에서 문서를 이해하려고 노력했지만 어떤 것을 사용해야 할지 모르겠는 올바른 것을 찾을 수 없었습니다.

나는 지난 몇 시간 동안 하나씩 시도해 왔으며 올바른 방법을 보여줄 수 있습니까?

 
surubabs :

나는 수학 함수에서 문서를 이해하려고 노력했지만 어떤 것을 사용해야 할지 모르겠는 올바른 것을 찾을 수 없었습니다.

나는 지난 몇 시간 동안 하나씩 시도해 왔으며 올바른 방법을 보여줄 수 있습니까?

올바른 방법은 무엇입니까?
 

안녕

MathMax 함수두 값 의 최대값을 반환합니다.

 double x_max= MathMax (iBBMidle[ ArrayMaximum (iBBMidle)],iBBUp[ ArrayMaximum (iBBUp)]);
     

MathMin 함수는 두 값 의 최소값을 반환합니다.

 double x_min= MathMin (iBBMidle[ ArrayMinimum (iBBMidle)],iBBUp[ ArrayMinimum (iBBUp)]);
 
kourosh1347 :

안녕

MathMax 함수는 두 값 의 최대값을 반환합니다.

MathMin 함수는 두 값 의 최소값을 반환합니다.

예, 잘 잡았습니다 ;-)
 
kourosh1347 :

안녕

MathMax 함수는 두 값 의 최대값을 반환합니다.

MathMin 함수는 두 값 의 최소값을 반환합니다.

네 맞아요

내가 하고 싶은 것은 iBBUp-IBBLow/iBBMiddle,

그런 다음 너비라고 이름을 지정하면 값이 너비로 돌아갑니다. 값이 증가하면 너비>0 매수 오픈(업사이드 브레이크 아웃), 너비<0 매도 오픈(다운 사이드 브레이크 아웃).

정확한 코드를 구현하는 방법을 모르겠습니다.

nural 네트워크 방식으로 코딩하려고 합니다.

그것을 암시하는 방법을 도와주세요.

 
surubabs :

네 맞아요

내가 하고 싶은 것은 iBBUp-IBBLow/iBBMiddle,

그런 다음 너비라고 이름을 지정하면 값이 너비로 돌아갑니다. 값이 증가하면 너비>0 매수 오픈(업사이드 브레이크 아웃), 너비<0 매도 오픈(다운 사이드 브레이크 아웃).

정확한 코드를 구현하는 방법을 모르겠습니다.

nural 네트워크 방식으로 코딩하려고 합니다.

그것을 암시하는 방법을 도와주세요.

인생에서 큰 목표를 갖는 것이 좋습니다.
 
surubabs :

네 맞아요

내가하고 싶은 것은 iBBUp-IBBLow/iBBMiddle,

그런 다음 너비라고 이름을 지정하면 값이 너비로 돌아갑니다. 값이 증가하면 너비>0 매수 오픈(업사이드 브레이크 아웃), 너비<0 매도 오픈(다운 사이드 브레이크 아웃).

정확한 코드를 구현하는 방법을 모르겠습니다.

nural 네트워크 방식으로 코딩하려고 합니다.

어떻게 암시하십시오 도와주세요.

신경망 은 "너비"와 어떤 관련이 있습니까? 당신을 따라가는 것은 어렵습니다.