angevoyageur: Muestre el código real de lo que está tratando por favor.
Todavía estoy trabajando en ello, señor, cuando u repetición a mi puesto, publico lo que estoy trabajando en él,
//+------------------------------------------------------------------+//| 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 parametersinputint bands_period= 20; // Bollinger Bands periodinputint bands_shift = 0; // Bollinger Bands shiftinputdouble deviation= 2; // Standard deviationinputdouble Lot=1; // Lots to tradeinputENUM_APPLIED_PRICE applied_price=PRICE_CLOSE; //type of price or handle//--- global variablesint BolBandsHandle; // Bolinger Bands handledouble iBBUp[],iBBLow[],iBBMidle[]; // dynamic arrays for numerical values of Bollinger Bandsdouble width;
double inputs[]; // array for storing inputsdouble weight[20]; // array for storing weights//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+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);
}
//--- get handle of the Bollinger Bands and Width indicators
BolBandsHandle=iBands(NULL,PERIOD_M1,bands_period,bands_shift,deviation,PRICE_CLOSE);
//--- Check for Invalid Handleif(BolBandsHandle<0)
{
Alert("Error in creation of indicators - error: ",GetLastError(),"!!");
return(-1);
}
return(0);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//--- release indicator handlesIndicatorRelease(BolBandsHandle);
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//--- 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;
}
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 arraysArraySetAsSeries(mrate,true);
// the indicator arraysArraySetAsSeries(iBBUp,true);
ArraySetAsSeries(iBBLow,true);
ArraySetAsSeries(iBBMidle,true);
//--- Get the details of the latest 3 barsif(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 rangedouble d2=1.0; //upper limit of the normalization rangedouble x_min=MathMin(iBBMidle[ArrayMinimum(iBBMidle)],iBBUp[ArrayMinimum(iBBUp)],iBBLow[ArrayMinimum(iBBLow)]); //minimum value over the rangedouble x_max=MathMax(iBBMidle[ArrayMaximum(iBBMidle)],iBBUp[ArrayMaximum(iBBUp)],iBBLow[ArrayMaximum(iBBLow)]); //minimum value ovefor(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 pricedouble Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Bid price//--- Declare bool type variables to hold our Buy and Sell Conditionsbool 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 upbool 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 downbool Buy_Close=(mrate[1].close<iBBMidle[1] && mrate[1].open>iBBMidle[1]); // Black candle crossed the Upper Band from above to belowbool Sell_Close=(mrate[1].close>iBBMidle[1] && mrate[1].open<iBBMidle[1]); // White candle crossed the Lower Band from below to aboveif(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 requestsMqlTradeResult mresult; // Will be used for results of trade requestsZeroMemory(mrequest);
ZeroMemory(mresult);
double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Ask pricedouble Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Bid priceif(!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 priceOrderSend(mrequest,mresult); // Send order
}
}
//+------------------------------------------------------------------+//| Open Short position |//+------------------------------------------------------------------+void ShortPositionOpen()
{
MqlTradeRequest mrequest; // Will be used for trade requestsMqlTradeResult mresult; // Will be used for results of trade requestsZeroMemory(mrequest);
ZeroMemory(mresult);
double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Ask pricedouble Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Bid priceif(!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 priceOrderSend(mrequest,mresult); // Send order
}
}
//+------------------------------------------------------------------+//| Close Long position |//+------------------------------------------------------------------+void LongPositionClose()
{
MqlTradeRequest mrequest; // Will be used for trade requestsMqlTradeResult mresult; // Will be used for results of trade requestsZeroMemory(mrequest);
ZeroMemory(mresult);
double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Ask pricedouble Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Bid priceif(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 priceOrderSend(mrequest,mresult); // Send order
}
}
//+------------------------------------------------------------------+//| Close Short position |//+------------------------------------------------------------------+void ShortPositionClose()
{
MqlTradeRequest mrequest; // Will be used for trade requestsMqlTradeResult mresult; // Will be used for results of trade requestsZeroMemory(mrequest);
ZeroMemory(mresult);
double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Ask pricedouble Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Bid priceif(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 priceOrderSend(mrequest,mresult); // Send order
}
}
//+------------------------------------------------------------------+
La función MathMax devuelve el valor máximo de dos valores.
La función MathMin devuelve el valor mínimo de dos valores.
Sí, tienes razón,
lo que quiero hacer es iBBUp-IBBLow/iBBMiddle,
entonces el nombre era ancho, los valores vuelven a ancho, si el valor aumenta ex: ancho>0 una compra abierta(upside break out), ancho<0 una venta abierta(down side breakout).
No sé el código exacto de cómo implementarlo.
estoy tratando de codificarlo con el método de la red nural.
Para iniciar sesión y usar el sitio web MQL5.com es necesario permitir el uso de Сookies.
Por favor, active este ajuste en su navegador, de lo contrario, no podrá iniciar sesión.
Ha iniciado sesión. La autenticación de dos factores se ha desactivado. Vuelva a configurarla y escanee un nuevo código QR, o continúe con la autenticación de dos factores desactivada.
Lo siento, algunos errores de ortografía,
quiero el ancho de la banda para esto necesito algún cálculo como
Ancho=(banda superior-banda inferior)/banda base
¿es posible hacer este cálculo dentro del ea?
¿como definir esto? cuando lo intento obtengo un error,
Width[]=(Banda superior[ ]-Banda inferior[ ])/Banda base[ ],
por favor, ayúdenos
Muestre el código real de lo que está tratando por favor.
Todavía estoy trabajando en ello, señor, cuando se reproducen a mi puesto, he publicado lo que estoy trabajando en él,
He intentado entender la documentación de las funciones matemáticas, pero no he podido encontrar la correcta, porque no sé cuál debo usar.
He estado probando uno por uno durante muchas horas, ¿puede mostrarme el método correcto?
He intentado entender los documentos de las funciones matemáticas, pero no he podido encontrar el método correcto porque no sé cuál debo usar.
He estado intentando uno por uno durante muchas horas, ¿puede mostrarme el método correcto?
Hola
Lafunción MathMax devuelve el valor máximo de dos valores.
La función MathMin devuelve el valor mínimo de dos valores.
Hola
La función MathMax devuelve el valor máximo de dos valores.
La función MathMin devuelve el valor mínimo de dos valores.
Hola
La función MathMax devuelve el valor máximo de dos valores.
La función MathMin devuelve el valor mínimo de dos valores.
Sí, tienes razón,
lo que quiero hacer es iBBUp-IBBLow/iBBMiddle,
entonces el nombre era ancho, los valores vuelven a ancho, si el valor aumenta ex: ancho>0 una compra abierta(upside break out), ancho<0 una venta abierta(down side breakout).
No sé el código exacto de cómo implementarlo.
estoy tratando de codificarlo con el método de la red nural.
como implementarlo por favor ayuda.
Sí, tienes razón,
lo que quiero hacer es iBBUp-IBBLow/iBBMiddle,
si el valor se incrementa, por ejemplo: width>0 un buy open(upside break out), width<0 un sell open(down side breakout).
No sé el código exacto de cómo implementarlo.
estoy tratando de codificarlo con el método de la red nural.
como implementarlo por favor ayuda.
Sí, tienes razón,
lo que quiero hacer es iBBUp-IBBLow/iBBMiddle,
si el valor se incrementa, por ejemplo: width>0 un buy open(upside break out), width<0 un sell open(down side breakout).
No sé el código exacto de cómo implementarlo.
estoy tratando de codificarlo con el método de la red nural.
como implementarlo por favor ayuda.