META TRADER 4 THREAD NOW ON KRESLIK.COM

Moderator: moderators

fibcat
rank: <50 posts
rank: <50 posts
Posts: 17
Joined: Fri Sep 08, 2006 2:15 pm
Reputation: 0
Gender: Male

Postby fibcat » Tue Dec 04, 2007 2:31 pm

Here are two TRO-like indicators I found somewhere in the net.
Not precisely as TRO's originals for tradestation or eSignal: TRO, what about starting some programming for MT4. Can you improve this two indicators?

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

fibcat
rank: <50 posts
rank: <50 posts
Posts: 17
Joined: Fri Sep 08, 2006 2:15 pm
Reputation: 0
Gender: Male

Postby fibcat » Tue Dec 04, 2007 2:35 pm

Sorry I don't see attachments: Must I treat them with ZIP or RAR or I can send them plain as tey are?

fibcat
rank: <50 posts
rank: <50 posts
Posts: 17
Joined: Fri Sep 08, 2006 2:15 pm
Reputation: 0
Gender: Male

Postby fibcat » Tue Dec 04, 2007 3:09 pm

fibcat wrote:Sorry I don't see attachments: Must I treat them with ZIP or RAR or I can send them plain as tey are?


I'trying again with zipped indicators:
Attachments
TrillSessions.zip
(2.19 KiB) Downloaded 126 times
TrillBox.zip
(1.39 KiB) Downloaded 152 times

deeforex
rank: 50+ posts
rank: 50+ posts
Posts: 99
Joined: Tue Oct 31, 2006 5:46 pm
Reputation: 0
Gender: None specified

Re: META TRADER 4 THREAD NOW ON KRESLIK.COM

Postby deeforex » Wed Dec 05, 2007 5:58 pm

TheRumpledOne wrote:Now there's a place to put all the TRO Indicators for MT4.


Does this mean someone is converting them to mq4? That would be great if someone could!

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

TRO_DYNAMICFIBSSR for MT4

Postby daniil » Tue Dec 11, 2007 6:47 am

Does this one do the right things?
Sorry the code is very rough....
Attachments
TRO_DYNAMICFIBSSR.ZIP
(1.28 KiB) Downloaded 134 times

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

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 » Tue Dec 11, 2007 1:18 pm

Thanks Daniil...

I will try it out on my platform. I appreciate your effort.

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 » Tue Dec 11, 2007 1:31 pm

daniil:

Hard to tell when you don't have what instrument is being traded, date, time and interval on the chart... I can't compare it to TradeStation or eSignal...LOL!!
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.

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

Here is a sample TRO

Postby BP » Tue Dec 11, 2007 1:38 pm

TRO,

I put it into my charts. Here it is. This is USDJPY at around 830 EST on 12/11/07, with an hourly chart. 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 » Wed Dec 12, 2007 12:29 am

This is close but these 2 lines need to refer to the CURRENT HIGH and CURRENT LOW! I don't know if High[j] and Low[j] do that.


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;



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 {
     
            PrevDynamic_R = Dynamic_R ;
            PrevDynamic_S = Dynamic_S ;

            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);
  }
//+------------------------------------------------------------------+




Getting closer but the Dynamic Support circles are missing for the last 4 candles!??!?!

It almost looks like MT4 is processing the data backwards.
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 » Wed Dec 12, 2007 12:59 am

Here is the esignal code:

Code: Select all

/****


TRO_DYNAMIC_FibsSR2 9:26 PM 4/3/2007 PLOT DYNAMIC SUPPORT/RESISTANCE with fibs
 
Programmer:  Avery T. Horton, Jr.  aka TheRumpledOne, 

DONATIONS AND GIFTS ACCEPTED

P O BOX 43575, TUCSON, AZ 85733

please include this and/or any other comment blocks and a
description of any changes you make.


ATTN ESIGNAL: I DID NOT POST THIS CODE ON YOUR FORUM
              I AM NOT RESPONSIBLE FOR ANY ESIGNAL FORUM RULE VIOLATIONS.

****/

//debugClear();

function preMain() {

    setPriceStudy(true);
    setStudyTitle("TRO_DYNAMIC_FibsSR2");
    setShowTitleParameters( false );

    setCursorLabelName("Dyn_R", 0);
    setCursorLabelName("Dyn_S", 1);
    setCursorLabelName("Dyn_77", 2);
    setCursorLabelName("Dyn_61", 3);
    setCursorLabelName("Dyn_50", 4);
    setCursorLabelName("Dyn_38", 5);
    setCursorLabelName("Dyn_23", 6);

    setDefaultBarFgColor(Color.red,0);
    setDefaultBarFgColor(Color.blue,1);   
    setDefaultBarFgColor(Color.teal,2);
    setDefaultBarFgColor(Color.khaki,3);
    setDefaultBarFgColor(Color.grey,4);
    setDefaultBarFgColor(Color.khaki,5);
    setDefaultBarFgColor(Color.teal,6);

    setDefaultBarThickness(2,0);
    setDefaultBarThickness(2,1);
    setDefaultBarThickness(2,2);
    setDefaultBarThickness(2,3);
    setDefaultBarThickness(2,4);
    setDefaultBarThickness(2,5);
    setDefaultBarThickness(2,6);

    setPlotType(PLOTTYPE_SQUARE ,0);
    setPlotType(PLOTTYPE_SQUARE ,1); 
    setPlotType(PLOTTYPE_SQUARE ,2);
    setPlotType(PLOTTYPE_SQUARE ,3);
    setPlotType(PLOTTYPE_SQUARE ,4);
    setPlotType(PLOTTYPE_SQUARE ,5); 
    setPlotType(PLOTTYPE_SQUARE ,6);




    var iDebug = new FunctionParameter("iDebug", FunctionParameter.BOOLEAN);
   iDebug.setDefault( false );

    var iAlert = new FunctionParameter("iAlert", FunctionParameter.BOOLEAN);
   iAlert.setDefault( false );



    var iDecimals = new FunctionParameter("iDecimals", FunctionParameter.NUMBER);
   iDecimals.setDefault( 4 );

    var iPlot = new FunctionParameter("iPlot", FunctionParameter.BOOLEAN);
    iPlot.setDefault( true );


    var iPeriods = new FunctionParameter("iPeriods", FunctionParameter.NUMBER);
   iPeriods.setDefault( 05 );


    var iLevel1 = new FunctionParameter("iLevel1", FunctionParameter.NUMBER);
   iLevel1.setDefault( .24 );


    var iLevel2 = new FunctionParameter("iLevel2", FunctionParameter.NUMBER);
   iLevel2.setDefault( .382 );

    var iLevel3 = new FunctionParameter("iLevel3", FunctionParameter.NUMBER);
   iLevel3.setDefault( .500 );


    var iLevel4 = new FunctionParameter("iLevel4", FunctionParameter.NUMBER);
   iLevel4.setDefault( .618 );


    var iLevel5 = new FunctionParameter("iLevel5", FunctionParameter.NUMBER);
   iLevel5.setDefault( .76 );
}

var Dynamic_77          = 0;
var Dynamic_61          = 0;
var Dynamic_50          = 0;
var Dynamic_38          = 0;
var Dynamic_23          = 0;

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


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

// askForInput();


function main( iAlert , iPlot,  iDecimals, iPeriods, iDebug,
               iLevel1,iLevel2,iLevel3,iLevel4,iLevel5   ) {

//    if (close(-1)==null)
   //     return;
     


  // initialize upon first loading formula

    if(getBarState() == BARSTATE_ALLBARS) {
        drawTextPixel( 5, 45, " TRO_DYNAMIC_FibsSR2 @URL=EFS:editParameters", Color.white, Color.green,
            Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON,
            "Comic Sans MS", 13, "UpExp");
        vDate = new Date();
        vInterval = getInterval();
        vSymbol = getSymbol().toUpperCase();
   
        // for RTH, eg, to convert, ES Z2 to ES Z2=2
        var rootSymbol = vSymbol.substring(0,3);
        if (rootSymbol == "ES " || rootSymbol == "NQ ")
            if ( vSymbol.indexOf("=2") == -1 ) vSymbol += "=2";
   
        vSymbol += ",D";
 //       return null;
    }

    if ( PrevDynamic_R==null)  PrevDynamic_R = 0;

    if ( PrevDynamic_S==null)  PrevDynamic_S = 0;


    if( getBarState() == BARSTATE_NEWBAR && getDay() != getDay(-1) ) {
       Dynamic_R =    high() ;  // dynamic Resistance
       Dynamic_S =    low() ;  // dynamic Suport

         PrevDynamic_R = high() ;
         PrevDynamic_S = low() ;
           xShEntry = high()  ;
           xLgEntry = low() ;
    }



if ( Dynamic_R != PrevDynamic_R ) {
   OldDynamic_R = PrevDynamic_R ;
   }
      
if ( Dynamic_S != PrevDynamic_S ) {
   OldDynamic_S  = PrevDynamic_S ;
   }
   
OldDynamic_R = PrevDynamic_R ;
OldDynamic_S = PrevDynamic_S ;

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;
        }
}

   
   
    if (Dynamic_R == null || Dynamic_S == null ) {
        return;
    } else {


if(iDebug == true){

debugPrint( "--------------------------------"    + "\n" );

debugPrint( "DYNAMIC SUPPORT:    " + ( Dynamic_S )  + "\n" );
debugPrint( "LOW:                " + ( low(0) ) + "\n" );
debugPrint( "PrevDynamic_S:      " + ( PrevDynamic_S ) + "\n" );
debugPrint( "xLL:                " + ( rnd(xLL)*1 ) + "\n" );

debugPrint( "DYNAMIC RESISTANCE: " + ( Dynamic_R ) + "\n" );
debugPrint( "HIGH:               " + ( high(0) )  + "\n" );
debugPrint( "PrevDynamic_R:      " + ( PrevDynamic_R ) +  "\n" );
debugPrint( "xHH:                " + ( rnd(xHH)*1) + "\n" );

debugPrint( getValue( "Time" )      + "\n" );
debugPrint( "------- TRO_DYNAMIC_FibsSR2 ---------"    + "\n" );

}

//  ALERT

    if(   close(0) >= Dynamic_R ){
      if( iAlert == true ) {
   Alert.addToList(getSymbol(), Dynamic_R +" DYNAMIC RESISTANCE", Color.blue, Color.black);
        Alert.playSound("ding.wav");
      }


     }
 
    if(  close(0) <= Dynamic_S ){
      if( iAlert == true ) {
   Alert.addToList(getSymbol(), Dynamic_S +" DYNAMIC SUPPORT", Color.red, Color.black);
        Alert.playSound("ding.wav");
      }

 
     }



if( high(0) == Dynamic_R ) {
    xShEntry = low(0);
}


if( low(0) == Dynamic_S ) {
    xLgEntry = high(0);
}
 


var xFibRange = Dynamic_R - Dynamic_S ;


var vFib1   =  ( iLevel1 * xFibRange ) + Dynamic_S   ;
var vFib2   =  ( iLevel2 * xFibRange ) + Dynamic_S   ;
var vFib3   =  ( iLevel3 * xFibRange ) + Dynamic_S   ;
var vFib4   =  ( iLevel4 * xFibRange ) + Dynamic_S   ;
var vFib5   =  ( iLevel5 * xFibRange ) + Dynamic_S   ;
 



var xFib1   = rnd( vFib1, iDecimals )  ;
var xFib2   = rnd( vFib2, iDecimals )  ;
var xFib3   = rnd( vFib3, iDecimals )  ;
var xFib4   = rnd( vFib4, iDecimals )  ;
var xFib5   = rnd( vFib5, iDecimals )  ;
 


if(iPlot == true ) { return new Array( Dynamic_R ,Dynamic_S , xFib5 ,xFib4 ,xFib3,xFib2,xFib1 ); }
else{ return new Array( Dynamic_R ,Dynamic_S ); }
    }
}






function editParameters() {
    askForInput("TRO_DYNAMIC_FibsSR2");
    return;
}

// rnd function - round to iDecimals places
function rnd(value, iDecimals ) { 

value =  value * Math.pow(10, iDecimals);

    return Math.round(value, iDecimals) / Math.pow(10, iDecimals);
}


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”