Coding help - page 777

 
Algo_W:

I am not sure how to implement IMaOnArray for this. I think that is the solution? Can anyone help me get the moving average of the ADX for the histogram?

Thank you

#property indicator_type1 DRAW_LINE

#property indicator_type1 DRAW_LINE
for(int i = limit-1; i >= 0; i--)
   Buffer1[i] = iADX(NULL, PERIOD_CURRENT, 14, PRICE_CLOSE, MODE_MAIN, i);
   
for(i = limit-1; i >= 0; i--)   
   Buffer2[i] = iMAOnArray(Buffer1, 0, 5, 0, MODE_SMA, i);
 
Naguisa Unada:

Hi Naguisa!

I trust your well?

I want to appreciate and say thank you for tweaking the mtf BB indcator. i can tell you its working like a charm.


Naguisa! Just to inquire further if i may , can this indicator be tweekable so that one may see different custom time-fames say like Fibonacci numbers or any odd and even time-frames and not necessarily the ones for MT4 only. is that possible, kindly?

 

coding help please.

how can ı code

ad right ray to a ma end point.?

 
guner:

coding help please.

how can ı code

ad right ray to a ma end point.?

Draw trend object with PRICE1 and PRICE2 values equal to value of your chosen MA on bar 0 and TIME1 equal to time of bar 0 while TIME2 is somwhere in the future. On every tick recalculate MA and set PRICE1 & PRICE2 accordingly and on every new bar set new TIME1.

 

Hi all,


I'm studying Mark Whistler's "Volatility illuminated" book and I'm interested to dig deeper in the indicators he built, especially the WAVE-PM
Whistler published the mq4 code on the book and there is a copy also here http://fxcodebase.com/code/viewtopic.php?f=38&t=64011 

However my intention is to port the indicator to tradingview since is my main charting platform, I know some pinescript basic but I find really hard to read into the C like code of the original script
Can someone give a look to the code and tell me roughly just the logic of what it does?

On the book Whistler don't say much about the indicator, just that " is visually identifying the 'compression' of the short-term distribution within the larger distribution. "



For what I've understood the oscillator represent the difference between upper and lower bands of a bollinger band, then the value is normalized in a range of 0-1 and plotted along the time

In the code I see that two oscillators are created (ShortBandsPeriod and LongBandsPeriod) but then I loosing myself into the for cycles...I can only see that there are some math calculations (a square, a exponent power, and a tangent?) but unfotunately can't grasp why and how are made

.
.
.
for (i=limit; i>=0; i--){
   
             
                avg= iMA(NULL,0,ShortBandsPeriod,0,MODE_SMA,PRICE_CLOSE,i+ShortBandsShift);
                
                sum=0;
                
                for (j=ShortBandsPeriod-1; j>=0; j--){
                 temp = Close[i+j] - avg;
                 sum = sum + temp * temp;
                }
         
                ShortDev[i]= ShortBandsDeviations * MathSqrt(sum / ShortBandsPeriod);
        ShortDev1[i] = MathPow((ShortDev[i] / Point), 2);
                
                
                    //if  ( i < limit - Chars)
                        //{
         
                        
                          temp=0;
                                for (j=Chars-1; j>=0; j--){                             
                                 temp = temp + ShortDev1[i+j];
                                }
                        
            temp = MathSqrt(temp / Chars) * Point;
            if (temp != 0)
                        {
                temp = ShortDev[i] / temp;
            }

                                
         
                        ShortOscillator[i] = MathTanh(temp);
                                
                   //}
   }
.
.
.


    So any help, suggestion or hint is appreciated, thanks!

Files:
WAVE-PM.mq4  5 kb
 

Hi,guys,could some coders help modify this fisher indicator.

yes ,its a very old indicator and repaint,however it has some valuable information. i want to analysis the state of the indicator when every candle closed.i‘ll be appreciated.

We don't change the repaint function,just add auto-refresh.Make the indicator refresh and record the state when every candle closed,but don't refresh itself during the next candle is starting.

sorry for my bad English.thanks in advance.

Files:
fisher1.mq4  3 kb
 

Hi Guys!

I trust your all well?

I found this indicators in the dynamic zone forum but there not working as such and if any generous coder may fix them, i would highly appreciate them.

Am attaching them in here,

My sincere appreciation in advance.

 
Mkurugenzi:

Hi Guys!

I trust your all well?

I found this indicators in the dynamic zone forum but there not working as such and if any generous coder may fix them, i would highly appreciate them.

Am attaching them in here,

My sincere appreciation in advance.

@Naguisa Unada


I trust your well?


Kindly, are you in a position to view my last post above and see if you are in a position to at-least retouch some if not all of the indicators to work?


your effort and time and resource is appreciated in advance. 

 

Hey coders! Can someone help me to modify this EA? 

This is a simple buy low sell high EA throwing out Limit orders ever x minutes that last x minutes/hours. 


What I think would improve it is to add a filter to it. Lets say stochastics or RSI..

So when stochastic is lower than 40 = launch the buy limits

And when stochastic is higher than 60 = launch the sell limits

And in between it doesnt launch anything



Is this possible? Thanks in advance.

I attach the EA 


I have used the EA "manually" by deciding running it longside or shortside with good results. 

Files:
WIDE_HARD.mq4  8 kb
EA-FXblue.png  68 kb
 
Hello. Immediately apologize for my bad english. If it's not difficult, please help with the advisor code. Namely, to correct the conditions of opening and closing positions. A little about the robot, the robot opens and closes positions at the turn of the zig zag indicator.
This system is supposed to work regardless of whether or not there is a zig zag indicator in MT4.
//+------------------------------------------------------------------+
//|                                       Test advisor on ZigZag.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                         https:/goga342@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright c 2010, MQL для тебя."
#property link "http://mql4you.ru"
#property strict
extern double lots = 0.01; //
extern int  TakeProfit=60; //
extern int  StopLoss=100; //
extern int Magic=111111111;
extern int Slippage=3;
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;

datetime Today=0;
double SL,TP;
int ticket;
//±-----------------------------------------------------------------+
int OnInit()
  {
   if(Digits==3 || Digits==5)
     {
      TakeProfit *=10;
      StopLoss   *=10;
      Slippage   *=10;
     }
   return(INIT_SUCCEEDED);
  }
//±-----------------------------------------------------------------+
int deinit() {return(0);}
//±-----------------------------------------------------------------+
int start()
  {

   if(DayOfWeek()==0 || DayOfWeek()==6) return(0); // в выходные не работаем
   if(!IsTradeAllowed()) return(0); // пропустим тик если терминал занят
                                    //:проверим открытие новой свечи
   if(Time[0]==Today) return(0);
   Today=Time[0];
//:получим значение ZigZag на предыдущей свече
   double lZZ=iCustom(NULL,0,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,1);
   double lZZ_=iCustom(NULL,0,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,0);
// открытие продаж

   if(CountSell()==0 && lZZ==Low[0] && lZZ_==Low[0])
     {
      SL = NormalizeDouble(Bid+StopLoss*Point, Digits);
      TP = NormalizeDouble(Bid-TakeProfit*Point, Digits);
        {

         ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,Slippage,SL,TP,"macd sample",Magic,0,Red);
         if(ticket>0)
           {
            // закрытие продаж
    //        if(CountSell()>0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,0,1)==High[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,0,1)==High[0])
              {
               for(int i=OrdersTotal()-1; i>=0; i--)
                 {
                  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
                    {
                     if(OrderMagicNumber()==Magic && OrderType()==OP_SELL)
                        if(OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,clrNONE))
                           Print("Ошибка открытия ордера на покупку !");
                    }
                 }
              }
           }
        }
     }
// открытие покупок

 //  if(CountBuy()==0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,0,1)==High[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,0,1)==High[0])
     {
      TP = NormalizeDouble(Ask+TakeProfit*Point, Digits);
      SL = NormalizeDouble(Ask-StopLoss*Point, Digits);
        {
         ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,SL,TP,"macd sample",Magic,0,Green);
         if(ticket>0)
           {
            // закрытие покупок    
       //     if(CountBuy()>0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,1,0)==Low[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,1,0)==Low[0])
              {
               for(int i=OrdersTotal()-1; i>=0; i--)
                 {
                  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
                    {
                     if(OrderMagicNumber()==Magic && OrderType()==OP_BUY)
                        if(!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,clrNONE))
                           Print("Ошибка открытия ордера на продажу!");
                    }
                 }
              }
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
int CountSell()//проверкна открытие ордеров на продажу
  {
   int count=0;

   for(int trade=OrdersTotal()-1; trade>=0; trade--)
     {
      if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_SELL)
           {
            if(OrderType()==OP_SELL)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
int CountBuy()// проверкна открытие ордеров на покупку
  {
   int count=0;

   for(int trade=OrdersTotal()-1; trade>=0; trade--)
     {
      if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_BUY)
           {
            if(OrderType()==OP_BUY)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+

opening sales

if(CountSell()==0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,1,0)==Low[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,1,0)==Low[0])

closing sales

      if(CountSell()>0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,0,1)==High[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,0,1)==High[0])
              

opening buy

if(CountBuy()==0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,0,1)==High[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,0,1)==High[0])
     

closing buy

 if(CountBuy()>0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,1,0)==Low[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,1,0)==Low[0])
              
Reason: