Eu acredito que nada é impossível neste mundo, se você quiser se tornar o presidente dos EUA, nós podemos, temos que sonhar com isso e temos que começar a tentar, com um plano adequado, novamente eu digo que acredito em "Nada é impossível".
Eu não tenho nenhuma programação de retaguarda, apenas tenho uma graduação em Economia. Estou estudando MQL a partir de sucata, e tenho uma certificação de analista técnico da Bolsa de Valores de Bombaim (BSE).
Como antes, tenho tentado fazer uma ema baseada na largura com alguns outros indicadores e não quero seguir o método nural, mas para os meus estudos tentei fazer uma ema baseada na largura em nural,
último teste de um mês que anexei, mas o problema aqui é que esta ea não vai Short sell :-)
angevoyageur : O que rede neural tem a ver com sua "largura"? É difícil te seguir.
Senhor estou postando meus novos estudos, é a largura que codifiquei nas redes nural, mas o fato é que não está tomando condições curtas, você pode me ajudar a descobrir o problema?
//+------------------------------------------------------------------+//| Kundi3.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 parametersinputint StopLoss= 30 ; // Stop Lossinputint TakeProfit= 100 ; // Take Profitinputint EA_Magic= 12345 ; // EA Magic Numberinputdouble Lot= 1.0 ; // Lots to Trade//--- weight values inputdouble w0= 0.5 ;
inputdouble w1= 0.5 ;
inputdouble w2= 0.5 ;
inputdouble w3= 0.5 ;
inputdouble w4= 0.5 ;
inputdouble w5= 0.5 ;
inputdouble w6= 0.5 ;
inputdouble w7= 0.5 ;
inputdouble w8= 0.5 ;
inputdouble w9= 0.5 ;
inputdouble w10= 0.5 ;
inputdouble w11= 0.5 ;
inputdouble w12= 0.5 ;
inputdouble w13= 0.5 ;
//-------------------------int iBands_handle; // variable for storing the indicator handledouble iBands_Basebuf[]; // dynamic array for storing indicator valuesdouble iBands_Upperbuf[]; // dynamic array for storing indicator valuesdouble iBands_Lowerbuf[]; // dynamic array for storing indicator valuesdouble inputs[ 14 ]; // array for storing inputsdouble weight[ 14 ]; // array for storing weightsstring my_symbol; // variable for storing the symbolENUM_TIMEFRAMES my_timeframe; // variable for storing the time framedouble lot_size; // variable for storing the minimum lot size of the transaction to be performeddouble p_close; // Variable to store the close value of a barint STP, TKP; // To be used for Stop Loss & Take Profit valuesdouble out; // variable for storing the output neuron value//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+intOnInit ()
{
//--- Do we have sufficient bars to workif ( 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 );
}
//--- save the current chart symbol for further operation of the EA on this very symbol
my_symbol= Symbol ();
//--- save the current time frame of the chart for further operation of the EA on this very time frame
my_timeframe= PERIOD_CURRENT ;
//--- save the minimum lot of the transaction to be performed
lot_size= SymbolInfoDouble (my_symbol, SYMBOL_VOLUME_MIN );
//--- apply the indicator and get its handle
iBands_handle= iBands (my_symbol,my_timeframe, 20 , 0 , 2.0 , PRICE_CLOSE );
//--- check the availability of the indicator handleif (iBands_handle== INVALID_HANDLE )
{
//--- no handle obtained, print the error message into the log file, complete handling the errorPrint ( "Failed to get the indicator handle" );
return (- 1 );
}
//--- add the indicator to the price chartChartIndicatorAdd ( ChartID (), 0 ,iBands_handle);
//--- set the iBands_Basebuf array indexing as time seriesArraySetAsSeries (iBands_Basebuf, true );
//--- set the iBands_upper indexing as time seriesArraySetAsSeries (iBands_Upperbuf, true );
//--- set the iBands lower array indexing as time seriesArraySetAsSeries (iBands_Lowerbuf, true );
//--- place weights into the array
weight[ 0 ]=w0;
weight[ 1 ]=w1;
weight[ 2 ]=w2;
weight[ 3 ]=w3;
weight[ 4 ]=w4;
weight[ 5 ]=w5;
weight[ 6 ]=w6;
weight[ 7 ]=w7;
weight[ 8 ]=w8;
weight[ 9 ]=w9;
weight[ 10 ]=w10;
weight[ 11 ]=w11;
weight[ 12 ]=w12;
weight[ 13 ]=w13;
//--- Let us handle currency pairs with 5 or 3 digit prices instead of 4
STP = StopLoss;
TKP = TakeProfit;
if ( _Digits == 5 || _Digits == 3 )
{
STP = STP* 10 ;
TKP = TKP* 10 ;
}
return ( 0 );
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit ( constint reason)
{
//--- delete the indicator handle and deallocate the memory space it occupiesIndicatorRelease (iBands_handle);
//--- free the iBands Base dynamic array of dataArrayFree (iBands_Basebuf);
//--- free the iBand lower dynamic array of dataArrayFree (iBands_Lowerbuf);
//--- free the iBands upper dynamic array of dataArrayFree (iBands_Upperbuf);
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick ()
{
//--- Do we have enough bars to work withif ( Bars ( _Symbol , _Period )< 60 ) // if total bars is less than 60 bars
{
Alert ( "We have less than 60 bars, EA will now exit!!" );
return ;
}
// 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.staticdatetime 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 appearedif ( 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 barif (IsNewBar== false )
{
return ;
}
//--- Do we have enough bars to work withint 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 ;
}
//--- Define some MQL5 Structures we will use for our tradeMqlTick latest_price; // To be used for getting recent/latest price quotesMqlTradeRequest mrequest; // To be used for sending our trade requestsMqlTradeResult mresult; // To be used to get our trade resultsMqlRates mrate[]; // To be used to store the prices, volumes and spread of each barZeroMemory (mrequest); // Initialization of mrequest structure/*
Let's make sure our arrays values for the Rates, ADX Values and MA values
is store serially similar to the timeseries array*///--- Get the last price quote using the MQL5 MqlTick StructureArraySetAsSeries (mrate, true );
if (! SymbolInfoTick ( _Symbol ,latest_price))
{
Alert ( "Error getting the latest price quote - error:" , GetLastError (), "!!" );
return ;
}
//--- Get the details of the latest 3 barsif ( CopyRates ( _Symbol , _Period , 0 , 3 ,mrate)< 0 )
{
Alert ( "Error copying rates/history data - error:" , GetLastError (), "!!" );
ResetLastError ();
return ;
}
int err1= 0 ; // variable for storing the results of working with the upper buffer of the Bollinger band indicatorint err2= 0 ; // variable for storing the results of working with the lower buffer of the Bollinger band indicatorint err3= 0 ;
//--- copy data from the indicator array to the iBands_upper dynamic array for further work with them
err1= CopyBuffer (iBands_handle, 1 , 0 , ArraySize (inputs)/ 2 ,iBands_Upperbuf);
//--- copy data from the indicator array to the iBands_Lower dynamic array for further work with them
err2= CopyBuffer (iBands_handle, 2 , 0 , ArraySize (inputs)/ 2 ,iBands_Lowerbuf);
//--- copy data from the indicator array to the iBands_Lower dynamic array for further work with them
err3= CopyBuffer (iBands_handle, 2 , 0 , ArraySize (inputs)/ 2 ,iBands_Basebuf);
//--- in case of errors, print the relevant error message into the log file and exit the functionif (err1< 0 || err2< 0 || err3< 0 )
{
Print ( "Failed to copy data from the indicator buffer" );
return ;
}
double d1=- 1.0 ; //lower limit of the normalization rangedouble d2= 1.0 ; //upper limit of the normalization range//--- minimum value over the rangedouble x_min= MathMin (iBands_Lowerbuf[ ArrayMinimum (iBands_Lowerbuf)],iBands_Upperbuf[ ArrayMinimum (iBands_Upperbuf)]);
double x_minn=iBands_Basebuf[ ArrayMinimum (iBands_Basebuf)];
//--- maximum value over the rangedouble x_max= MathMax (iBands_Lowerbuf[ ArrayMaximum (iBands_Lowerbuf)],iBands_Upperbuf[ ArrayMaximum (iBands_Upperbuf)]);
double x_maxx=iBands_Basebuf[ ArrayMaximum (iBands_Basebuf)];
//--- In the loop, fill in the array of inputs with the pre-normalized indicator valuesfor ( int i= 0 ;i< ArraySize (inputs)/ 2 ;i++)
{
inputs[i* 2 ]=((((iBands_Upperbuf[i]-iBands_Lowerbuf[i])/iBands_Basebuf[i])-(x_min+x_minn)*(d2-d1))/((x_maxx+x_max)-(x_min+x_minn)))+d1;
}
//--- store the neuron calculation result in the out variable
out=CalculateNeuron(inputs,weight);
//--- we have no errors, so continue//--- Do we have positions opened already?bool Buy_opened= false ; // variable to hold the result of Buy opened positionbool Sell_opened= false ; // variables to hold the result of Sell opened positionif ( PositionSelect ( _Symbol )== true ) // we have an opened position
{
if ( PositionGetInteger ( POSITION_TYPE )== POSITION_TYPE_BUY )
{
Buy_opened= true ; //It is a Buy
}
elseif ( PositionGetInteger ( POSITION_TYPE )== POSITION_TYPE_SELL )
{
Sell_opened= true ; // It is a Sell
}
}
// Copy the bar close price for the previous bar prior to the current bar, that is Bar 1
p_close=mrate[ 1 ].close; // bar 1 close price/*
1. Check for a long/Buy Setup : MA-8 increasing upwards,
previous price close above it, ADX > 22, +DI > -DI
*///--- Declare bool type variables to hold our Buy Conditionsbool Buy_Condition_1=(out< 0 ); // MA-8 Increasing upwards//--- Putting all together if (Buy_Condition_1 )
{
// any opened Buy position?if (Buy_opened)
{
Alert ( "We already have a Buy Position!!!" );
return ; // Don't open a new Buy Position
}
ZeroMemory (mrequest);
mrequest.action = TRADE_ACTION_DEAL ; // immediate order execution
mrequest.price = NormalizeDouble (latest_price.ask, _Digits ); // latest ask price
mrequest.sl = NormalizeDouble (latest_price.ask - STP* _Point , _Digits ); // Stop Loss
mrequest.tp = NormalizeDouble (latest_price.ask + TKP* _Point , _Digits ); // Take Profit
mrequest.symbol = _Symbol ; // currency pair
mrequest.volume = Lot; // number of lots to trade
mrequest.magic = EA_Magic; // Order Magic Number
mrequest.type = ORDER_TYPE_BUY ; // Buy Order
mrequest.type_filling = ORDER_FILLING_RETURN ; // Order execution type
mrequest.deviation= 100 ; // Deviation from current price//--- send orderOrderSend (mrequest,mresult);
// get the result codeif (mresult.retcode== 10009 || mresult.retcode== 10008 ) //Request is completed or order placed
{
Alert ( "A Buy order has been successfully placed with Ticket#:" ,mresult.order, "!!" );
}
else
{
Alert ( "The Buy order request could not be completed -error:" , GetLastError ());
ResetLastError ();
return ;
}
}
/*
2. Check for a Short/Sell Setup : MA-8 decreasing downwards,
previous price close below it, ADX > 22, -DI > +DI
*///--- Declare bool type variables to hold our Sell Conditionsbool Sell_Condition_1 = (out> 0 ); // MA-8 decreasing downwards//--- Putting all togetherif (Sell_Condition_1 )
{
// any opened Sell position?if (Sell_opened)
{
Alert ( "We already have a Sell position!!!" );
return ; // Don't open a new Sell Position
}
ZeroMemory (mrequest);
mrequest.action= TRADE_ACTION_DEAL ; // immediate order execution
mrequest.price = NormalizeDouble (latest_price.bid, _Digits ); // latest Bid price
mrequest.sl = NormalizeDouble (latest_price.bid + STP* _Point , _Digits ); // Stop Loss
mrequest.tp = NormalizeDouble (latest_price.bid - TKP* _Point , _Digits ); // Take Profit
mrequest.symbol = _Symbol ; // currency pair
mrequest.volume = Lot; // number of lots to trade
mrequest.magic = EA_Magic; // Order Magic Number
mrequest.type= ORDER_TYPE_SELL ; // Sell Order
mrequest.type_filling = ORDER_FILLING_RETURN ; // Order execution type
mrequest.deviation= 100 ; // Deviation from current price//--- send orderOrderSend (mrequest,mresult);
// get the result codeif (mresult.retcode== 10009 || mresult.retcode== 10008 ) //Request is completed or order placed
{
Alert ( "A Sell order has been successfully placed with Ticket#:" ,mresult.order, "!!" );
}
else
{
Alert ( "The Sell order request could not be completed -error:" , GetLastError ());
ResetLastError ();
return ;
}
}
return ;
}
//+------------------------------------------------------------------+//| Neuron calculation function |//+------------------------------------------------------------------+double CalculateNeuron( double &x[], double &w[])
{
//--- variable for storing the weighted sum of inputsdouble NET= 0.0 ;
//--- Using a loop we obtain the weighted sum of inputs based on the number of inputsfor ( int n= 0 ;n< ArraySize (x);n++)
{
NET+=x[n]*w[n];
}
//--- multiply the weighted sum of inputs by the additional coefficient
NET*= 2 ;
//--- send the weighted sum of inputs to the activation function and return its valuereturn (ActivateNeuron(NET));
}
//+------------------------------------------------------------------+//| Activation function |//+------------------------------------------------------------------+double ActivateNeuron( double x)
{
//--- variable for storing the activation function resultsdouble Out;
//--- hyperbolic tangent function
Out=( exp (x)- exp (-x))/( exp (x)+ exp (-x));
//--- return the activation function valuereturn (Out);
}
//+------------------------------------------------------------------+
EA que você postou acima se chama Kundi3, mas post anterior com resultado do Strategy Tester mostra Kundi5, ou você tem certeza de que este é o mesmo ?
Eu acredito que nada é impossível neste mundo, se você quiser se tornar o presidente dos EUA, nós podemos, temos que sonhar com isso e temos que começar a tentar, com um plano adequado, novamente eu digo que acredito em "Nada é impossível".
Eu não tenho nenhuma programação de retaguarda, apenas tenho uma graduação em Economia. Estou estudando MQL a partir de sucata, e tenho uma certificação de analista técnico da Bolsa de Valores de Bombaim (BSE).
Como antes, tenho tentado fazer uma ema baseada na largura com alguns outros indicadores e não quero seguir o método nural, mas para os meus estudos tentei fazer uma ema baseada na largura em nural,
último teste de um mês que anexei, mas o problema aqui é que esta ea não vai Short sell :-)
Respeito seu otimismo, mas não o compartilho. De qualquer forma, fico feliz se puder ajudá-lo, mas ainda não sei nada sobre rede neural.
Seu CalculateNeuron() nunca retorna um número positivo, você tem que verificar seus parâmetros de entrada (entradas e peso) e sua função. Use a função Print para depurar seu código.
surubabs: sim, é o mesmo, ele feliz bcoz de um passado de copay completo de e. u. u pode voltar a testá-lo senhor.
Algumas perguntas:
1. você treinou a rede neural - otimização dos parâmetros de peso no testador de estratégia? 2. como função de ativação "tangente hiperbólica" que os pesos devem estar na faixa de -1 a 1, você está tomando um valor negativo após a otimização?
Neste ponto do último relatório, posso ver que todos os pesos são positivos, portanto, esperamos que o resultado negativo da rede neural não faça sentido, aqui são obtidos de apenas um ramo da tangente hiperbólica e, como conseqüência, a abertura comercializa apenas em uma direção.
1. você treinou a rede neural - otimização dos parâmetros de peso no testador de estratégia? 2. como função de ativação "tangente hiperbólica" que os pesos devem estar na faixa de -1 a 1, você está tomando um valor negativo após a otimização?
Neste ponto do último relatório, posso ver que todos os pesos são positivos, portanto, esperamos que o resultado negativo da rede neural não faça sentido, aqui são obtidos de apenas um ramo da tangente hiperbólica e, como conseqüência, a abertura comercializa apenas em uma direção.
Meu teste
Senhor, o que você fez No bacalhau para obter um resultado como este, eu não poderia executar o testador de estratégia com a configuração do parameater que você explica em seu artigo, depois de selecionar os parâmetros no Testador eu cliquei em start butten, mas não é
testes .
Devo mudar a fórmula de cálculo neural de Hyperbolic para sigmoid ?
ou há alguma outra função para obter um resultado como você tem?
ou eu deveria mudar o manual de pesos de 0,5 para algum outro ?
É muito mais fácil do que você pensa. Leia novamente meu artigo sobre redes neurais, em particular a parte do "Putting It All Together" (Colocando tudo junto). Após o código da Figura 7, há uma descrição de como otimizar os parâmetros de peso.
Preste atenção às opções, primeiro escolha os parâmetros de otimização, e depois desligue a otimização.
Caro angevoyager,
Eu acredito que nada é impossível neste mundo, se você quiser se tornar o presidente dos EUA, nós podemos, temos que sonhar com isso e temos que começar a tentar, com um plano adequado, novamente eu digo que acredito em "Nada é impossível".
Eu não tenho nenhuma programação de retaguarda, apenas tenho uma graduação em Economia. Estou estudando MQL a partir de sucata, e tenho uma certificação de analista técnico da Bolsa de Valores de Bombaim (BSE).
Como antes, tenho tentado fazer uma ema baseada na largura com alguns outros indicadores e não quero seguir o método nural, mas para os meus estudos tentei fazer uma ema baseada na largura em nural,
último teste de um mês que anexei, mas o problema aqui é que esta ea não vai Short sell :-)
O que rede neural tem a ver com sua "largura"? É difícil te seguir.
Caro angevoyager,
Eu acredito que nada é impossível neste mundo, se você quiser se tornar o presidente dos EUA, nós podemos, temos que sonhar com isso e temos que começar a tentar, com um plano adequado, novamente eu digo que acredito em "Nada é impossível".
Eu não tenho nenhuma programação de retaguarda, apenas tenho uma graduação em Economia. Estou estudando MQL a partir de sucata, e tenho uma certificação de analista técnico da Bolsa de Valores de Bombaim (BSE).
Como antes, tenho tentado fazer uma ema baseada na largura com alguns outros indicadores e não quero seguir o método nural, mas para os meus estudos tentei fazer uma ema baseada na largura em nural,
último teste de um mês que anexei, mas o problema aqui é que esta ea não vai Short sell :-)
Respeito seu otimismo, mas não o compartilho. De qualquer forma, fico feliz se puder ajudá-lo, mas ainda não sei nada sobre rede neural.
Obviamente, como sua condição de venda é :
e sair é :Seu CalculateNeuron() nunca retorna um número positivo, você tem que verificar seus parâmetros de entrada (entradas e peso) e sua função. Use a função Print para depurar seu código.
sim, é o mesmo, ele feliz bcoz de um passado de copay completo de e. u. u pode voltar a testá-lo senhor.
Algumas perguntas:
1. você treinou a rede neural - otimização dos parâmetros de peso no testador de estratégia?
2. como função de ativação "tangente hiperbólica" que os pesos devem estar na faixa de -1 a 1, você está tomando um valor negativo após a otimização?
Neste ponto do último relatório, posso ver que todos os pesos são positivos, portanto, esperamos que o resultado negativo da rede neural não faça sentido, aqui são obtidos de apenas um ramo da tangente hiperbólica e, como conseqüência, a abertura comercializa apenas em uma direção.
Meu teste
Algumas perguntas:
1. você treinou a rede neural - otimização dos parâmetros de peso no testador de estratégia?
2. como função de ativação "tangente hiperbólica" que os pesos devem estar na faixa de -1 a 1, você está tomando um valor negativo após a otimização?
Neste ponto do último relatório, posso ver que todos os pesos são positivos, portanto, esperamos que o resultado negativo da rede neural não faça sentido, aqui são obtidos de apenas um ramo da tangente hiperbólica e, como conseqüência, a abertura comercializa apenas em uma direção.
Meu teste
Senhor, o que você fez No bacalhau para obter um resultado como este, eu não poderia executar o testador de estratégia com a configuração do parameater que você explica em seu artigo, depois de selecionar os parâmetros no Testador eu cliquei em start butten, mas não é
testes .
Devo mudar a fórmula de cálculo neural de Hyperbolic para sigmoid ?
ou há alguma outra função para obter um resultado como você tem?
ou eu deveria mudar o manual de pesos de 0,5 para algum outro ?
como calcular o peso ?
É muito mais fácil do que você pensa.
Leia novamente meu artigo sobre redes neurais, em particular a parte do "Putting It All Together" (Colocando tudo junto).
Após o código da Figura 7, há uma descrição de como otimizar os parâmetros de peso.
Preste atenção às opções, primeiro escolha os parâmetros de otimização, e depois desligue a otimização.
Caro angevoyager,
Eu acredito que nada é impossível neste mundo,