и вот здесь иммено я хочу чтобы НМА их открывал а EMA/WMA закрывал и так далее
в
от здесь НМА индикатор
https://www.mql5.com/ru/code/viewcode/27999/230520/super_trend_hull.mq5
вот здесь допустим мне нужны другие Параметры для void OPENORDER(string ord) из индикатора НМА для запуска нового ордера, например свеча закрылась пол линией НМА -> Сигнал Sell
И вот здесь яа немогу продвинутся
Много ошибок, не прочитать.
Много ошибок, не прочитать.
if (cprice > Up[i-1]) Direction[i] = 1; if (cprice < Dn[i-1]) Direction[i] = -1;
- www.mql5.com
Здравствуйте
Вот такая идея, ввести в этот ЕА ,
//+------------------------------------------------------------------+ //| EMA_WMA v2(barabashkakvn's edition).mq5 | //| Copyright © 2009, Vladimir Hlystov | //| cmillion@narod.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, Vladimir Hlystov" #property link "cmillion@narod.ru" #property version "2.000" #include <Trade\PositionInfo.mqh> #include <Trade\Trade.mqh> #include <Trade\SymbolInfo.mqh> #include <Trade\AccountInfo.mqh> CPositionInfo m_position; // trade position object CTrade m_trade; // trading object CSymbolInfo m_symbol; // symbol info object CAccountInfo m_account; // account info wrapper input int period_EMA = 28; // EMA: averaging period input int period_WMA = 8; // WMA: averaging period input ushort InpStopLoss = 50; // StopLoss input ushort InpTakeProfit = 50; // TakeProfit input ushort InpTrailingStop= 50; // Trailing Stop input ushort InpTrailingStep= 10; // Trailing Step input int risk = 10; // Risk double my_lot; ulong m_magic=72406264; // magic number //--- double my_SL,my_TP; datetime TimeBar; double ExtStopLoss=0.0; double ExtTakeProfit=0.0; double ExtTrailingStop=0.0; double ExtTrailingStep=0.0; int handle_iMA_EMA; // variable for storing the handle of the iMA indicator int handle_iMA_WMA; // variable for storing the handle of the iMA indicator //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { if(InpTrailingStop!=0 && InpTrailingStep==0) { Alert(__FUNCTION__," ERROR: Trailing is not possible: the parameter \"Trailing Step\" is zero!"); return(INIT_PARAMETERS_INCORRECT); } //--- m_symbol.Name(Symbol()); // sets symbol name //--- m_trade.SetExpertMagicNumber(m_magic); // sets magic number if(!RefreshRates()) { Print("Error RefreshRates. Bid=",DoubleToString(m_symbol.Bid(),Digits()), ", Ask=",DoubleToString(m_symbol.Ask(),Digits())); return(INIT_FAILED); } m_symbol.Refresh(); //--- tuning for 3 or 5 digits int digits_adjust=1; if(m_symbol.Digits()==3 || m_symbol.Digits()==5) digits_adjust=10; ExtStopLoss = InpStopLoss * digits_adjust; ExtTakeProfit = InpTakeProfit * digits_adjust; ExtTrailingStop= InpTrailingStop * digits_adjust; ExtTrailingStep= InpTrailingStep * digits_adjust; //--- create handle of the indicator iMA handle_iMA_EMA=iMA(Symbol(),Period(),period_EMA,0,MODE_EMA,PRICE_OPEN); //--- if the handle is not created if(handle_iMA_EMA==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- create handle of the indicator iMA handle_iMA_WMA=iMA(Symbol(),Period(),period_WMA,0,MODE_LWMA,PRICE_OPEN); //--- if the handle is not created if(handle_iMA_WMA==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { datetime time_0=iTime(0); if(TimeBar==time_0) return; if(TimeBar==0) { TimeBar=time_0; return; }//first program run double EMA0 = iMAGet(handle_iMA_EMA,0); double WMA0 = iMAGet(handle_iMA_WMA,0); double EMA1 = iMAGet(handle_iMA_EMA,1); double WMA1 = iMAGet(handle_iMA_WMA,1); if(EMA0<WMA0 && EMA1>WMA1) //Buy { if(!RefreshRates()) return; TimeBar=time_0; my_TP = m_symbol.Ask() + ExtTakeProfit*Point(); my_SL = m_symbol.Ask() - ExtStopLoss*Point(); my_lot = LOT(risk); CLOSEORDER("Sell"); OPENORDER("Buy"); } if(EMA0>WMA0 && EMA1<WMA1) //Sell { if(!RefreshRates()) return; TimeBar=time_0; my_TP=m_symbol.Bid()-ExtTakeProfit*Point(); my_SL = m_symbol.Bid() + ExtStopLoss*Point(); my_lot= LOT(risk); CLOSEORDER("Buy"); OPENORDER("Sell"); } //--- Trailing(); //--- return; } //-------------------------------------------------------------------- void CLOSEORDER(string ord) { for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions if(m_position.SelectByIndex(i)) if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic) { if(m_position.PositionType()==POSITION_TYPE_BUY && ord=="Buy") m_trade.PositionClose(m_position.Ticket()); // Close Buy if(m_position.PositionType()==POSITION_TYPE_SELL && ord=="Sell") m_trade.PositionClose(m_position.Ticket()); // Close Sell } } //-------------------------------------------------------------------- void OPENORDER(string ord) { if(ord=="Buy") if(!m_trade.Buy(my_lot,Symbol(),m_symbol.Ask(),my_SL,my_TP,"")) Print("Buy -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of result: ",m_trade.ResultRetcodeDescription(), ", ticket of deal: ",m_trade.ResultDeal()); if(ord=="Sell") if(!m_trade.Sell(my_lot,Symbol(),m_symbol.Bid(),my_SL,my_TP,"")) Print("BUY_STOP -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of Retcode: ",m_trade.ResultRetcodeDescription(), ", ticket of order: ",m_trade.ResultOrder()); return; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double LOT(int input_risk) { if(!RefreshRates()) return(m_symbol.LotsMin()); double MINLOT=m_symbol.LotsMin(); double margin_required=0.0; if(!OrderCalcMargin(ORDER_TYPE_BUY,Symbol(),1.0,m_symbol.Ask(),margin_required)) return(m_symbol.LotsMin()); my_lot=m_account.FreeMargin()*input_risk/100.0/margin_required; if(my_lot>m_symbol.LotsMax()) my_lot=m_symbol.LotsMax(); if(my_lot<MINLOT) my_lot=MINLOT; if(MINLOT<0.1) my_lot=NormalizeDouble(my_lot,2); else my_lot=NormalizeDouble(my_lot,1); return(my_lot); } //+------------------------------------------------------------------+ //| Refreshes the symbol quotes data | //+------------------------------------------------------------------+ bool RefreshRates() { //--- refresh rates if(!m_symbol.RefreshRates()) return(false); //--- protection against the return value of "zero" if(m_symbol.Ask()==0 || m_symbol.Bid()==0) return(false); //--- return(true); } //+------------------------------------------------------------------+ //| Get Time for specified bar index | //+------------------------------------------------------------------+ datetime iTime(const int index,string symbol=NULL,ENUM_TIMEFRAMES timeframe=PERIOD_CURRENT) { if(symbol==NULL) symbol=Symbol(); if(timeframe==0) timeframe=Period(); datetime Time[]; datetime time=0; ArraySetAsSeries(Time,true); int copied=CopyTime(symbol,timeframe,index,1,Time); if(copied>0) time=Time[0]; return(time); } //+------------------------------------------------------------------+ //| Get value of buffers for the iMA | //+------------------------------------------------------------------+ double iMAGet(int handle_iMA,const int index) { double MA[]; ArraySetAsSeries(MA,true); //--- reset error code ResetLastError(); //--- fill a part of the iMABuffer array with values from the indicator buffer that has 0 index if(CopyBuffer(handle_iMA,0,0,index+1,MA)<0) { //--- if the copying fails, tell the error code PrintFormat("Failed to copy data from the iMA indicator, error code %d",GetLastError()); //--- quit with zero result - it means that the indicator is considered as not calculated return(0.0); } return(MA[index]); } //+------------------------------------------------------------------+ //| Trailing | //+------------------------------------------------------------------+ void Trailing() { if(InpTrailingStop==0) return; for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions if(m_position.SelectByIndex(i)) if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic) { if(m_position.PositionType()==POSITION_TYPE_BUY) { if(m_position.PriceCurrent()-m_position.PriceOpen()>ExtTrailingStop+ExtTrailingStep) if(m_position.StopLoss()<m_position.PriceCurrent()-(ExtTrailingStop+ExtTrailingStep)) { if(!m_trade.PositionModify(m_position.Ticket(), m_symbol.NormalizePrice(m_position.PriceCurrent()-ExtTrailingStop), m_position.TakeProfit())) Print("Modify ",m_position.Ticket(), " Position -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of result: ",m_trade.ResultRetcodeDescription()); } } else { if(m_position.PriceOpen()-m_position.PriceCurrent()>ExtTrailingStop+ExtTrailingStep) if((m_position.StopLoss()>(m_position.PriceCurrent()+(ExtTrailingStop+ExtTrailingStep))) || (m_position.StopLoss()==0)) { if(!m_trade.PositionModify(m_position.Ticket(), m_symbol.NormalizePrice(m_position.PriceCurrent()+ExtTrailingStop), m_position.TakeProfit())) Print("Modify ",m_position.Ticket(), " Position -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of result: ",m_trade.ResultRetcodeDescription()); } } } } //+------------------------------------------------------------------+
следующий HMA индикатор, для исполнения только Buy и Sell
//------------------------------------------------------------------ #property copyright "www.forex-tsd.com" #property link "www.forex-tsd.com" //------------------------------------------------------------------ #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 1 #property indicator_label1 "Super trend hull" #property indicator_type1 DRAW_COLOR_LINE #property indicator_color1 clrLimeGreen,clrPaleVioletRed #property indicator_style1 STYLE_SOLID #property indicator_width1 2 // // // // // enum enPrices { pr_close, // Close pr_open, // Open pr_high, // High pr_low, // Low pr_median, // Median pr_typical, // Typical pr_weighted, // Weighted pr_average // Average (high+low+oprn+close)/4 }; input int hullPeriod = 12; // Hull period input enPrices Price = pr_median; // Price input int atrPeriod = 12; // ATR period input double atrMultiplier = 0.66; // ATR multiplier double st[]; double colorBuffer[]; //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int OnInit() { SetIndexBuffer(0,st,INDICATOR_DATA); SetIndexBuffer(1,colorBuffer,INDICATOR_COLOR_INDEX); return(0); } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // double Up[]; double Dn[]; double Direction[]; int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[]) { if (ArraySize(Direction)!=rates_total) { ArrayResize(Up,rates_total); ArrayResize(Dn,rates_total); ArrayResize(Direction,rates_total); } // // // // // for (int i=(int)MathMax(prev_calculated-1,1); i<rates_total; i++) { double atr = 0; for (int k=0;k<atrPeriod && (i-k-1)>=0; k++) atr += MathMax(high[i-k],close[i-k-1])-MathMin(low[i-k],close[i-k-1]); atr /= atrPeriod; // // // // // double cprice = close[i]; double mprice = iHull(getPrice(Price,open,close,high,low,i,rates_total),hullPeriod,i,rates_total); Up[i] = mprice+atrMultiplier*atr; Dn[i] = mprice-atrMultiplier*atr; // // // // // colorBuffer[i] = colorBuffer[i-1]; Direction[i] = Direction[i-1]; if (cprice > Up[i-1]) Direction[i] = 1; if (cprice < Dn[i-1]) Direction[i] = -1; if (Direction[i] > 0) { Dn[i] = MathMax(Dn[i],Dn[i-1]); st[i] = Dn[i]; } else { Up[i] = MathMin(Up[i],Up[i-1]); st[i] = Up[i]; } if (Direction[i]== 1) colorBuffer[i] = 0; if (Direction[i]==-1) colorBuffer[i] = 1; } return(rates_total); } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // double workHull[][2]; double iHull(double price, double period, int r, int bars, int instanceNo=0) { if (ArrayRange(workHull,0)!= bars) ArrayResize(workHull,bars); // // // // // int HmaPeriod = (int)MathMax(period,2); int HalfPeriod = (int)MathFloor(HmaPeriod/2); int HullPeriod = (int)MathFloor(MathSqrt(HmaPeriod)); double hma,hmw,weight; instanceNo *= 2; workHull[r][instanceNo] = price; // // // // // hmw = HalfPeriod; hma = hmw*price; for(int k=1; k<HalfPeriod && (r-k)>=0; k++) { weight = HalfPeriod-k; hmw += weight; hma += weight*workHull[r-k][instanceNo]; } workHull[r][instanceNo+1] = 2.0*hma/hmw; hmw = HmaPeriod; hma = hmw*price; for(int k=1; k<period && (r-k)>=0; k++) { weight = HmaPeriod-k; hmw += weight; hma += weight*workHull[r-k][instanceNo]; } workHull[r][instanceNo+1] -= hma/hmw; // // // // // hmw = HullPeriod; hma = hmw*workHull[r][instanceNo+1]; for(int k=1; k<HullPeriod && (r-k)>=0; k++) { weight = HullPeriod-k; hmw += weight; hma += weight*workHull[r-k][1+instanceNo]; } return(hma/hmw); } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // double getPrice(enPrices price, const double& open[], const double& close[], const double& high[], const double& low[], int i, int bars) { switch (price) { case pr_close: return(close[i]); case pr_open: return(open[i]); case pr_high: return(high[i]); case pr_low: return(low[i]); case pr_median: return((high[i]+low[i])/2.0); case pr_typical: return((high[i]+low[i]+close[i])/3.0); case pr_weighted: return((high[i]+low[i]+close[i]+close[i])/4.0); case pr_average: return((high[i]+low[i]+close[i]+open[i])/4.0); } return(0); }
Я так понял что
if (cprice > Up[i-1]) Direction[i] = 1;
Отвечает за сигнал пересикания линии?!
Я так понял что
Отвечает за сигнал пересикания пересечение) линии?!
Нет, изменение цвета индикатора
Блин так было на tradingview, тут уж совсем се по-другому
Ну это же сигнал на изменения, я имею в виду или линия перешла на красный цвет, то можно же зделать под этот сигнал Sell, или я ошибаюсь?
Ну а сам индикатор можно же как-то добавлять с помощью iCustom
вот вроде работает
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
имя индикатора правильно впишите свой
handle_iCustom=iCustom(m_symbol.Name(),Period(),"super_trend_hull",Inp_hullPeriod,Inp_Price,Inp_atrPeriod,Inp_atrMultiplier);
//+------------------------------------------------------------------+ //| EMA_WMA v2(barabashkakvn's edition).mq5 | //| Copyright © 2009, Vladimir Hlystov | //| cmillion@narod.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, Vladimir Hlystov" #property link "cmillion@narod.ru" #property version "2.000" #include <Trade\PositionInfo.mqh> #include <Trade\Trade.mqh> #include <Trade\SymbolInfo.mqh> #include <Trade\AccountInfo.mqh> CPositionInfo m_position; // trade position object CTrade m_trade; // trading object CSymbolInfo m_symbol; // symbol info object CAccountInfo m_account; // account info wrapper //+------------------------------------------------------------------+ //| Enum Prices | //+------------------------------------------------------------------+ enum enPrices { pr_close, // Close pr_open, // Open pr_high, // High pr_low, // Low pr_median, // Median pr_typical, // Typical pr_weighted, // Weighted pr_average // Average (high+low+oprn+close)/4 }; //+------------------------------------------------------------------+ //--- Super Trend Hull Indicator input int Inp_hullPeriod = 12; // Hull period input enPrices Inp_Price = pr_median; // Price input int Inp_atrPeriod = 12; // ATR period input double Inp_atrMultiplier = 0.66; // ATR multiplier //--- input ushort InpStopLoss = 50; // StopLoss input ushort InpTakeProfit = 50; // TakeProfit input ushort InpTrailingStop= 50; // Trailing Stop input ushort InpTrailingStep= 10; // Trailing Step input int risk = 10; // Risk double my_lot; ulong m_magic=72406264; // magic number //--- double my_SL,my_TP; datetime TimeBar; double ExtStopLoss=0.0; double ExtTakeProfit=0.0; double ExtTrailingStop=0.0; double ExtTrailingStep=0.0; int m_bar_current=0; int handle_iCustom; // variable for storing the handle of the iCustom indicator //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { if(InpTrailingStop!=0 && InpTrailingStep==0) { Alert(__FUNCTION__," ERROR: Trailing is not possible: the parameter \"Trailing Step\" is zero!"); return(INIT_PARAMETERS_INCORRECT); } //--- m_symbol.Name(Symbol()); // sets symbol name //--- m_trade.SetExpertMagicNumber(m_magic); // sets magic number if(!RefreshRates()) { Print("Error RefreshRates. Bid=",DoubleToString(m_symbol.Bid(),Digits()), ", Ask=",DoubleToString(m_symbol.Ask(),Digits())); return(INIT_FAILED); } m_symbol.Refresh(); //--- tuning for 3 or 5 digits int digits_adjust=1; if(m_symbol.Digits()==3 || m_symbol.Digits()==5) digits_adjust=10; ExtStopLoss = InpStopLoss * digits_adjust; ExtTakeProfit = InpTakeProfit * digits_adjust; ExtTrailingStop= InpTrailingStop * digits_adjust; ExtTrailingStep= InpTrailingStep * digits_adjust; //--- create handle of the indicator iCustom handle_iCustom=iCustom(m_symbol.Name(),Period(),"super_trend_hull",Inp_hullPeriod,Inp_Price,Inp_atrPeriod,Inp_atrMultiplier); //--- if the handle is not created if(handle_iCustom==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d", m_symbol.Name(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { datetime time_0=iTime(0); if(TimeBar==time_0) return; if(TimeBar==0) { TimeBar=time_0; return; }//first program run double color_buffer[]; ArraySetAsSeries(color_buffer,true); int start_pos=1,count=3; if(!iGetArray(handle_iCustom,1,start_pos,count,color_buffer)) return; if(color_buffer[m_bar_current+1]>color_buffer[m_bar_current]) { if(!RefreshRates()) return; TimeBar=time_0; my_TP = m_symbol.Ask() + ExtTakeProfit*Point(); my_SL = m_symbol.Ask() - ExtStopLoss*Point(); my_lot = LOT(risk); CLOSEORDER("Sell"); OPENORDER("Buy"); } if(color_buffer[m_bar_current+1]<color_buffer[m_bar_current]) { if(!RefreshRates()) return; TimeBar=time_0; my_TP=m_symbol.Bid()-ExtTakeProfit*Point(); my_SL = m_symbol.Bid() + ExtStopLoss*Point(); my_lot= LOT(risk); CLOSEORDER("Buy"); OPENORDER("Sell"); } //--- Trailing(); //--- return; } //-------------------------------------------------------------------- void CLOSEORDER(string ord) { for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of open positions if(m_position.SelectByIndex(i)) if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic) { if(m_position.PositionType()==POSITION_TYPE_BUY && ord=="Buy") m_trade.PositionClose(m_position.Ticket()); // Close Buy if(m_position.PositionType()==POSITION_TYPE_SELL && ord=="Sell") m_trade.PositionClose(m_position.Ticket()); // Close Sell } } //-------------------------------------------------------------------- void OPENORDER(string ord) { if(ord=="Buy") if(!m_trade.Buy(my_lot,Symbol(),m_symbol.Ask(),my_SL,my_TP,"")) Print("Buy -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of result: ",m_trade.ResultRetcodeDescription(), ", ticket of deal: ",m_trade.ResultDeal()); if(ord=="Sell") if(!m_trade.Sell(my_lot,Symbol(),m_symbol.Bid(),my_SL,my_TP,"")) Print("BUY_STOP -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of Retcode: ",m_trade.ResultRetcodeDescription(), ", ticket of order: ",m_trade.ResultOrder()); return; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double LOT(int input_risk) { if(!RefreshRates()) return(m_symbol.LotsMin()); double MINLOT=m_symbol.LotsMin(); double margin_required=0.0; if(!OrderCalcMargin(ORDER_TYPE_BUY,Symbol(),1.0,m_symbol.Ask(),margin_required)) return(m_symbol.LotsMin()); my_lot=m_account.FreeMargin()*input_risk/100.0/margin_required; if(my_lot>m_symbol.LotsMax()) my_lot=m_symbol.LotsMax(); if(my_lot<MINLOT) my_lot=MINLOT; if(MINLOT<0.1) my_lot=NormalizeDouble(my_lot,2); else my_lot=NormalizeDouble(my_lot,1); return(my_lot); } //+------------------------------------------------------------------+ //| Refreshes the symbol quotes data | //+------------------------------------------------------------------+ bool RefreshRates() { //--- refresh rates if(!m_symbol.RefreshRates()) return(false); //--- protection against the return value of "zero" if(m_symbol.Ask()==0 || m_symbol.Bid()==0) return(false); //--- return(true); } //+------------------------------------------------------------------+ //| Get Time for specified bar index | //+------------------------------------------------------------------+ datetime iTime(const int index,string symbol=NULL,ENUM_TIMEFRAMES timeframe=PERIOD_CURRENT) { if(symbol==NULL) symbol=Symbol(); if(timeframe==0) timeframe=Period(); datetime Time[]; datetime time=0; ArraySetAsSeries(Time,true); int copied=CopyTime(symbol,timeframe,index,1,Time); if(copied>0) time=Time[0]; return(time); } //+------------------------------------------------------------------+ //| Get value of buffers | //+------------------------------------------------------------------+ bool iGetArray(const int handle,const int buffer,const int start_pos, const int count,double &arr_buffer[]) { bool result=true; if(!ArrayIsDynamic(arr_buffer)) { PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__); return(false); } ArrayFree(arr_buffer); //--- reset error code ResetLastError(); //--- fill a part of the iBands array with values from the indicator buffer int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer); if(copied!=count) { //--- if the copying fails, tell the error code PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d", __FILE__,__FUNCTION__,count,copied,GetLastError()); //--- quit with zero result - it means that the indicator is considered as not calculated return(false); } return(result); } //+------------------------------------------------------------------+ //| Trailing | //+------------------------------------------------------------------+ void Trailing() { if(InpTrailingStop==0) return; for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of open positions if(m_position.SelectByIndex(i)) if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic) { if(m_position.PositionType()==POSITION_TYPE_BUY) { if(m_position.PriceCurrent()-m_position.PriceOpen()>ExtTrailingStop+ExtTrailingStep) if(m_position.StopLoss()<m_position.PriceCurrent()-(ExtTrailingStop+ExtTrailingStep)) { if(!m_trade.PositionModify(m_position.Ticket(), m_symbol.NormalizePrice(m_position.PriceCurrent()-ExtTrailingStop), m_position.TakeProfit())) Print("Modify ",m_position.Ticket(), " Position -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of result: ",m_trade.ResultRetcodeDescription()); } } else { if(m_position.PriceOpen()-m_position.PriceCurrent()>ExtTrailingStop+ExtTrailingStep) if((m_position.StopLoss()>(m_position.PriceCurrent()+(ExtTrailingStop+ExtTrailingStep))) || (m_position.StopLoss()==0)) { if(!m_trade.PositionModify(m_position.Ticket(), m_symbol.NormalizePrice(m_position.PriceCurrent()+ExtTrailingStop), m_position.TakeProfit())) Print("Modify ",m_position.Ticket(), " Position -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of result: ",m_trade.ResultRetcodeDescription()); } } } } //+------------------------------------------------------------------+
у меня пару вопросов, я не вижу Хендлов от ЕМА и WMA для закрытия позиций, иммено для этого я беру ЕМА 9 а для WMA эту формулу
lengthx = input(17) src2a = input(close) CL(src2a, lengthx)=> p = length/2 wma(wma(close,p/3)*3 - wma(close,p/2) - wma(close,p),p)
если вам это о чем то говорит, хотя я думаю можно просто сделать WMA тоже 9
так же была такая идея пускать этот ехперт тоько в определенное время, я уже кое что на эту тему нашел, попробую с перво сделать сам
но вы так же межете мне подсказать;)
у меня пару вопросов, я не вижу Хендлов от ЕМА и WMA для закрытия позиций, иммено для этого я беру ЕМА 9 а для WMA эту формулу
если вам это о чем то говорит, хотя я думаю можно просто сделать WMA тоже 9
так же была такая идея пускать этот ехперт толко в определенное время, я уже кое что на эту тему нашел, попробую с перво цделать сам
но вы так же межете мне подсказать;)
сейчас переделываю - я не прочёл что именно Вы хотели . сейчас сделаю как в первом вашем посту написано
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Вы принимаете политику сайта и условия использования
и вот здесь иммено я хочу сделать, чтобы НМА их открывал а EMA/WMA их закрывал и так далее
вот этот НМА индикатор
https://www.mql5.com/ru/code/viewcode/27999/230520/super_trend_hull.mq5
в этом коде допустим мне нужны другие Параметры для void OPENORDER(string ord) из индикатора НМА для запуска нового ордера, например свеча закрылась пол линией НМА -> Сигнал Sell
И вот здесь я немогу продвинутся