META TRADER 4 THREAD NOW ON KRESLIK.COM

Moderator: moderators

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11396
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Wed Dec 12, 2007 1:25 am

This one is usuable but still not quite finished.

Code: Select all


//+------------------------------------------------------------------+
//|                                            TRO_DYNAMICFIBSSR.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 DarkSeaGreen
#property indicator_color4 Khaki
#property indicator_color5 Gray
#property indicator_color6 Khaki
#property indicator_color7 DarkSeaGreen
//---- input parameters
extern bool      bDrawFibs = false;
extern int       iDecimals =4;
extern int       iPeriods=5;
extern double    iLevel1=0.24;
extern double    iLevel2=0.382;
extern double    iLevel3=0.5;
extern double    iLevel4=0.618;
extern double    iLevel5=0.76;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
//----- internal vars
double Dynamic_77       = 0;
double Dynamic_61       = 0;
double Dynamic_50       = 0;
double Dynamic_38       = 0;
double Dynamic_23       = 0;

double Dynamic_R          = 0;
double Dynamic_S        = 0;
double OldDynamic_R     = 0;
double OldDynamic_S       = 0;
double PrevDynamic_R    = 0;
double PrevDynamic_S    = 0;

/*
var xHH_CL   = 0 ;
var xCL_LL   = 0 ;
var xLgEntry = 0 ;
var xShEntry = 0
*/


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,161);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,161);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,161);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,161);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexEmptyValue(3,0.0);
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexArrow(4,161);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexEmptyValue(4,0.0);
   SetIndexStyle(5,DRAW_ARROW);
   SetIndexArrow(5,161);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexEmptyValue(5,0.0);
   SetIndexStyle(6,DRAW_ARROW);
   SetIndexArrow(6,161);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexEmptyValue(6,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
    if(counted_bars < 0)
        return(-1);
//----


for (int j =0;j<=300; j++){
 
      if(TimeDay(Time[j])!=TimeDay(Time[j+1])) {
     
     
         PrevDynamic_R =0;
         PrevDynamic_S =0;
   //     Dynamic_R = High[j+1];
   //     Dynamic_S = Low[j+1];
     
      }
     
      else {
     
           
            int xHH = ArrayMaximum(High,iPeriods, j );  // dynamic Resistance array index
            int xLL = ArrayMinimum(Low, iPeriods, j );  // dynamic Suport array index

            Dynamic_R = High[xHH];
            Dynamic_S = Low[xLL];
     
     
     
            if ( (PrevDynamic_R !=0) && (PrevDynamic_R > Dynamic_R) && (Dynamic_R != High[j]) ) Dynamic_R = PrevDynamic_R;
            if ( (PrevDynamic_S !=0) && (PrevDynamic_S < Dynamic_S) && (Dynamic_S != Low[j]) )  Dynamic_S = PrevDynamic_S;
     

      }
     
      double Range = Dynamic_R-Dynamic_S;
      Print ("Dynamic S ", Dynamic_S, " Dynamic R", Dynamic_R);
     
      int i,xM;
     for(i=j; i<=j*iPeriods+xHH; i++)
                        ExtMapBuffer1[i] = Dynamic_R;
     
      for(i=j; i<=j*iPeriods+xLL; i++)
                        ExtMapBuffer2[i] = Dynamic_S;
     
      if (bDrawFibs){                 
            if (xHH>xLL) xM = xLL;
            else xM = xHH;
       
            for (i=0; i<=xM; i++)
            {
               ExtMapBuffer3[j] = Dynamic_R - Range*iLevel1;
               ExtMapBuffer4[j] = Dynamic_R - Range*iLevel2;
               ExtMapBuffer5[j] = Dynamic_R - Range*iLevel3;
               ExtMapBuffer6[j] = Dynamic_R - Range*iLevel4;
               ExtMapBuffer7[j] = Dynamic_R - Range*iLevel5;
         
     
            }
       }     
     
   //  PrevDynamic_R = Dynamic_R;
  //   PrevDynamic_S = Dynamic_S;
}
   
//----
   return(0);
  }
//+------------------------------------------------------------------+


IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!

Please do NOT PM me with trading or coding questions, post them in a thread.

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
daniil
rank: 50+ posts
rank: 50+ posts
Posts: 61
Joined: Mon May 07, 2007 6:40 am
Reputation: 0
Gender: Male

Postby daniil » Fri Dec 14, 2007 2:20 am

the code became compact and easy. i begin to like MQL :)

Code: Select all

//+------------------------------------------------------------------+
//|                                            TRO_DYNAMICFIBSSR.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 DarkSeaGreen
#property indicator_color4 Khaki
#property indicator_color5 Gray
#property indicator_color6 Khaki
#property indicator_color7 DarkSeaGreen
//---- input parameters
extern bool      bDrawFibs = false;
extern bool      bCountAllBars = false;
extern int       iBarsToCount = 500;
extern int       iPeriods=5;
extern double    iLevel1=0.24;
extern double    iLevel2=0.382;
extern double    iLevel3=0.5;
extern double    iLevel4=0.618;
extern double    iLevel5=0.76;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
//----- internal vars

double Dynamic_R        = 0;
double Dynamic_S        = 0;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,161);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,161);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,161);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,161);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexEmptyValue(3,0.0);
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexArrow(4,161);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexEmptyValue(4,0.0);
   SetIndexStyle(5,DRAW_ARROW);
   SetIndexArrow(5,161);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexEmptyValue(5,0.0);
   SetIndexStyle(6,DRAW_ARROW);
   SetIndexArrow(6,161);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexEmptyValue(6,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit;
   int xHH,xLL,i,j;
   if(counted_bars < 0)
        return(-1);
//----
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   if (!bCountAllBars) limit = iBarsToCount;
   for (i=0;j<limit; i++){
           xHH = ArrayMaximum(High,iPeriods,i);  // dynamic Resistance array index
           xLL = ArrayMinimum(Low, iPeriods,i);  // dynamic Suport array index
           Dynamic_R = High[xHH];
           Dynamic_S = Low[xLL];
           for(j=i; j<=i*iPeriods+xHH; j++) ExtMapBuffer1[j] = Dynamic_R;
           for(j=i; j<=i*iPeriods+xLL; j++) ExtMapBuffer2[j] = Dynamic_S;
           if (bDrawFibs){
                  double Range = Dynamic_R - Dynamic_S;   
                  ExtMapBuffer3[i] = Dynamic_R - Range*iLevel1;
                  ExtMapBuffer4[i] = Dynamic_R - Range*iLevel2;
                  ExtMapBuffer5[i] = Dynamic_R - Range*iLevel3;
                  ExtMapBuffer6[i] = Dynamic_R - Range*iLevel4;
                  ExtMapBuffer7[i] = Dynamic_R - Range*iLevel5;
            }     
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

BP
rank: 50+ posts
rank: 50+ posts
Posts: 99
Joined: Tue Feb 06, 2007 12:58 pm
Reputation: 0
Location: Camp Hill, PA
Gender: Male

Postby BP » Fri Dec 14, 2007 11:30 am

Daniil,

Did you update the zip file? Can you post it if you have changed it? How is the new version running now?

Thanks for your efforts Daniil.

BP

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11396
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Fri Dec 14, 2007 6:02 pm

daniil

That's still not quite "right".

The dynamic support/resistance formula needs to be coded EXACTLY the way I did it in TradeStation and eSignal:


PrevDynamic_R = Dynamic_R ;
PrevDynamic_S = Dynamic_S ;

var xHH = highest( iPeriods , high() ) ; // dynamic Resistance
var xLL = lowest( iPeriods , low() ) ; // dynamic Suport

Dynamic_R = rnd(xHH, iDecimals); // dynamic Resistance
Dynamic_S = rnd(xLL, iDecimals); // dynamic Suport


if ( Dynamic_R != high(0) && Dynamic_R < PrevDynamic_R ) {
if ( PrevDynamic_R != 0 ) {
Dynamic_R = PrevDynamic_R;
}
}


if ( Dynamic_S != low(0) && Dynamic_S > PrevDynamic_S ) {
if ( PrevDynamic_S != 0 ) {
Dynamic_S = PrevDynamic_S;
}
}
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11396
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Sun Dec 16, 2007 7:42 pm

TRO_DYNAMICFIBSSRPx.mq4

Code: Select all


//+------------------------------------------------------------------+
//|                             TRO_DYNAMICFIBSSRPx.mq4            |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 Yellow
#property indicator_color3 Yellow
#property indicator_color4 Yellow
 

//---- input parameters
extern bool      bDrawFibs = true;
extern bool      bCountAllBars = false;
extern int       iBarsToCount = 500;
extern int       iPeriods=5;
extern double    iLevelP1=0.382;
extern double    iLevelP2=0.618;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];


//----- internal vars

double Dynamic_R        = 0;
double Dynamic_S        = 0;

double PrevDynamic_R    = 0;
double PrevDynamic_S    = 0;

double PrevDynamic_RP1    = 0;
double PrevDynamic_RP2    = 0;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,161);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,161);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,161);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,161);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexEmptyValue(3,0.0);

 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit;
   int xHH,xLL,i,j;
   if(counted_bars < 0)
        return(-1);
//----
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   if (!bCountAllBars) limit = iBarsToCount;
   for (i=0;j<limit; i++){
           PrevDynamic_R = Dynamic_R ;
           PrevDynamic_S = Dynamic_S ;
           xHH = ArrayMaximum(High,iPeriods,i);  // dynamic Resistance array index
           xLL = ArrayMinimum(Low, iPeriods,i);  // dynamic Suport array index
           Dynamic_R = High[xHH];
           Dynamic_S = Low[xLL];
           
         
           for(j=i; j<=i*iPeriods+xHH; j++) ExtMapBuffer1[j] = Dynamic_R;
           for(j=i; j<=i*iPeriods+xLL; j++) ExtMapBuffer2[j] = Dynamic_S;
           if (bDrawFibs){
 
                  double Range = Dynamic_R - Dynamic_S;   
                  ExtMapBuffer1[i] = Dynamic_R + (Range*iLevelP2) ;
                  ExtMapBuffer2[i] = Dynamic_R + (Range*iLevelP1) ;
                  ExtMapBuffer3[i] = Dynamic_S - (Range*iLevelP1) ;
                  ExtMapBuffer4[i] = Dynamic_S - (Range*iLevelP2) ;
            }     
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
daniil
rank: 50+ posts
rank: 50+ posts
Posts: 61
Joined: Mon May 07, 2007 6:40 am
Reputation: 0
Gender: Male

Postby daniil » Mon Dec 17, 2007 3:05 am

Avery! it seems you put PrevDynamic_S, PrevDynamic_R in the code but actually do not use them?? why?

How to use this indicator in proper way? is it for HOUR bars or it can be used for 5MIN?
BRGDS,Dan

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11396
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Mon Dec 17, 2007 4:32 am

It's a work in progress, daniil, so that's why they are not used.

I still need to get the DYNAMIC SR part to work just like TradeStation and eSignal... Would you see if you could do that, PLEASE!

How to use the SRP properly? The Yellow circles are price targets... gives you something to shoot for.
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
daniil
rank: 50+ posts
rank: 50+ posts
Posts: 61
Joined: Mon May 07, 2007 6:40 am
Reputation: 0
Gender: Male

Postby daniil » Mon Dec 17, 2007 4:52 am

Avery! Great problem for me because i have no TS, no ESignal, so i do not know how this SR indicator must behave.
If you'll be kind and explain what's wrong with this one, how it must behave - so i will do my best to code it.

BTW - "Yellow circles" - ??? must i add some "Yellow circles"?


BRGDS, Dan

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11396
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Mon Dec 17, 2007 6:23 am

Scroll back!!

I posted the Dynamic SR formula.

The yellow circles are the FIB PROJECTIONS.
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11396
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

MT4 MOTHERLODE

Postby TheRumpledOne » Wed Dec 19, 2007 8:29 pm

MT4 MOTHERLODE

A bunch of MT4 code that I found. I actually modified a few :)
Attachments
indicators.zip
(161.47 KiB) Downloaded 431 times
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “MetaTrader”