Page 1 of 20

eSignal - TREND INDICATOR

Posted: Wed Jul 26, 2006 5:56 pm
by TheRumpledOne
Do we need separate threads for eSignal code?

I converted my TREND, OHMLC, Dynamic S/R and SHME_Ind2 indicators to eSignal.



Posted: Wed Jul 26, 2006 9:01 pm
by michal.kreslik
Great, Avery,

could you please post the eSignal code? I guess we'd all like to see how does it look.

Michal

Posted: Sat Jul 29, 2006 3:30 pm
by TheRumpledOne
SLOT MACHINE TREND INDICATOR FOR ESIGNAL


I owe a HUGE thank you to Augustus.

Augustus posted code on the eSignal forum that was just what I needed to build my SLOT MACHINE TREND INDICATOR.



This one is actually more flexible than my TradeStation version - you can select the moving average types ( simple, exponential, weighted ).

Notice the length is part of the column heading. Couldn't do that with TradeStation!

Also, the multifrequency is built in. You don't have to load up mutiple radarscreen rows.

EFS file attached.

TradeStation, you're going to be #2 or less sooner than you think!!

Posted: Sat Jul 29, 2006 3:51 pm
by tommy23
I did not find the SLOT MACHINE TREND INDICATOR attached efs file mentioned in your post - will you please post it so I can download it - it is awesome

Thank you

Posted: Sat Jul 29, 2006 4:04 pm
by TheRumpledOne
EFS ATTACHED

MICHAL THE ATTACHMENTS ARE BROKEN!!

Posted: Sat Jul 29, 2006 4:06 pm
by TheRumpledOne

Code: Select all


/*****************************************************************

Studie: Marketcenter

Autor : augustus

Version: Test 25.07


// TRO_SM_TREND 20060726




Provided By : eSignal (c) Copyright 2004
Description:  Pixel Spacing Example

drawTextPixel(xBar, yValue, Text, [FGColor], [BGColor], [Flags],
        [FontName], [FontSize], [TagName], [cx], [cy])

This function is used to draw text on the chart at precise pixel
locations. It is used in conjunction with the getTextHeight() and
getTextWidth() functions.

xBar:  Relative position where text should appear.
yValue:  y-axis value where text should appear
Text:  The text that should be displayed
FGColor:  Optional. If not provided, pass null. Foreground color of the text.
BGColor:  Optional. if not provided, pass null. Background color of the text
Flags:  Text Flags (these can be ORd together). Pass null if not using flags.
FontName:  Optional. If not provided, pass null. Otherwise, pass a font name (e.g, "Courier" or "Arial").
FontSize:  Optional. If not provided, pass null. Otherwise, pass the font size to use (e.g., 11 or 15 or 8, etc.)
TagName:  A unique identifier for this text object.
cx:   Optional. Pixel spacing control.
cy:   Optional. Pixel spacing control.


Notes:

The cx and cy parameters control the
width (cx) and height (cy) of the text label.  They are also
available in the drawTextRelative and drawTextAbsolute functions,
but are not very useful unless you are using them in combination
with text flags, RELATIVETOTOP, RELATIVETOLEFT and RELATIVETOBOTTOM. 
Both cx and cy require whole numbers.

You can pass positive or negative numbers to these parameters.
If you use positive whole numbers then the size is based on that
number of pixels.
    cx of 15 will be the width of the text label of 15 pixels.
    cy of 15 will be the height of the text label of 15 pixels.
If you use negative whole numbers then the size is relative to the
specified font size.
    cx of -15 will be the approxomate width of 15 characters of the
        specified font.
    cy of -2 will be 2 times the height of the specified
        font.  -3 would be 3 times the height etc.


The formula example below draws a table containing
3 columns and 2 rows of text labels.


Verwendete Indikatoren:


*****************************************************************/

var nFontCY = 0;
var nFontCX = 0;
var nColWidth   = 0;
var nRowThickness = 1;
var nFontSize   = 10;
var sStr;
var tStr;
var diff1 =0;
var diff2 =0;
var midpoint1 =0;
var realtimepivot =0;


var xAvgr1c1 = null;
var xAvgr1c2 = null;
var xAvgr1c3 = null;
var xAvgr1c4 = null;

var xAvgr2c1 = null;
var xAvgr2c2 = null;
var xAvgr2c3 = null;
var xAvgr2c4 = null;

var xAvgr3c1 = null;
var xAvgr3c2 = null;
var xAvgr3c3 = null;
var xAvgr3c4 = null; 

var xAvgr4c1 = null;
var xAvgr4c2 = null;
var xAvgr4c3 = null;
var xAvgr4c4 = null; 

var xAvgr5c1 = null;
var xAvgr5c2 = null;
var xAvgr5c3 = null;
var xAvgr5c4 = null;

var xAvgr6c1 = null;
var xAvgr6c2 = null;
var xAvgr6c3 = null;
var xAvgr6c4 = null;

var xAvgr7c1 = null;
var xAvgr7c2 = null;
var xAvgr7c3 = null;
var xAvgr7c4 = null;



function preMain() {
    setStudyTitle("TRO_SM_TREND");
    setShowCursorLabel(false);
    setShowTitleParameters(false);
   

    var iButtonX = new FunctionParameter("iButtonX", FunctionParameter.NUMBER);
   iButtonX.setDefault( 1 );

    var iButtonY = new FunctionParameter("iButtonY", FunctionParameter.NUMBER);
   iButtonY.setDefault( 1 );


    var iFontSize = new FunctionParameter("iFontSize", FunctionParameter.NUMBER);
   iFontSize.setDefault( 10 );
 

    var iDecimals = new FunctionParameter("iDecimals", FunctionParameter.NUMBER);
   iDecimals.setDefault( 2 );
        iDecimals.setName("Round to X decimals");

    var iInterval1 = new FunctionParameter("iInterval1", FunctionParameter.STRING);
   iInterval1.addOption("D");
        iInterval1.addOption("W");
        iInterval1.addOption("M");
        iInterval1.addOption("T");
   iInterval1.setDefault( "1" );
        iInterval1.setName("Interval 1");

    var iInterval2 = new FunctionParameter("iInterval2", FunctionParameter.STRING);
   iInterval2.addOption("D");
        iInterval2.addOption("W");
        iInterval2.addOption("M");
        iInterval2.addOption("T");
   iInterval2.setDefault( "5" );
        iInterval2.setName("Interval 2");

    var iInterval3 = new FunctionParameter("iInterval3", FunctionParameter.STRING);
   iInterval3.addOption("D");
        iInterval3.addOption("W");
        iInterval3.addOption("M");
        iInterval3.addOption("T");
   iInterval3.setDefault( "15" );
        iInterval3.setName("Interval 3");

    var iInterval4 = new FunctionParameter("iInterval4", FunctionParameter.STRING);
   iInterval4.addOption("D");
        iInterval4.addOption("W");
        iInterval4.addOption("M");
        iInterval4.addOption("T");
   iInterval4.setDefault( "60" );
        iInterval4.setName("Interval 4");


    var iInterval5 = new FunctionParameter("iInterval5", FunctionParameter.STRING);
   iInterval5.addOption("D");
        iInterval5.addOption("W");
        iInterval5.addOption("M");
        iInterval5.addOption("T");
   iInterval5.setDefault( "D" );
        iInterval5.setName("Interval 5");

    var iInterval6 = new FunctionParameter("iInterval6", FunctionParameter.STRING);
   iInterval6.addOption("D");
        iInterval6.addOption("W");
        iInterval6.addOption("M");
        iInterval6.addOption("T");
   iInterval6.setDefault( "W" );
        iInterval6.setName("Interval 6");

    var iInterval7 = new FunctionParameter("iInterval7", FunctionParameter.STRING);
   iInterval7.addOption("D");
        iInterval7.addOption("W");
        iInterval7.addOption("M");
        iInterval7.addOption("T");
   iInterval7.setDefault( "M" );
        iInterval7.setName("Interval 7");

    var iAvgType1 = new FunctionParameter("iAvgType1", FunctionParameter.STRING);
        iAvgType1.addOption("Simple");
        iAvgType1.addOption("Exponential");
        iAvgType1.addOption("Weighted");
        iAvgType1.addOption("Volume Weighted");
   iAvgType1.setDefault( "Exponential" );
   iAvgType1.setName("Fast AVG Type");

    var iAvgType2 = new FunctionParameter("iAvgType2", FunctionParameter.STRING);
        iAvgType2.addOption("Simple");
        iAvgType2.addOption("Exponential");
        iAvgType2.addOption("Weighted");
        iAvgType2.addOption("Volume Weighted");
   iAvgType2.setDefault( "Exponential" );
   iAvgType2.setName("Med AVG Type");


    var iAvgType3 = new FunctionParameter("iAvgType3", FunctionParameter.STRING);
        iAvgType3.addOption("Simple");
        iAvgType3.addOption("Exponential");
        iAvgType3.addOption("Weighted");
        iAvgType3.addOption("Volume Weighted");
   iAvgType3.setDefault( "Exponential" );
   iAvgType3.setName("Slow AVG Type");

    var iAvgType4 = new FunctionParameter("iAvgType4", FunctionParameter.STRING);
        iAvgType4.addOption("Simple");
        iAvgType4.addOption("Exponential");
        iAvgType4.addOption("Weighted");
        iAvgType4.addOption("Volume Weighted");
   iAvgType4.setDefault( "Exponential" );
   iAvgType4.setName("Slowest AVG Type");

    var iLength1 = new FunctionParameter("iLength1", FunctionParameter.NUMBER);
   iLength1.setDefault( 05 );
   iLength1.setName("Fast AVG Length");

    var iLength2 = new FunctionParameter("iLength2", FunctionParameter.NUMBER);
   iLength2.setDefault( 10 );
   iLength2.setName("Med AVG Length");

    var iLength3 = new FunctionParameter("iLength3", FunctionParameter.NUMBER);
   iLength3.setDefault( 20 );
   iLength3.setName("Slow AVG Length");

    var iLength4 = new FunctionParameter("iLength4", FunctionParameter.NUMBER);
   iLength4.setDefault( 40 );
   iLength4.setName("Slowest AVG Length");

    /***** Column Width is used here for the cx parameter *****/
   var fp = new FunctionParameter("inputColWidth", FunctionParameter.NUMBER);
   fp.setName("Column Width");
   fp.setDefault(80);

    /***** Row Thickness is used here for the cy parameter *****/
   var fp = new FunctionParameter("inputRowThickness", FunctionParameter.NUMBER);
   fp.setName("Row Thickness");
   fp.setDefault(-1.2);

   var fp = new FunctionParameter("inputFontSize", FunctionParameter.NUMBER);
   fp.setName("Font Size");
   fp.setLowerLimit(1);
   fp.setDefault(11);

    /*****
        With drawTextPixel, X Start = the number of pixels from the left of
            the window.
        With drawTextRelative or Absolute, X Start will be the bar index unless
            the RELATIVETO### text flags are used.  In which case the values
            will represent pixels.
    *****/
   var fp = new FunctionParameter("inputXstart", FunctionParameter.NUMBER);
   fp.setName("X Start");
   fp.setLowerLimit(1);
   fp.setDefault(5);

    /*****
        With drawTextPixel, Y Start = the number of pixels from the top of
            the window.
        With drawTextRelative or Absolute, Y Start will be relative to the
            price scale of the chart symbol unless the RELATIVETO### text
            flags are used.  In which case the values will represent pixels.
    *****/
   var fp = new FunctionParameter("inputYstart", FunctionParameter.NUMBER);
   fp.setName("Y Start");
   fp.setLowerLimit(1);
   fp.setDefault(20);   
   
       
    var fp4 = new FunctionParameter("roundlen", FunctionParameter.NUMBER);
        fp4.setName("roundlen");
        fp4.setLowerLimit(0);
        fp4.setDefault(2);
}

var bEdit = true;

//Für Trendtrader
var ret = null;
var avgTR = null;
var highestC = null;
var lowestC = null;
var bInit = false;

// Für HiLo-Activator
var vMA1 = null;
var vMA2 = null;
var Swing = 0;
var cInit = false;

//Truth
var dEdit = true;
var vATR = null;
var vDonchian = null;

function main(
           
            inputColWidth, inputRowThickness, inputFontSize,
            inputXstart, inputYstart,
             
            roundlen, 

            iInterval1, iInterval2, iInterval3, iInterval4, iInterval5, iInterval6, iInterval7,
            iAvgType1, iLength1,
            iAvgType2, iLength2,
            iAvgType3, iLength3,
            iAvgType4, iLength4,
               

        iFontSize, iButtonX, iButtonY) {
           
           
   
  // initialize upon first loading formula
    if(getBarState() == BARSTATE_ALLBARS) {
        drawTextPixel( iButtonX , iButtonY, " TRO_SM_TREND @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();
        iInterval = 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;
    }
         
   
   
   
   
    //  prevents the formula from executing except at bar 0 and on new bar.
   if(getCurrentBarIndex() != 0 && getBarState() != BARSTATE_NEWBAR) return;

    // initialization routine to set values for global variables
    if (bEdit == true) {
        nColWidth = Math.round(inputColWidth);
        nRowThickness = Math.round(inputRowThickness);
        nFontSize = Math.round(inputFontSize);
       
        /***** Used for setting the space between x/y anchors for text
            labels based on the font height *****/
        if (nRowThickness < 0) {
            nFontCY = getTextHeight("A", null, nFontSize)*(nRowThickness);
        } else {
            nFontCY = -nRowThickness;
        }
       
        /***** This will get the maximum width for the specified string
            based on the specified font type.  If the font type is not
            specified it uses a default Arial. *****/
        if (nColWidth < 0) {
            nFontCX = getTextWidth("Row ## Col ##", null, nFontSize);
        } else {
            nFontCX = nColWidth;
        }
        bEdit = false;
    }

    var nX = inputXstart;
    var nY = inputYstart;

   
   
    //DISPLAY  COLUMN HEADINGS
   
        tStr= "FAST=" + iLength1 ;
    drawTextPixel(nX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c1", nColWidth, nRowThickness);

        tStr= "MED=" + iLength2 ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c2", nColWidth, nRowThickness);

        tStr= "SLOW=" + iLength3 ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c3", nColWidth, nRowThickness);


        tStr= "SLOWEST=" + iLength4 ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c4", nColWidth, nRowThickness);
       

        tStr= "Interval "  ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c5", nColWidth, nRowThickness);
       
   
    //Zeile2
   
    nX = inputXstart;
    nY -= nFontCY;


    if(bInit==false){
        avgTR      = wma(21,atr(1));
        highestC   = upperDonchian(21,close());
        lowestC    = lowerDonchian(21,close());
        bInit=true;

// INITIALIZE ROW 1
   
    if(iInterval1 != 0 ) {
   
      if( iAvgType1 == "Simple" )      { xAvgr1c1  = sma( iLength1 , inv(iInterval1) ) } ;
      if( iAvgType1 == "Exponential" ) { xAvgr1c1  = ema( iLength1 , inv(iInterval1) ) } ;
      if( iAvgType1 == "Weighted" )    { xAvgr1c1  = ema( iLength1 , inv(iInterval1) ) } ;
 
      if( iAvgType2 == "Simple" )      { xAvgr1c2  = sma( iLength2 , inv(iInterval1) ) } ;
      if( iAvgType2 == "Exponential" ) { xAvgr1c2  = ema( iLength2 , inv(iInterval1) ) } ;
      if( iAvgType2 == "Weighted" )    { xAvgr1c2  = ema( iLength2 , inv(iInterval1) ) } ;
 
      if( iAvgType3 == "Simple" )      { xAvgr1c3  = sma( iLength3 , inv(iInterval1) ) } ;
      if( iAvgType3 == "Exponential" ) { xAvgr1c3  = ema( iLength3 , inv(iInterval1) ) } ;
      if( iAvgType3 == "Weighted" )    { xAvgr1c3  = ema( iLength3 , inv(iInterval1) ) } ;
 
      if( iAvgType4 == "Simple" )      { xAvgr1c4  = sma( iLength4 , inv(iInterval1) ) } ;
      if( iAvgType4 == "Exponential" ) { xAvgr1c4  = ema( iLength4 , inv(iInterval1) ) } ;
      if( iAvgType4 == "Weighted" )    { xAvgr1c4  = ema( iLength4 , inv(iInterval1) ) } ;
 

   } // iInterval1

// INITIALIZE ROW 2
   
    if(iInterval2 != 0 ) {
   
      if( iAvgType1 == "Simple" )      { xAvgr2c1  = sma( iLength1 , inv(iInterval2) ) } ;
      if( iAvgType1 == "Exponential" ) { xAvgr2c1  = ema( iLength1 , inv(iInterval2) ) } ;
      if( iAvgType1 == "Weighted" )    { xAvgr2c1  = ema( iLength1 , inv(iInterval2) ) } ;
 
      if( iAvgType2 == "Simple" )      { xAvgr2c2  = sma( iLength2 , inv(iInterval2) ) } ;
      if( iAvgType2 == "Exponential" ) { xAvgr2c2  = ema( iLength2 , inv(iInterval2) ) } ;
      if( iAvgType2 == "Weighted" )    { xAvgr2c2  = ema( iLength2 , inv(iInterval2) ) } ;
 
      if( iAvgType3 == "Simple" )      { xAvgr2c3  = sma( iLength3 , inv(iInterval2) ) } ;
      if( iAvgType3 == "Exponential" ) { xAvgr2c3  = ema( iLength3 , inv(iInterval2) ) } ;
      if( iAvgType3 == "Weighted" )    { xAvgr2c3  = ema( iLength3 , inv(iInterval2) ) } ;
 
      if( iAvgType4 == "Simple" )      { xAvgr2c4  = sma( iLength4 , inv(iInterval2) ) } ;
      if( iAvgType4 == "Exponential" ) { xAvgr2c4  = ema( iLength4 , inv(iInterval2) ) } ;
      if( iAvgType4 == "Weighted" )    { xAvgr2c4  = ema( iLength4 , inv(iInterval2) ) } ;
 

   } // iInterval2


// INITIALIZE ROW 3
   
    if(iInterval3 != 0 ) {
   
      if( iAvgType1 == "Simple" )      { xAvgr3c1  = sma( iLength1 , inv(iInterval3) ) } ;
      if( iAvgType1 == "Exponential" ) { xAvgr3c1  = ema( iLength1 , inv(iInterval3) ) } ;
      if( iAvgType1 == "Weighted" )    { xAvgr3c1  = ema( iLength1 , inv(iInterval3) ) } ;
 
      if( iAvgType2 == "Simple" )      { xAvgr3c2  = sma( iLength2 , inv(iInterval3) ) } ;
      if( iAvgType2 == "Exponential" ) { xAvgr3c2  = ema( iLength2 , inv(iInterval3) ) } ;
      if( iAvgType2 == "Weighted" )    { xAvgr3c2  = ema( iLength2 , inv(iInterval3) ) } ;
 
      if( iAvgType3 == "Simple" )      { xAvgr3c3  = sma( iLength3 , inv(iInterval3) ) } ;
      if( iAvgType3 == "Exponential" ) { xAvgr3c3  = ema( iLength3 , inv(iInterval3) ) } ;
      if( iAvgType3 == "Weighted" )    { xAvgr3c3  = ema( iLength3 , inv(iInterval3) ) } ;
 
      if( iAvgType4 == "Simple" )      { xAvgr3c4  = sma( iLength4 , inv(iInterval3) ) } ;
      if( iAvgType4 == "Exponential" ) { xAvgr3c4  = ema( iLength4 , inv(iInterval3) ) } ;
      if( iAvgType4 == "Weighted" )    { xAvgr3c4  = ema( iLength4 , inv(iInterval3) ) } ;
 

   } // iInterval3



// INITIALIZE ROW 4
   
    if(iInterval4 != 0 ) {
   
      if( iAvgType1 == "Simple" )      { xAvgr4c1  = sma( iLength1 , inv(iInterval4) ) } ;
      if( iAvgType1 == "Exponential" ) { xAvgr4c1  = ema( iLength1 , inv(iInterval4) ) } ;
      if( iAvgType1 == "Weighted" )    { xAvgr4c1  = ema( iLength1 , inv(iInterval4) ) } ;
 
      if( iAvgType2 == "Simple" )      { xAvgr4c2  = sma( iLength2 , inv(iInterval4) ) } ;
      if( iAvgType2 == "Exponential" ) { xAvgr4c2  = ema( iLength2 , inv(iInterval4) ) } ;
      if( iAvgType2 == "Weighted" )    { xAvgr4c2  = ema( iLength2 , inv(iInterval4) ) } ;
 
      if( iAvgType3 == "Simple" )      { xAvgr4c3  = sma( iLength3 , inv(iInterval4) ) } ;
      if( iAvgType3 == "Exponential" ) { xAvgr4c3  = ema( iLength3 , inv(iInterval4) ) } ;
      if( iAvgType3 == "Weighted" )    { xAvgr4c3  = ema( iLength3 , inv(iInterval4) ) } ;
 
      if( iAvgType4 == "Simple" )      { xAvgr4c4  = sma( iLength4 , inv(iInterval4) ) } ;
      if( iAvgType4 == "Exponential" ) { xAvgr4c4  = ema( iLength4 , inv(iInterval4) ) } ;
      if( iAvgType4 == "Weighted" )    { xAvgr4c4  = ema( iLength4 , inv(iInterval4) ) } ;
 

   } // iInterval4

// INITIALIZE ROW 5
   
    if(iInterval5 != 0 ) {
   
      if( iAvgType1 == "Simple" )      { xAvgr5c1  = sma( iLength1 , inv(iInterval5) ) } ;
      if( iAvgType1 == "Exponential" ) { xAvgr5c1  = ema( iLength1 , inv(iInterval5) ) } ;
      if( iAvgType1 == "Weighted" )    { xAvgr5c1  = ema( iLength1 , inv(iInterval5) ) } ;
 
      if( iAvgType2 == "Simple" )      { xAvgr5c2  = sma( iLength2 , inv(iInterval5) ) } ;
      if( iAvgType2 == "Exponential" ) { xAvgr5c2  = ema( iLength2 , inv(iInterval5) ) } ;
      if( iAvgType2 == "Weighted" )    { xAvgr5c2  = ema( iLength2 , inv(iInterval5) ) } ;
 
      if( iAvgType3 == "Simple" )      { xAvgr5c3  = sma( iLength3 , inv(iInterval5) ) } ;
      if( iAvgType3 == "Exponential" ) { xAvgr5c3  = ema( iLength3 , inv(iInterval5) ) } ;
      if( iAvgType3 == "Weighted" )    { xAvgr5c3  = ema( iLength3 , inv(iInterval5) ) } ;
 
      if( iAvgType4 == "Simple" )      { xAvgr5c4  = sma( iLength4 , inv(iInterval5) ) } ;
      if( iAvgType4 == "Exponential" ) { xAvgr5c4  = ema( iLength4 , inv(iInterval5) ) } ;
      if( iAvgType4 == "Weighted" )    { xAvgr5c4  = ema( iLength4 , inv(iInterval5) ) } ;
 

   } // iInterval5

// INITIALIZE ROW 6
   
    if(iInterval6 != 0 ) {
   
      if( iAvgType1 == "Simple" )      { xAvgr6c1  = sma( iLength1 , inv(iInterval6) ) } ;
      if( iAvgType1 == "Exponential" ) { xAvgr6c1  = ema( iLength1 , inv(iInterval6) ) } ;
      if( iAvgType1 == "Weighted" )    { xAvgr6c1  = ema( iLength1 , inv(iInterval6) ) } ;
 
      if( iAvgType2 == "Simple" )      { xAvgr6c2  = sma( iLength2 , inv(iInterval6) ) } ;
      if( iAvgType2 == "Exponential" ) { xAvgr6c2  = ema( iLength2 , inv(iInterval6) ) } ;
      if( iAvgType2 == "Weighted" )    { xAvgr6c2  = ema( iLength2 , inv(iInterval6) ) } ;
 
      if( iAvgType3 == "Simple" )      { xAvgr6c3  = sma( iLength3 , inv(iInterval6) ) } ;
      if( iAvgType3 == "Exponential" ) { xAvgr6c3  = ema( iLength3 , inv(iInterval6) ) } ;
      if( iAvgType3 == "Weighted" )    { xAvgr6c3  = ema( iLength3 , inv(iInterval6) ) } ;
 
      if( iAvgType4 == "Simple" )      { xAvgr6c4  = sma( iLength4 , inv(iInterval6) ) } ;
      if( iAvgType4 == "Exponential" ) { xAvgr6c4  = ema( iLength4 , inv(iInterval6) ) } ;
      if( iAvgType4 == "Weighted" )    { xAvgr6c4  = ema( iLength4 , inv(iInterval6) ) } ;
 

   } // iInterval6



// INITIALIZE ROW 7
   
    if(iInterval7 != 0 ) {
   
      if( iAvgType1 == "Simple" )      { xAvgr7c1  = sma( iLength1 , inv(iInterval7) ) } ;
      if( iAvgType1 == "Exponential" ) { xAvgr7c1  = ema( iLength1 , inv(iInterval7) ) } ;
      if( iAvgType1 == "Weighted" )    { xAvgr7c1  = ema( iLength1 , inv(iInterval7) ) } ;
 
      if( iAvgType2 == "Simple" )      { xAvgr7c2  = sma( iLength2 , inv(iInterval7) ) } ;
      if( iAvgType2 == "Exponential" ) { xAvgr7c2  = ema( iLength2 , inv(iInterval7) ) } ;
      if( iAvgType2 == "Weighted" )    { xAvgr7c2  = ema( iLength2 , inv(iInterval7) ) } ;
 
      if( iAvgType3 == "Simple" )      { xAvgr7c3  = sma( iLength3 , inv(iInterval7) ) } ;
      if( iAvgType3 == "Exponential" ) { xAvgr7c3  = ema( iLength3 , inv(iInterval7) ) } ;
      if( iAvgType3 == "Weighted" )    { xAvgr7c3  = ema( iLength3 , inv(iInterval7) ) } ;
 
      if( iAvgType4 == "Simple" )      { xAvgr7c4  = sma( iLength4 , inv(iInterval7) ) } ;
      if( iAvgType4 == "Exponential" ) { xAvgr7c4  = ema( iLength4 , inv(iInterval7) ) } ;
      if( iAvgType4 == "Weighted" )    { xAvgr7c4  = ema( iLength4 , inv(iInterval7) ) } ;
 

   } // iInterval7



    } // bInit
     
   
// PROCESS ROW 1

    if( iInterval1 != 0 ) {
       
// PROCESS ROW 1 COLUMN 1 
        if( xAvgr1c1.getValue(0)  > xAvgr1c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr1c1.getValue(0)  < xAvgr1c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c1", nColWidth, nRowThickness);


// PROCESS ROW 1 COLUMN 2 
        if( xAvgr1c2.getValue(0)  > xAvgr1c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr1c2.getValue(0)  < xAvgr1c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c2", nColWidth, nRowThickness);
       
// PROCESS ROW 1 COLUMN 3 
        if( xAvgr1c3.getValue(0)  > xAvgr1c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr1c3.getValue(0)  < xAvgr1c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c3", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 4 
        if( xAvgr1c4.getValue(0)  > xAvgr1c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr1c4.getValue(0)  < xAvgr1c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c4", nColWidth, nRowThickness);
       


// PROCESS ROW 1 COLUMN 5

        sStr     = ""+ iInterval1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c5", nColWidth, nRowThickness);
 

        } // iInterval1
   

// PROCESS ROW 2

    if( iInterval2 != 0 ) {

nX = inputXstart;
nY -= nFontCY; ;
       
// PROCESS ROW 2 COLUMN 1 
        if( xAvgr2c1.getValue(0)  > xAvgr2c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr2c1.getValue(0)  < xAvgr2c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col1", nColWidth, nRowThickness);


// PROCESS ROW 2 COLUMN 2 
        if( xAvgr2c2.getValue(0)  > xAvgr2c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr2c2.getValue(0)  < xAvgr2c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col2", nColWidth, nRowThickness);
       
// PROCESS ROW 2 COLUMN 3 
        if( xAvgr2c3.getValue(0)  > xAvgr2c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr2c3.getValue(0)  < xAvgr2c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 2 COLUMN 4 
        if( xAvgr2c4.getValue(0)  > xAvgr2c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr2c4.getValue(0)  < xAvgr2c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col4", nColWidth, nRowThickness);
       


// PROCESS ROW 2 COLUMN 5

        sStr     = ""+ iInterval2 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col5", nColWidth, nRowThickness);
 

        } // iInterval2 


// PROCESS ROW 3

    if( iInterval3 != 0 ) {

nX = inputXstart;
nY -= nFontCY; ;
       
// PROCESS ROW 3 COLUMN 1 
        if( xAvgr3c1.getValue(0)  > xAvgr3c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr3c1.getValue(0)  < xAvgr3c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col1", nColWidth, nRowThickness);


// PROCESS ROW 3 COLUMN 2 
        if( xAvgr3c2.getValue(0)  > xAvgr3c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr3c2.getValue(0)  < xAvgr3c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col2", nColWidth, nRowThickness);
       
// PROCESS ROW 3 COLUMN 3 
        if( xAvgr3c3.getValue(0)  > xAvgr3c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr3c3.getValue(0)  < xAvgr3c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 3 COLUMN 4 
        if( xAvgr3c4.getValue(0)  > xAvgr3c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr3c4.getValue(0)  < xAvgr3c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col4", nColWidth, nRowThickness);
       


// PROCESS ROW 3 COLUMN 5

        sStr     = ""+ iInterval3 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col5", nColWidth, nRowThickness);
 

        } // iInterval3 
   

// PROCESS ROW 4

    if( iInterval4 != 0 ) {

nX = inputXstart;
nY -= nFontCY; ;
       
// PROCESS ROW 4 COLUMN 1 
        if( xAvgr4c1.getValue(0)  > xAvgr4c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr4c1.getValue(0)  < xAvgr4c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col1", nColWidth, nRowThickness);


// PROCESS ROW 4 COLUMN 2 
        if( xAvgr4c2.getValue(0)  > xAvgr4c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr4c2.getValue(0)  < xAvgr4c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col2", nColWidth, nRowThickness);
       
// PROCESS ROW 4 COLUMN 3 
        if( xAvgr4c3.getValue(0)  > xAvgr4c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr4c3.getValue(0)  < xAvgr4c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 4 COLUMN 4 
        if( xAvgr4c4.getValue(0)  > xAvgr4c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr4c4.getValue(0)  < xAvgr4c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col4", nColWidth, nRowThickness);
       


// PROCESS ROW 4 COLUMN 5

        sStr     = ""+ iInterval4 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col5", nColWidth, nRowThickness);
 

        } // iInterval4 
 

// PROCESS ROW 5

    if( iInterval5 != 0 ) {

nX = inputXstart;
nY -= nFontCY; ;
       
// PROCESS ROW 5 COLUMN 1 
        if( xAvgr5c1.getValue(0)  > xAvgr5c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr5c1.getValue(0)  < xAvgr5c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row5Col1", nColWidth, nRowThickness);


// PROCESS ROW 5 COLUMN 2 
        if( xAvgr5c2.getValue(0)  > xAvgr5c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr5c2.getValue(0)  < xAvgr5c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row5Col2", nColWidth, nRowThickness);
       
// PROCESS ROW 5 COLUMN 3 
        if( xAvgr5c3.getValue(0)  > xAvgr5c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr5c3.getValue(0)  < xAvgr5c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row5Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 5 COLUMN 4 
        if( xAvgr5c4.getValue(0)  > xAvgr5c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr5c4.getValue(0)  < xAvgr5c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row5Col4", nColWidth, nRowThickness);
       


// PROCESS ROW 5 COLUMN 5

        sStr     = ""+ iInterval5 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row5Col5", nColWidth, nRowThickness);
 

        } // iInterval5 
   


// PROCESS ROW 6

    if( iInterval6 != 0 ) {

nX = inputXstart;
nY -= nFontCY; ;
       
// PROCESS ROW 6 COLUMN 1 
        if( xAvgr6c1.getValue(0)  > xAvgr6c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr6c1.getValue(0)  < xAvgr6c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row6Col1", nColWidth, nRowThickness);


// PROCESS ROW 6 COLUMN 2 
        if( xAvgr6c2.getValue(0)  > xAvgr6c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr6c2.getValue(0)  < xAvgr6c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row6Col2", nColWidth, nRowThickness);
       
// PROCESS ROW 6 COLUMN 3 
        if( xAvgr6c3.getValue(0)  > xAvgr6c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr6c3.getValue(0)  < xAvgr6c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row6Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 6 COLUMN 4 
        if( xAvgr6c4.getValue(0)  > xAvgr6c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr6c4.getValue(0)  < xAvgr6c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row6Col4", nColWidth, nRowThickness);
       


// PROCESS ROW 6 COLUMN 5

        sStr     = ""+ iInterval6 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row6Col5", nColWidth, nRowThickness);
 

        } // iInterval6 
 
// PROCESS ROW 7

    if( iInterval7 != 0 ) {

nX = inputXstart;
nY -= nFontCY; ;
       
// PROCESS ROW 7 COLUMN 1 
        if( xAvgr7c1.getValue(0)  > xAvgr7c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr7c1.getValue(0)  < xAvgr7c1.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row7Col1", nColWidth, nRowThickness);


// PROCESS ROW 7 COLUMN 2 
        if( xAvgr7c2.getValue(0)  > xAvgr7c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr7c2.getValue(0)  < xAvgr7c2.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row7Col2", nColWidth, nRowThickness);
       
// PROCESS ROW 7 COLUMN 3 
        if( xAvgr7c3.getValue(0)  > xAvgr7c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr7c3.getValue(0)  < xAvgr7c3.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row7Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 7 COLUMN 4 
        if( xAvgr7c4.getValue(0)  > xAvgr7c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.green;
           sStr     = "+" ;        } 
        else
        if( xAvgr7c4.getValue(0)  < xAvgr7c4.getValue(-1) ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
           sStr     = "-" ;   }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           sStr     = "=" ; }

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row7Col4", nColWidth, nRowThickness);
       


// PROCESS ROW 7 COLUMN 5

        sStr     = ""+ iInterval7 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row7Col5", nColWidth, nRowThickness);
 

        } // iInterval7 

    return; // MAIN
}


//==rnd will round to N digits.
function rnd(value, N) {
    var n;
    var mult=1;
    for(n=0;n<N;n++) mult*=10;
    value*=mult;
    return Math.round( value,N)/mult;
}

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

milking the cow

Posted: Sat Jul 29, 2006 6:59 pm
by TheRumpledOne
eSIGNAL MILK THE COW SLOT MACHINE INDICATOR



Code: Select all

/*****************************************************************

TRO_MTC 20060728 MILK THE COW SLOT MACHINE INDICATOR

Programmer:  Avery T. Horton, Jr.  aka TheRumpledOne



Provided By : eSignal (c) Copyright 2004
Description:  Pixel Spacing Example

drawTextPixel(xBar, yValue, Text, [FGColor], [BGColor], [Flags],
        [FontName], [FontSize], [TagName], [cx], [cy])

This function is used to draw text on the chart at precise pixel
locations. It is used in conjunction with the getTextHeight() and
getTextWidth() functions.

xBar:  Relative position where text should appear.
yValue:  y-axis value where text should appear
Text:  The text that should be displayed
FGColor:  Optional. If not provided, pass null. Foreground color of the text.
BGColor:  Optional. if not provided, pass null. Background color of the text
Flags:  Text Flags (these can be ORd together). Pass null if not using flags.
FontName:  Optional. If not provided, pass null. Otherwise, pass a font name (e.g, "Courier" or "Arial").
FontSize:  Optional. If not provided, pass null. Otherwise, pass the font size to use (e.g., 11 or 15 or 8, etc.)
TagName:  A unique identifier for this text object.
cx:   Optional. Pixel spacing control.
cy:   Optional. Pixel spacing control.


Notes:

The cx and cy parameters control the
width (cx) and height (cy) of the text label.  They are also
available in the drawTextRelative and drawTextAbsolute functions,
but are not very useful unless you are using them in combination
with text flags, RELATIVETOTOP, RELATIVETOLEFT and RELATIVETOBOTTOM. 
Both cx and cy require whole numbers.

You can pass positive or negative numbers to these parameters.
If you use positive whole numbers then the size is based on that
number of pixels.
    cx of 15 will be the width of the text label of 15 pixels.
    cy of 15 will be the height of the text label of 15 pixels.
If you use negative whole numbers then the size is relative to the
specified font size.
    cx of -15 will be the approxomate width of 15 characters of the
        specified font.
    cy of -2 will be 2 times the height of the specified
        font.  -3 would be 3 times the height etc.


The formula example below draws a table containing
3 columns and 2 rows of text labels.


Verwendete Indikatoren:


*****************************************************************/

var nFontCY = 0;
var nFontCX = 0;
var nColWidth   = 0;
var nRowThickness = 1;
var nFontSize   = 10;
var sStr;
var tStr;
var diff1 =0;
var diff2 =0;
var midpoint1 =0;
var realtimepivot =0;

var xInit   = false;
var xMiddle = null;
var xGap    = null;
var xHiOp   = null;
var xOpLo   = null;

var xOpen   = null;
var xHigh   = null;
var xLow    = null;
var xClose  = null;


function preMain() {
    setStudyTitle("TRO_MTC");
    setShowCursorLabel(false);
    setShowTitleParameters(false);
   

    var iButtonX = new FunctionParameter("iButtonX", FunctionParameter.NUMBER);
   iButtonX.setDefault( 1 );

    var iButtonY = new FunctionParameter("iButtonY", FunctionParameter.NUMBER);
   iButtonY.setDefault( 1 );


    var iFontSize = new FunctionParameter("iFontSize", FunctionParameter.NUMBER);
   iFontSize.setDefault( 10 );
 

    var iDecimals = new FunctionParameter("iDecimals", FunctionParameter.NUMBER);
   iDecimals.setDefault( 2 );
        iDecimals.setName("Round to X decimals");

    /***** Column Width is used here for the cx parameter *****/
   var fp = new FunctionParameter("inputColWidth", FunctionParameter.NUMBER);
   fp.setName("Column Width");
   fp.setDefault(80);

    /***** Row Thickness is used here for the cy parameter *****/
   var fp = new FunctionParameter("inputRowThickness", FunctionParameter.NUMBER);
   fp.setName("Row Thickness");
   fp.setDefault(-1.2);

   var fp = new FunctionParameter("inputFontSize", FunctionParameter.NUMBER);
   fp.setName("Font Size");
   fp.setLowerLimit(1);
   fp.setDefault(11);

    /*****
        With drawTextPixel, X Start = the number of pixels from the left of
            the window.
        With drawTextRelative or Absolute, X Start will be the bar index unless
            the RELATIVETO### text flags are used.  In which case the values
            will represent pixels.
    *****/
   var fp = new FunctionParameter("inputXstart", FunctionParameter.NUMBER);
   fp.setName("X Start");
   fp.setLowerLimit(1);
   fp.setDefault(5);

    /*****
        With drawTextPixel, Y Start = the number of pixels from the top of
            the window.
        With drawTextRelative or Absolute, Y Start will be relative to the
            price scale of the chart symbol unless the RELATIVETO### text
            flags are used.  In which case the values will represent pixels.
    *****/
   var fp = new FunctionParameter("inputYstart", FunctionParameter.NUMBER);
   fp.setName("Y Start");
   fp.setLowerLimit(1);
   fp.setDefault(20);   
   
       
    var fp4 = new FunctionParameter("roundlen", FunctionParameter.NUMBER);
        fp4.setName("roundlen");
        fp4.setLowerLimit(0);
        fp4.setDefault(2);
}

var bEdit = true;


function main(
           
            inputColWidth, inputRowThickness, inputFontSize,
            inputXstart, inputYstart,
             
            iDecimals, 


        iFontSize, iButtonX, iButtonY) {
           
           
   
  // initialize upon first loading formula
    if(getBarState() == BARSTATE_ALLBARS) {
        drawTextPixel( iButtonX , iButtonY, " TRO_MTC @URL=EFS:editParameters", Color.white,    Color.lime,
            Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON,
            "Comic Sans MS", 13, "UpExp");
        vDate = new Date();
        iInterval = 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;
    }
         
   
   
   
   
    //  prevents the formula from executing except at bar 0 and on new bar.
   if(getCurrentBarIndex() != 0 && getBarState() != BARSTATE_NEWBAR) return;

    // initialization routine to set values for global variables
    if (bEdit == true) {
        nColWidth = Math.round(inputColWidth);
        nRowThickness = Math.round(inputRowThickness);
        nFontSize = Math.round(inputFontSize);
       
        /***** Used for setting the space between x/y anchors for text
            labels based on the font height *****/
        if (nRowThickness < 0) {
            nFontCY = getTextHeight("A", null, nFontSize)*(nRowThickness);
        } else {
            nFontCY = -nRowThickness;
        }
       
        /***** This will get the maximum width for the specified string
            based on the specified font type.  If the font type is not
            specified it uses a default Arial. *****/
        if (nColWidth < 0) {
            nFontCX = getTextWidth("Row ## Col ##", null, nFontSize);
        } else {
            nFontCX = nColWidth;
        }
        bEdit = false;
    }

    var nX = inputXstart;
    var nY = inputYstart;

   
   
    //DISPLAY  COLUMN HEADINGS
   
        tStr= "Middle"   ;
    drawTextPixel(nX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c1", nColWidth, nRowThickness);

        tStr= "Gap"  ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c2", nColWidth, nRowThickness);

        tStr= "HiOp"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c3", nColWidth, nRowThickness);


        tStr= "OpLo"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c4", nColWidth, nRowThickness);
       

       
   
    //Zeile2
   
    nX = inputXstart;
    nY -= nFontCY;

    if(xInit==false){

// INITIALIZE ROW 1
      

         xOpen   =  open( inv("D") ) ;
         
         xHigh   =  high( inv("D") ) ;

         xLow    =  low( inv("D") ) ;

         xClose  =  close( inv("D") ) ;

         xInit=true;

    } // xInit
     

 
       
// PROCESS ROW 1 COLUMN 1 
 

var zOpen    = xOpen.getValue(0) ;

var zClose   = xClose.getValue(0) ;
 
var zClose1  = xClose.getValue(-1) ;

var zHigh    = xHigh.getValue(0) ;

var zHigh1   = xHigh.getValue(-1) ;

var zLow     = xLow.getValue(0) ;

var zLow1    = xLow.getValue(-1) ;

var zMid1   = rnd( ((zHigh1 + zLow1) * .50) , 2 )   ;

var zGap    = rnd( (zOpen - zClose1) , 2) ;

        xDiff1 =  rnd( (close(0) - zMid1) ,iDecimals ) ;

        if( xDiff1  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
             ;        } 
        else
        if( xDiff1 < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           
           }

           sStr     = "" + xDiff1 ;
        drawTextPixel(nX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c1", nColWidth, nRowThickness);


// PROCESS ROW 1 COLUMN 2 


        if( zGap  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                  } 
        else
        if( zGap  < 0  ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
             }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
          }

           sStr     = "" + zGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c2", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 3 


        xHiOp =  rnd( ( zHigh - zOpen ) ,iDecimals) ;

        if( xHiOp  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                    } 
        else
        if( xHiOp  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
            }
        sStr     = "" + xHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c3", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 4


 
        xOpLo =  rnd( ( zOpen - zLow ) ,iDecimals) ;


        if( xOpLo  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                   } 
        else
        if( xOpLo  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           }

        sStr     = "" + xOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c4", nColWidth, nRowThickness);
       

/*
debugPrint( "zMid1    : " + formatPriceNumber( zMid1 ) + "\n" );

debugPrint( "zGap    : " + formatPriceNumber( zGap ) + "\n" );

debugPrint( "xHiOp    : " + formatPriceNumber( xHiOp ) + "\n" );

debugPrint( "xOpLo    : " + formatPriceNumber( xOpLo ) + "\n" );
*/


    return; // MAIN
}


//==rnd will round to N digits.
function rnd(value, N) {
    var n;
    var mult=1;
    for(n=0;n<N;n++) mult*=10;
    value*=mult;
    return Math.round( value,N)/mult;
}

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



eSIGNAL SLOT MACHINE MIDDLE INDICATOR

Posted: Sat Jul 29, 2006 7:46 pm
by TheRumpledOne

eSIGNAL SLOT MACHINE MIDDLE INDICATOR





Code: Select all

/*****************************************************************

TRO_SM_MIDDLE 20060728 MIDDLE SLOT MACHINE INDICATOR

Programmer:  Avery T. Horton, Jr.  aka TheRumpledOne



Provided By : eSignal (c) Copyright 2004
Description:  Pixel Spacing Example

drawTextPixel(xBar, yValue, Text, [FGColor], [BGColor], [Flags],
        [FontName], [FontSize], [TagName], [cx], [cy])

This function is used to draw text on the chart at precise pixel
locations. It is used in conjunction with the getTextHeight() and
getTextWidth() functions.

xBar:  Relative position where text should appear.
yValue:  y-axis value where text should appear
Text:  The text that should be displayed
FGColor:  Optional. If not provided, pass null. Foreground color of the text.
BGColor:  Optional. if not provided, pass null. Background color of the text
Flags:  Text Flags (these can be ORd together). Pass null if not using flags.
FontName:  Optional. If not provided, pass null. Otherwise, pass a font name (e.g, "Courier" or "Arial").
FontSize:  Optional. If not provided, pass null. Otherwise, pass the font size to use (e.g., 11 or 15 or 8, etc.)
TagName:  A unique identifier for this text object.
cx:   Optional. Pixel spacing control.
cy:   Optional. Pixel spacing control.


Notes:

The cx and cy parameters control the
width (cx) and height (cy) of the text label.  They are also
available in the drawTextRelative and drawTextAbsolute functions,
but are not very useful unless you are using them in combination
with text flags, RELATIVETOTOP, RELATIVETOLEFT and RELATIVETOBOTTOM. 
Both cx and cy require whole numbers.

You can pass positive or negative numbers to these parameters.
If you use positive whole numbers then the size is based on that
number of pixels.
    cx of 15 will be the width of the text label of 15 pixels.
    cy of 15 will be the height of the text label of 15 pixels.
If you use negative whole numbers then the size is relative to the
specified font size.
    cx of -15 will be the approxomate width of 15 characters of the
        specified font.
    cy of -2 will be 2 times the height of the specified
        font.  -3 would be 3 times the height etc.


The formula example below draws a table containing
3 columns and 2 rows of text labels.


Verwendete Indikatoren:


*****************************************************************/

var nFontCY = 0;
var nFontCX = 0;
var nColWidth   = 0;
var nRowThickness = 1;
var nFontSize   = 10;
var sStr;
var tStr;
var diff1 =0;
var diff2 =0;
var midpoint1 =0;
var realtimepivot =0;

var xInit   = false;
var xMiddle = null;
var xGap    = null;
var xHiOp   = null;
var xOpLo   = null;

var xOpen   = null;
var xHigh   = null;
var xLow    = null;
var xClose  = null;


function preMain() {
    setStudyTitle("TRO_SM_MIDDLE");
    setShowCursorLabel(false);
    setShowTitleParameters(false);
   

    var iButtonX = new FunctionParameter("iButtonX", FunctionParameter.NUMBER);
   iButtonX.setDefault( 1 );

    var iButtonY = new FunctionParameter("iButtonY", FunctionParameter.NUMBER);
   iButtonY.setDefault( 1 );


    var iFontSize = new FunctionParameter("iFontSize", FunctionParameter.NUMBER);
   iFontSize.setDefault( 10 );
 

    var iDecimals = new FunctionParameter("iDecimals", FunctionParameter.NUMBER);
   iDecimals.setDefault( 2 );
        iDecimals.setName("Round to X decimals");

    /***** Column Width is used here for the cx parameter *****/
   var fp = new FunctionParameter("inputColWidth", FunctionParameter.NUMBER);
   fp.setName("Column Width");
   fp.setDefault(80);

    /***** Row Thickness is used here for the cy parameter *****/
   var fp = new FunctionParameter("inputRowThickness", FunctionParameter.NUMBER);
   fp.setName("Row Thickness");
   fp.setDefault(-1.2);

   var fp = new FunctionParameter("inputFontSize", FunctionParameter.NUMBER);
   fp.setName("Font Size");
   fp.setLowerLimit(1);
   fp.setDefault(11);

    /*****
        With drawTextPixel, X Start = the number of pixels from the left of
            the window.
        With drawTextRelative or Absolute, X Start will be the bar index unless
            the RELATIVETO### text flags are used.  In which case the values
            will represent pixels.
    *****/
   var fp = new FunctionParameter("inputXstart", FunctionParameter.NUMBER);
   fp.setName("X Start");
   fp.setLowerLimit(1);
   fp.setDefault(5);

    /*****
        With drawTextPixel, Y Start = the number of pixels from the top of
            the window.
        With drawTextRelative or Absolute, Y Start will be relative to the
            price scale of the chart symbol unless the RELATIVETO### text
            flags are used.  In which case the values will represent pixels.
    *****/
   var fp = new FunctionParameter("inputYstart", FunctionParameter.NUMBER);
   fp.setName("Y Start");
   fp.setLowerLimit(1);
   fp.setDefault(20);   
   
       
    var fp4 = new FunctionParameter("roundlen", FunctionParameter.NUMBER);
        fp4.setName("roundlen");
        fp4.setLowerLimit(0);
        fp4.setDefault(2);
}

var bEdit = true;


function main(
           
            inputColWidth, inputRowThickness, inputFontSize,
            inputXstart, inputYstart,
             
            iDecimals, 


        iFontSize, iButtonX, iButtonY) {
           
           
   
  // initialize upon first loading formula
    if(getBarState() == BARSTATE_ALLBARS) {
        drawTextPixel( iButtonX , iButtonY, " TRO_SM_MIDDLE @URL=EFS:editParameters", Color.white,    Color.lime,
            Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON,
            "Comic Sans MS", 13, "UpExp");
        vDate = new Date();
        iInterval = getInterval();

        vSymbol = getSymbol().toUpperCase();
   
        xSymbol = 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;
    }
         
   
   
   
   
    //  prevents the formula from executing except at bar 0 and on new bar.
   if(getCurrentBarIndex() != 0 && getBarState() != BARSTATE_NEWBAR) return;

    // initialization routine to set values for global variables
    if (bEdit == true) {
        nColWidth = Math.round(inputColWidth);
        nRowThickness = Math.round(inputRowThickness);
        nFontSize = Math.round(inputFontSize);
       
        /***** Used for setting the space between x/y anchors for text
            labels based on the font height *****/
        if (nRowThickness < 0) {
            nFontCY = getTextHeight("A", null, nFontSize)*(nRowThickness);
        } else {
            nFontCY = -nRowThickness;
        }
       
        /***** This will get the maximum width for the specified string
            based on the specified font type.  If the font type is not
            specified it uses a default Arial. *****/
        if (nColWidth < 0) {
            nFontCX = getTextWidth("Row ## Col ##", null, nFontSize);
        } else {
            nFontCX = nColWidth;
        }
        bEdit = false;
    }

    var nX = inputXstart;
    var nY = inputYstart;

   
   
    //DISPLAY  COLUMN HEADINGS
   
        tStr= "Symbol"   ;
    drawTextPixel(nX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c0", nColWidth, nRowThickness);

        tStr= "PrevMid"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c1", nColWidth, nRowThickness);

        tStr= "+/-"  ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c2", nColWidth, nRowThickness);

        tStr= "HiMid"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c3", nColWidth, nRowThickness);


        tStr= "MidLo"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c4", nColWidth, nRowThickness);
       

       
   
    //Zeile2
   
    nX = inputXstart;
    nY -= nFontCY;

    if(xInit==false){

// INITIALIZE ROW 1
      

         xOpen   =  open(  ) ;
         
         xHigh   =  high(  ) ;

         xLow    =  low(  ) ;

         xClose  =  close(  ) ;

         xInit=true;

    } // xInit
     

 
 
           sStr     = xSymbol ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c0", nColWidth, nRowThickness);
       


// PROCESS ROW 1 COLUMN 1 
 

var zOpen    = xOpen.getValue(0) ;

var zClose   = xClose.getValue(0) ;
 
var zClose1  = xClose.getValue(-1) ;

var zHigh    = xHigh.getValue(0) ;

var zHigh1   = xHigh.getValue(-1) ;

var zLow     = xLow.getValue(0) ;

var zLow1    = xLow.getValue(-1) ;

var zMid1   = rnd( ((zHigh1 + zLow1) * .50) , 2 )   ;



         
           xFGColor = Color.magenta;
      xBGColor = Color.black;
         

           sStr     = "" + zMid1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c1", nColWidth, nRowThickness);


// PROCESS ROW 1 COLUMN 2 


  var   zDiff = rnd( (close(0) - zMid1) , 2 )   ;

        if( zDiff  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                  } 
        else
        if( zDiff < 0  ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
             }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
          }

           sStr     = "" + zDiff ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c2", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 3 


        xHiOp =  rnd( ( zHigh - zMid1 ) ,iDecimals) ;
     

        if( xHiOp  > 0 ) {
           xFGColor = Color.black;
           xBGColor = Color.lime;
                    } 
        else
        if( xHiOp  < 0 ) {
           xHiOp = 0 ;
           xFGColor = Color.white;
      xBGColor = Color.black;
               }
   
        sStr     = "" + xHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c3", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 4


 
        xOpLo =  rnd( ( zMid1 - zLow ) ,iDecimals) ;


        if( xOpLo  > 0 ) {
           xFGColor = Color.black;
      xBGColor = Color.red;
               }
       else { 
           xOpLo = 0 ;
           xFGColor = Color.white;
      xBGColor = Color.black;
           }

        sStr     = "" + xOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c4", nColWidth, nRowThickness);
       

/*
debugPrint( "zMid1    : " + formatPriceNumber( zMid1 ) + "\n" );

debugPrint( "xHiOp    : " + formatPriceNumber( xHiOp ) + "\n" );

debugPrint( "xOpLo    : " + formatPriceNumber( xOpLo ) + "\n" );
*/


    return; // MAIN
}


//==rnd will round to N digits.
function rnd(value, N) {
    var n;
    var mult=1;
    for(n=0;n<N;n++) mult*=10;
    value*=mult;
    return Math.round( value,N)/mult;
}

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





eSIGNAL - MULTI SLOT MACHINE - MILK THE COW

Posted: Sat Jul 29, 2006 8:57 pm
by TheRumpledOne
eSIGNAL - MULTI SLOT MACHINE - MILK THE COW

I figured out how to create a RADARSCREEN with different symbols in eSignal.

Don't look back TradeStation because we're going to blow right by you!




Code: Select all

/*****************************************************************

TRO_MTC_MULTI 20060728 MILK THE COW SLOT MACHINE INDICATOR

Programmer:  Avery T. Horton, Jr.  aka TheRumpledOne



Provided By : eSignal (c) Copyright 2004
Description:  Pixel Spacing Example

drawTextPixel(xBar, yValue, Text, [FGColor], [BGColor], [Flags],
        [FontName], [FontSize], [TagName], [cx], [cy])

This function is used to draw text on the chart at precise pixel
locations. It is used in conjunction with the getTextHeight() and
getTextWidth() functions.

xBar:  Relative position where text should appear.
yValue:  y-axis value where text should appear
Text:  The text that should be displayed
FGColor:  Optional. If not provided, pass null. Foreground color of the text.
BGColor:  Optional. if not provided, pass null. Background color of the text
Flags:  Text Flags (these can be ORd together). Pass null if not using flags.
FontName:  Optional. If not provided, pass null. Otherwise, pass a font name (e.g, "Courier" or "Arial").
FontSize:  Optional. If not provided, pass null. Otherwise, pass the font size to use (e.g., 11 or 15 or 8, etc.)
TagName:  A unique identifier for this text object.
cx:   Optional. Pixel spacing control.
cy:   Optional. Pixel spacing control.


Notes:

The cx and cy parameters control the
width (cx) and height (cy) of the text label.  They are also
available in the drawTextRelative and drawTextAbsolute functions,
but are not very useful unless you are using them in combination
with text flags, RELATIVETOTOP, RELATIVETOLEFT and RELATIVETOBOTTOM. 
Both cx and cy require whole numbers.

You can pass positive or negative numbers to these parameters.
If you use positive whole numbers then the size is based on that
number of pixels.
    cx of 15 will be the width of the text label of 15 pixels.
    cy of 15 will be the height of the text label of 15 pixels.
If you use negative whole numbers then the size is relative to the
specified font size.
    cx of -15 will be the approxomate width of 15 characters of the
        specified font.
    cy of -2 will be 2 times the height of the specified
        font.  -3 would be 3 times the height etc.


The formula example below draws a table containing
3 columns and 2 rows of text labels.


Verwendete Indikatoren:


*****************************************************************/

var nFontCY = 0;
var nFontCX = 0;
var nColWidth   = 0;
var nRowThickness = 1;
var nFontSize   = 10;
var sStr;
var tStr;
var diff1 =0;
var diff2 =0;
var midpoint1 =0;
var realtimepivot =0;

var xInit   = false;
var xMiddle = null;
var xGap    = null;
var xHiOp   = null;
var xOpLo   = null;

var xOpen   = null;
var xHigh   = null;
var xLow    = null;
var xClose  = null;


var xbOpen   = null;
var xbHigh   = null;
var xbLow    = null;
var xbClose  = null;

var xcOpen   = null;
var xcHigh   = null;
var xcLow    = null;
var xcClose  = null;

var xdOpen   = null;
var xdHigh   = null;
var xdLow    = null;
var xdClose  = null;


function preMain() {
    setStudyTitle("TRO_MTC_MULTI");
    setShowCursorLabel(false);
    setShowTitleParameters(false);
   



    var iSymbol1 = new FunctionParameter("iSymbol1", FunctionParameter.STRING);
   iSymbol1.addOption("AAPL");
        iSymbol1.addOption("GOOG");
        iSymbol1.addOption("SHLD");
        iSymbol1.addOption("RIMM");
   iSymbol1.setDefault( "AAPL" );
        iSymbol1.setName("Symbol 1");

    var iSymbol2 = new FunctionParameter("iSymbol2", FunctionParameter.STRING);
   iSymbol2.addOption("AAPL");
        iSymbol2.addOption("GOOG");
        iSymbol2.addOption("SHLD");
        iSymbol2.addOption("RIMM");
   iSymbol2.setDefault( "GOOG" );
        iSymbol2.setName("Symbol 2"); 

    var iSymbol3 = new FunctionParameter("iSymbol3", FunctionParameter.STRING);
   iSymbol3.addOption("AAPL");
        iSymbol3.addOption("GOOG");
        iSymbol3.addOption("SHLD");
        iSymbol3.addOption("RIMM");
   iSymbol3.setDefault( "SHLD" );
        iSymbol3.setName("Symbol 3");

    var iSymbol4 = new FunctionParameter("iSymbol4", FunctionParameter.STRING);
   iSymbol4.addOption("AAPL");
        iSymbol4.addOption("GOOG");
        iSymbol4.addOption("SHLD");
        iSymbol4.addOption("RIMM");
   iSymbol4.setDefault( "RIMM" );
        iSymbol4.setName("Symbol 4");

    var iButtonX = new FunctionParameter("iButtonX", FunctionParameter.NUMBER);
   iButtonX.setDefault( 1 );

    var iButtonY = new FunctionParameter("iButtonY", FunctionParameter.NUMBER);
   iButtonY.setDefault( 1 );


    var iFontSize = new FunctionParameter("iFontSize", FunctionParameter.NUMBER);
   iFontSize.setDefault( 10 );
 

    var iDecimals = new FunctionParameter("iDecimals", FunctionParameter.NUMBER);
   iDecimals.setDefault( 2 );
        iDecimals.setName("Round to X decimals");

    /***** Column Width is used here for the cx parameter *****/
   var fp = new FunctionParameter("inputColWidth", FunctionParameter.NUMBER);
   fp.setName("Column Width");
   fp.setDefault(80);

    /***** Row Thickness is used here for the cy parameter *****/
   var fp = new FunctionParameter("inputRowThickness", FunctionParameter.NUMBER);
   fp.setName("Row Thickness");
   fp.setDefault(-1.2);

   var fp = new FunctionParameter("inputFontSize", FunctionParameter.NUMBER);
   fp.setName("Font Size");
   fp.setLowerLimit(1);
   fp.setDefault(11);

    /*****
        With drawTextPixel, X Start = the number of pixels from the left of
            the window.
        With drawTextRelative or Absolute, X Start will be the bar index unless
            the RELATIVETO### text flags are used.  In which case the values
            will represent pixels.
    *****/
   var fp = new FunctionParameter("inputXstart", FunctionParameter.NUMBER);
   fp.setName("X Start");
   fp.setLowerLimit(1);
   fp.setDefault(5);

    /*****
        With drawTextPixel, Y Start = the number of pixels from the top of
            the window.
        With drawTextRelative or Absolute, Y Start will be relative to the
            price scale of the chart symbol unless the RELATIVETO### text
            flags are used.  In which case the values will represent pixels.
    *****/
   var fp = new FunctionParameter("inputYstart", FunctionParameter.NUMBER);
   fp.setName("Y Start");
   fp.setLowerLimit(1);
   fp.setDefault(20);   
   
       
    var fp4 = new FunctionParameter("roundlen", FunctionParameter.NUMBER);
        fp4.setName("roundlen");
        fp4.setLowerLimit(0);
        fp4.setDefault(2);
}

var bEdit = true;


function main(  iSymbol1, iSymbol2, iSymbol3, iSymbol4,
           
            inputColWidth, inputRowThickness, inputFontSize,
            inputXstart, inputYstart,
             
            iDecimals, 


        iFontSize, iButtonX, iButtonY) {
           
           
   
  // initialize upon first loading formula
    if(getBarState() == BARSTATE_ALLBARS) {
        drawTextPixel( iButtonX , iButtonY, " TRO_MTC_MULTI @URL=EFS:editParameters", Color.white,    Color.lime,
            Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON,
            "Comic Sans MS", 13, "UpExp");
        vDate = new Date();
        iInterval = 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;
    }
         
   
   
   
   
    //  prevents the formula from executing except at bar 0 and on new bar.
   if(getCurrentBarIndex() != 0 && getBarState() != BARSTATE_NEWBAR) return;

    // initialization routine to set values for global variables
    if (bEdit == true) {
        nColWidth = Math.round(inputColWidth);
        nRowThickness = Math.round(inputRowThickness);
        nFontSize = Math.round(inputFontSize);
       
        /***** Used for setting the space between x/y anchors for text
            labels based on the font height *****/
        if (nRowThickness < 0) {
            nFontCY = getTextHeight("A", null, nFontSize)*(nRowThickness);
        } else {
            nFontCY = -nRowThickness;
        }
       
        /***** This will get the maximum width for the specified string
            based on the specified font type.  If the font type is not
            specified it uses a default Arial. *****/
        if (nColWidth < 0) {
            nFontCX = getTextWidth("Row ## Col ##", null, nFontSize);
        } else {
            nFontCX = nColWidth;
        }
        bEdit = false;
    }

    var nX = inputXstart;
    var nY = inputYstart;

   
   
    //DISPLAY  COLUMN HEADINGS
   
        tStr= "Symbol"   ;
    drawTextPixel(nX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c0", nColWidth, nRowThickness);

        tStr= "Middle"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c1", nColWidth, nRowThickness);

        tStr= "Gap"  ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c2", nColWidth, nRowThickness);

        tStr= "HiOp"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c3", nColWidth, nRowThickness);


        tStr= "OpLo"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c4", nColWidth, nRowThickness);
       

       
   
    //Zeile2
   
    nX = inputXstart;
    nY -= nFontCY;

    if(xInit==false){

// INITIALIZE ROW 1

         xOpen   =  open(sym( iSymbol1 ,inv("D") ) ) ;
         xHigh   =  high(sym( iSymbol1 ,inv("D") ) ) ;
         xLow    =  low(sym( iSymbol1 ,inv("D") ) ) ;
         xClose  =  close(sym( iSymbol1 ,inv("D") ) ) ;

// INITIALIZE ROW 2

         xbOpen   =  open(sym( iSymbol2 ,inv("D") ) ) ;
         xbHigh   =  high(sym( iSymbol2 ,inv("D") ) ) ;
         xbLow    =  low(sym( iSymbol2 ,inv("D") ) ) ;
         xbClose  =  close(sym( iSymbol2 ,inv("D") ) ) ;

// INITIALIZE ROW 3

         xcOpen   =  open(sym( iSymbol3 ,inv("D") ) ) ;
         xcHigh   =  high(sym( iSymbol3 ,inv("D") ) ) ;
         xcLow    =  low(sym( iSymbol3 ,inv("D") ) ) ;
         xcClose  =  close(sym( iSymbol3 ,inv("D") ) ) ;


// INITIALIZE ROW 4

         xdOpen   =  open(sym( iSymbol4 ,inv("D") ) ) ;
         xdHigh   =  high(sym( iSymbol4 ,inv("D") ) ) ;
         xdLow    =  low(sym( iSymbol4 ,inv("D") ) ) ;
         xdClose  =  close(sym( iSymbol4 ,inv("D") ) ) ;




         xInit=true;

    } // xInit
     

 
       


// PROCESS ROW 1 COLUMN 1 
 

           sStr     = iSymbol1.toUpperCase() ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c0", nColWidth, nRowThickness);


var zOpen    = xOpen.getValue(0) ;

var zClose   = xClose.getValue(0) ;
 
var zClose1  = xClose.getValue(-1) ;

var zHigh    = xHigh.getValue(0) ;

var zHigh1   = xHigh.getValue(-1) ;

var zLow     = xLow.getValue(0) ;

var zLow1    = xLow.getValue(-1) ;

var zMid1   = rnd( ((zHigh1 + zLow1) * .50) , 2 )   ;

var zGap    = rnd( (zOpen - zClose1) , 2) ;

        xDiff1 =  rnd( (close(0, sym(iSymbol1) ) - zMid1) ,iDecimals ) ;

        if( xDiff1  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
             ;        } 
        else
        if( xDiff1 < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           
           }

           sStr     = "" + xDiff1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c1", nColWidth, nRowThickness);


// PROCESS ROW 1 COLUMN 2 


        if( zGap  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                  } 
        else
        if( zGap  < 0  ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
             }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
          }

           sStr     = "" + zGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c2", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 3 


        xHiOp =  rnd( ( zHigh - zOpen ) ,iDecimals) ;

        if( xHiOp  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                    } 
        else
        if( xHiOp  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
            }
        sStr     = "" + xHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c3", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 4


 
        xOpLo =  rnd( ( zOpen - zLow ) ,iDecimals) ;


        if( xOpLo  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                   } 
        else
        if( xOpLo  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           }

        sStr     = "" + xOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c4", nColWidth, nRowThickness);
       

/*
debugPrint( "zMid1    : " + formatPriceNumber( zMid1 ) + "\n" );

debugPrint( "zGap    : " + formatPriceNumber( zGap ) + "\n" );

debugPrint( "xHiOp    : " + formatPriceNumber( xHiOp ) + "\n" );

debugPrint( "xOpLo    : " + formatPriceNumber( xOpLo ) + "\n" );
*/






// PROCESS ROW 2 COLUMN 1 
 
nX = inputXstart;
nY -= nFontCY; ;

           sStr     = iSymbol2.toUpperCase() ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col0", nColWidth, nRowThickness);


var zbOpen    = xbOpen.getValue(0) ;

var zbClose   = xbClose.getValue(0) ;
 
var zbClose1  = xbClose.getValue(-1) ;

var zbHigh    = xbHigh.getValue(0) ;

var zbHigh1   = xbHigh.getValue(-1) ;

var zbLow     = xbLow.getValue(0) ;

var zbLow1    = xbLow.getValue(-1) ;

var zbMid1   = rnd( (( zbHigh1 + zbLow1) * .50) , 2 )   ;

var zbGap    = rnd( ( zbOpen - zbClose1) , 2) ;

        xbDiff1 =  rnd( (close(0, sym(iSymbol2) ) - zbMid1) ,iDecimals ) ;

        if( xbDiff1  > 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.lime;
             ;        } 
        else
        if( xbDiff1 < 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.red;
               }
       else {   
           xbFGColor = Color.black;
          xbBGColor = Color.yellow;
           
           }

           sStr     = "" + xbDiff1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xbFGColor, xbBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col1", nColWidth, nRowThickness);


// PROCESS ROW 2 COLUMN 2 


        if( zbGap  > 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.lime;
                  } 
        else
        if( zbGap  < 0  ) {
           xbFGColor = Color.black;
          xbBGColor = Color.red;
             }
       else {   
           xbFGColor = Color.black;
          xbBGColor = Color.yellow;
          }

           sStr     = "" + zbGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xbFGColor, xbBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col2", nColWidth, nRowThickness);
       

// PROCESS ROW 2 COLUMN 3 


        xbHiOp =  rnd( ( zbHigh - zbOpen ) ,iDecimals) ;

        if( xbHiOp  > 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.lime;
                    } 
        else
        if( xbHiOp  < 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.red;
               }
       else {   
           xbFGColor = Color.black;
          xbBGColor = Color.yellow;
            }
        sStr     = "" + xbHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xbFGColor, xbBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 2 COLUMN 4


 
        xbOpLo =  rnd( ( zbOpen - zbLow ) ,iDecimals) ;


        if( xbOpLo  > 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.lime;
                   } 
        else
        if( xbOpLo  < 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.red;
               }
       else {   
           xbFGColor = Color.black;
          xbBGColor = Color.yellow;
           }

        sStr     = "" + xbOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xbFGColor, xbBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col4", nColWidth, nRowThickness);
       



// PROCESS ROW 3 COLUMN 1 
 
nX = inputXstart;
nY -= nFontCY; ;

           sStr     = iSymbol3.toUpperCase() ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col0", nColWidth, nRowThickness);


var zcOpen    = xcOpen.getValue(0) ;

var zcClose   = xcClose.getValue(0) ;
 
var zcClose1  = xcClose.getValue(-1) ;

var zcHigh    = xcHigh.getValue(0) ;

var zcHigh1   = xcHigh.getValue(-1) ;

var zcLow     = xcLow.getValue(0) ;

var zcLow1    = xcLow.getValue(-1) ;

var zcMid1   = rnd( (( zcHigh1 + zcLow1) * .50) , 2 )   ;

var zcGap    = rnd( ( zcOpen - zcClose1) , 2) ;

        xcDiff1 =  rnd( (close(0, sym(iSymbol3) ) - zcMid1) ,iDecimals ) ;

        if( xcDiff1  > 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.lime;
             ;        } 
        else
        if( xcDiff1 < 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.red;
               }
       else {   
           xcFGColor = Color.black;
          xcBGColor = Color.yellow;
           
           }

           sStr     = "" + xcDiff1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xcFGColor, xcBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col1", nColWidth, nRowThickness);


// PROCESS ROW 3 COLUMN 2 


        if( zcGap  > 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.lime;
                  } 
        else
        if( zcGap  < 0  ) {
           xcFGColor = Color.black;
          xcBGColor = Color.red;
             }
       else {   
           xcFGColor = Color.black;
          xcBGColor = Color.yellow;
          }

           sStr     = "" + zcGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xcFGColor, xcBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col2", nColWidth, nRowThickness);
       

// PROCESS ROW 3 COLUMN 3 


        xcHiOp =  rnd( ( zcHigh - zcOpen ) ,iDecimals) ;

        if( xcHiOp  > 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.lime;
                    } 
        else
        if( xcHiOp  < 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.red;
               }
       else {   
           xcFGColor = Color.black;
          xcBGColor = Color.yellow;
            }
        sStr     = "" + xcHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xcFGColor, xcBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col3", nColWidth, nRowThickness);


// PROCESS ROW 3 COLUMN 4


 
        xcOpLo =  rnd( ( zcOpen - zcLow ) ,iDecimals) ;


        if( xcOpLo  > 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.lime;
                   } 
        else
        if( xcOpLo  < 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.red;
               }
       else {   
           xcFGColor = Color.black;
          xcBGColor = Color.yellow;
           }

        sStr     = "" + xcOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xcFGColor, xcBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col4", nColWidth, nRowThickness);
       

// PROCESS ROW 4 COLUMN 1 
 
nX = inputXstart;
nY -= nFontCY; ;

           sStr     = iSymbol4.toUpperCase() ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col0", nColWidth, nRowThickness);


var zdOpen    = xdOpen.getValue(0) ;

var zdClose   = xdClose.getValue(0) ;
 
var zdClose1  = xdClose.getValue(-1) ;

var zdHigh    = xdHigh.getValue(0) ;

var zdHigh1   = xdHigh.getValue(-1) ;

var zdLow     = xdLow.getValue(0) ;

var zdLow1    = xdLow.getValue(-1) ;

var zdMid1   = rnd( (( zdHigh1 + zdLow1) * .50) , 2 )   ;

var zdGap    = rnd( ( zdOpen - zdClose1) , 2) ;

        xdDiff1 =  rnd( (close(0, sym(iSymbol4) ) - zdMid1) ,iDecimals ) ;

        if( xdDiff1  > 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.lime;
             ;        } 
        else
        if( xdDiff1 < 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.red;
               }
       else {   
           xdFGColor = Color.black;
          xdBGColor = Color.yellow;
           
           }

           sStr     = "" + xdDiff1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xdFGColor, xdBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col1", nColWidth, nRowThickness);


// PROCESS ROW 4 COLUMN 2 


        if( zdGap  > 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.lime;
                  } 
        else
        if( zdGap  < 0  ) {
           xdFGColor = Color.black;
          xdBGColor = Color.red;
             }
       else {   
           xdFGColor = Color.black;
          xdBGColor = Color.yellow;
          }

           sStr     = "" + zdGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xdFGColor, xdBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col2", nColWidth, nRowThickness);
       

// PROCESS ROW 4 COLUMN 3 


        xdHiOp =  rnd( ( zdHigh - zdOpen ) ,iDecimals) ;

        if( xdHiOp  > 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.lime;
                    } 
        else
        if( xdHiOp  < 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.red;
               }
       else {   
           xdFGColor = Color.black;
          xdBGColor = Color.yellow;
            }
        sStr     = "" + xdHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xdFGColor, xdBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 4 COLUMN 4


 
        xdOpLo =  rnd( ( zdOpen - zdLow ) ,iDecimals) ;


        if( xdOpLo  > 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.lime;
                   } 
        else
        if( xdOpLo  < 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.red;
               }
       else {   
           xdFGColor = Color.black;
          xdBGColor = Color.yellow;
           }

        sStr     = "" + xdOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xdFGColor, xdBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col4", nColWidth, nRowThickness);
       



    return; // MAIN
}


//==rnd will round to N digits.
function rnd(value, N) {
    var n;
    var mult=1;
    for(n=0;n<N;n++) mult*=10;
    value*=mult;
    return Math.round( value,N)/mult;
}

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

ENHANCEMENT

Posted: Sat Jul 29, 2006 9:37 pm
by TheRumpledOne
I enhanced the TRO MTC MULTI eSignal study to dispaly Close - Open and added inputs iTrade1 and iTrade2 so you could define the TRADE ZONES.

If the price enters the trade zone then the background turns white.




Code: Select all

/*****************************************************************

TRO_MTC_MULTI 20060728 MILK THE COW SLOT MACHINE INDICATOR

Programmer:  Avery T. Horton, Jr.  aka TheRumpledOne



Provided By : eSignal (c) Copyright 2004
Description:  Pixel Spacing Example

drawTextPixel(xBar, yValue, Text, [FGColor], [BGColor], [Flags],
        [FontName], [FontSize], [TagName], [cx], [cy])

This function is used to draw text on the chart at precise pixel
locations. It is used in conjunction with the getTextHeight() and
getTextWidth() functions.

xBar:  Relative position where text should appear.
yValue:  y-axis value where text should appear
Text:  The text that should be displayed
FGColor:  Optional. If not provided, pass null. Foreground color of the text.
BGColor:  Optional. if not provided, pass null. Background color of the text
Flags:  Text Flags (these can be ORd together). Pass null if not using flags.
FontName:  Optional. If not provided, pass null. Otherwise, pass a font name (e.g, "Courier" or "Arial").
FontSize:  Optional. If not provided, pass null. Otherwise, pass the font size to use (e.g., 11 or 15 or 8, etc.)
TagName:  A unique identifier for this text object.
cx:   Optional. Pixel spacing control.
cy:   Optional. Pixel spacing control.


Notes:

The cx and cy parameters control the
width (cx) and height (cy) of the text label.  They are also
available in the drawTextRelative and drawTextAbsolute functions,
but are not very useful unless you are using them in combination
with text flags, RELATIVETOTOP, RELATIVETOLEFT and RELATIVETOBOTTOM. 
Both cx and cy require whole numbers.

You can pass positive or negative numbers to these parameters.
If you use positive whole numbers then the size is based on that
number of pixels.
    cx of 15 will be the width of the text label of 15 pixels.
    cy of 15 will be the height of the text label of 15 pixels.
If you use negative whole numbers then the size is relative to the
specified font size.
    cx of -15 will be the approxomate width of 15 characters of the
        specified font.
    cy of -2 will be 2 times the height of the specified
        font.  -3 would be 3 times the height etc.


The formula example below draws a table containing
3 columns and 2 rows of text labels.


Verwendete Indikatoren:


*****************************************************************/

var nFontCY = 0;
var nFontCX = 0;
var nColWidth   = 0;
var nRowThickness = 1;
var nFontSize   = 10;
var sStr;
var tStr;
var diff1 =0;
var diff2 =0;
var midpoint1 =0;
var realtimepivot =0;

var xInit   = false;
var xMiddle = null;
var xGap    = null;
var xHiOp   = null;
var xOpLo   = null;

var xOpen   = null;
var xHigh   = null;
var xLow    = null;
var xClose  = null;


var xbOpen   = null;
var xbHigh   = null;
var xbLow    = null;
var xbClose  = null;

var xcOpen   = null;
var xcHigh   = null;
var xcLow    = null;
var xcClose  = null;

var xdOpen   = null;
var xdHigh   = null;
var xdLow    = null;
var xdClose  = null;


function preMain() {
    setStudyTitle("TRO_MTC_MULTI");
    setShowCursorLabel(false);
    setShowTitleParameters(false);
   



    var iSymbol1 = new FunctionParameter("iSymbol1", FunctionParameter.STRING);
   iSymbol1.addOption("AAPL");
        iSymbol1.addOption("GOOG");
        iSymbol1.addOption("SHLD");
        iSymbol1.addOption("RIMM");
   iSymbol1.setDefault( "AAPL" );
        iSymbol1.setName("Symbol 1");

    var iSymbol2 = new FunctionParameter("iSymbol2", FunctionParameter.STRING);
   iSymbol2.addOption("AAPL");
        iSymbol2.addOption("GOOG");
        iSymbol2.addOption("SHLD");
        iSymbol2.addOption("RIMM");
   iSymbol2.setDefault( "GOOG" );
        iSymbol2.setName("Symbol 2"); 

    var iSymbol3 = new FunctionParameter("iSymbol3", FunctionParameter.STRING);
   iSymbol3.addOption("AAPL");
        iSymbol3.addOption("GOOG");
        iSymbol3.addOption("SHLD");
        iSymbol3.addOption("RIMM");
   iSymbol3.setDefault( "SHLD" );
        iSymbol3.setName("Symbol 3");

    var iSymbol4 = new FunctionParameter("iSymbol4", FunctionParameter.STRING);
   iSymbol4.addOption("AAPL");
        iSymbol4.addOption("GOOG");
        iSymbol4.addOption("SHLD");
        iSymbol4.addOption("RIMM");
   iSymbol4.setDefault( "RIMM" );
        iSymbol4.setName("Symbol 4");



    var iTrade1 = new FunctionParameter("iTrade1 ", FunctionParameter.NUMBER);
   iTrade1 .setDefault( .10 );

    var iTrade2 = new FunctionParameter("iTrade2 ", FunctionParameter.NUMBER);
   iTrade2 .setDefault( .20 );

    var iButtonX = new FunctionParameter("iButtonX", FunctionParameter.NUMBER);
   iButtonX.setDefault( 1 );

    var iButtonY = new FunctionParameter("iButtonY", FunctionParameter.NUMBER);
   iButtonY.setDefault( 1 );


    var iFontSize = new FunctionParameter("iFontSize", FunctionParameter.NUMBER);
   iFontSize.setDefault( 10 );
 

    var iDecimals = new FunctionParameter("iDecimals", FunctionParameter.NUMBER);
   iDecimals.setDefault( 2 );
        iDecimals.setName("Round to X decimals");

    /***** Column Width is used here for the cx parameter *****/
   var fp = new FunctionParameter("inputColWidth", FunctionParameter.NUMBER);
   fp.setName("Column Width");
   fp.setDefault(80);

    /***** Row Thickness is used here for the cy parameter *****/
   var fp = new FunctionParameter("inputRowThickness", FunctionParameter.NUMBER);
   fp.setName("Row Thickness");
   fp.setDefault(-1.2);

   var fp = new FunctionParameter("inputFontSize", FunctionParameter.NUMBER);
   fp.setName("Font Size");
   fp.setLowerLimit(1);
   fp.setDefault(11);

    /*****
        With drawTextPixel, X Start = the number of pixels from the left of
            the window.
        With drawTextRelative or Absolute, X Start will be the bar index unless
            the RELATIVETO### text flags are used.  In which case the values
            will represent pixels.
    *****/
   var fp = new FunctionParameter("inputXstart", FunctionParameter.NUMBER);
   fp.setName("X Start");
   fp.setLowerLimit(1);
   fp.setDefault(5);

    /*****
        With drawTextPixel, Y Start = the number of pixels from the top of
            the window.
        With drawTextRelative or Absolute, Y Start will be relative to the
            price scale of the chart symbol unless the RELATIVETO### text
            flags are used.  In which case the values will represent pixels.
    *****/
   var fp = new FunctionParameter("inputYstart", FunctionParameter.NUMBER);
   fp.setName("Y Start");
   fp.setLowerLimit(1);
   fp.setDefault(20);   
   
       
    var fp4 = new FunctionParameter("roundlen", FunctionParameter.NUMBER);
        fp4.setName("roundlen");
        fp4.setLowerLimit(0);
        fp4.setDefault(2);
}

var bEdit = true;


function main(  iSymbol1, iSymbol2, iSymbol3, iSymbol4, iTrade1, iTrade2,
           
            inputColWidth, inputRowThickness, inputFontSize,
            inputXstart, inputYstart,
             
            iDecimals, 


        iFontSize, iButtonX, iButtonY) {
           
           
   
  // initialize upon first loading formula
    if(getBarState() == BARSTATE_ALLBARS) {
        drawTextPixel( iButtonX , iButtonY, " TRO_MTC_MULTI @URL=EFS:editParameters", Color.white,    Color.lime,
            Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON,
            "Comic Sans MS", 13, "UpExp");
        vDate = new Date();
        iInterval = 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;
    }
         
   
   
   
   
    //  prevents the formula from executing except at bar 0 and on new bar.
   if(getCurrentBarIndex() != 0 && getBarState() != BARSTATE_NEWBAR) return;

    // initialization routine to set values for global variables
    if (bEdit == true) {
        nColWidth = Math.round(inputColWidth);
        nRowThickness = Math.round(inputRowThickness);
        nFontSize = Math.round(inputFontSize);
       
        /***** Used for setting the space between x/y anchors for text
            labels based on the font height *****/
        if (nRowThickness < 0) {
            nFontCY = getTextHeight("A", null, nFontSize)*(nRowThickness);
        } else {
            nFontCY = -nRowThickness;
        }
       
        /***** This will get the maximum width for the specified string
            based on the specified font type.  If the font type is not
            specified it uses a default Arial. *****/
        if (nColWidth < 0) {
            nFontCX = getTextWidth("Row ## Col ##", null, nFontSize);
        } else {
            nFontCX = nColWidth;
        }
        bEdit = false;
    }

    var nX = inputXstart;
    var nY = inputYstart;

   
   
    //DISPLAY  COLUMN HEADINGS
   
        tStr= "Symbol"   ;
    drawTextPixel(nX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c0", nColWidth, nRowThickness);

        tStr= "Middle"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c1", nColWidth, nRowThickness);

        tStr= "Gap"  ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c2", nColWidth, nRowThickness);

        tStr= "HiOp"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c3", nColWidth, nRowThickness);


        tStr= "OpLo"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c4", nColWidth, nRowThickness);
       


        tStr= "ClOp"   ;
    drawTextPixel(nX+=nFontCX, nY, tStr, Color.blue, Color.lightgrey,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r4c5", nColWidth, nRowThickness);
       
       
   
    //Zeile2
   
    nX = inputXstart;
    nY -= nFontCY;

    if(xInit==false){

// INITIALIZE ROW 1

         xOpen   =  open(sym( iSymbol1 ,inv("D") ) ) ;
         xHigh   =  high(sym( iSymbol1 ,inv("D") ) ) ;
         xLow    =  low(sym( iSymbol1 ,inv("D") ) ) ;
         xClose  =  close(sym( iSymbol1 ,inv("D") ) ) ;

// INITIALIZE ROW 2

         xbOpen   =  open(sym( iSymbol2 ,inv("D") ) ) ;
         xbHigh   =  high(sym( iSymbol2 ,inv("D") ) ) ;
         xbLow    =  low(sym( iSymbol2 ,inv("D") ) ) ;
         xbClose  =  close(sym( iSymbol2 ,inv("D") ) ) ;

// INITIALIZE ROW 3

         xcOpen   =  open(sym( iSymbol3 ,inv("D") ) ) ;
         xcHigh   =  high(sym( iSymbol3 ,inv("D") ) ) ;
         xcLow    =  low(sym( iSymbol3 ,inv("D") ) ) ;
         xcClose  =  close(sym( iSymbol3 ,inv("D") ) ) ;


// INITIALIZE ROW 4

         xdOpen   =  open(sym( iSymbol4 ,inv("D") ) ) ;
         xdHigh   =  high(sym( iSymbol4 ,inv("D") ) ) ;
         xdLow    =  low(sym( iSymbol4 ,inv("D") ) ) ;
         xdClose  =  close(sym( iSymbol4 ,inv("D") ) ) ;




         xInit=true;

    } // xInit
     

 
       


// PROCESS ROW 1 COLUMN 1 
 

           sStr     = iSymbol1.toUpperCase() ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c0", nColWidth, nRowThickness);


var zOpen    = xOpen.getValue(0) ;

var zClose   = xClose.getValue(0) ;
 
var zClose1  = xClose.getValue(-1) ;

var zHigh    = xHigh.getValue(0) ;

var zHigh1   = xHigh.getValue(-1) ;

var zLow     = xLow.getValue(0) ;

var zLow1    = xLow.getValue(-1) ;

var zMid1   = rnd( ((zHigh1 + zLow1) * .50) , 2 )   ;

var zGap    = rnd( (zOpen - zClose1) , 2) ;

        xDiff1 =  rnd( (close(0, sym(iSymbol1) ) - zMid1) ,iDecimals ) ;

        if( xDiff1  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
             ;        } 
        else
        if( xDiff1 < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           
           }

           sStr     = "" + xDiff1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c1", nColWidth, nRowThickness);


// PROCESS ROW 1 COLUMN 2 


        if( zGap  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                  } 
        else
        if( zGap  < 0  ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
             }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
          }

           sStr     = "" + zGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c2", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 3 


        xHiOp =  rnd( ( zHigh - zOpen ) ,iDecimals) ;

        if( xHiOp  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                    } 
        else
        if( xHiOp  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
            }
        sStr     = "" + xHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c3", nColWidth, nRowThickness);
       

// PROCESS ROW 1 COLUMN 4


 
        xOpLo =  rnd( ( zOpen - zLow ) ,iDecimals) ;


        if( xOpLo  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                   } 
        else
        if( xOpLo  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           }

        sStr     = "" + xOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c4", nColWidth, nRowThickness);
       



// PROCESS ROW 1 COLUMN 5


 
        xClOp =  rnd( ( zClose - zOpen ) ,iDecimals) ;
        mClOp =  Math.abs(xClOp);

        if( mClOp  >= iTrade1 && mClOp  <= iTrade2 ) {
           xFGColor = Color.green;
          xBGColor = Color.white;
                   } 
        else

        if( xClOp  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                   } 
        else
        if( xClOp  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           }

        sStr     = "" + xClOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "r3c5", nColWidth, nRowThickness);
       





// PROCESS ROW 2 COLUMN 1 
 
nX = inputXstart;
nY -= nFontCY; ;

           sStr     = iSymbol2.toUpperCase() ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col0", nColWidth, nRowThickness);


var zbOpen    = xbOpen.getValue(0) ;

var zbClose   = xbClose.getValue(0) ;
 
var zbClose1  = xbClose.getValue(-1) ;

var zbHigh    = xbHigh.getValue(0) ;

var zbHigh1   = xbHigh.getValue(-1) ;

var zbLow     = xbLow.getValue(0) ;

var zbLow1    = xbLow.getValue(-1) ;

var zbMid1   = rnd( (( zbHigh1 + zbLow1) * .50) , 2 )   ;

var zbGap    = rnd( ( zbOpen - zbClose1) , 2) ;

        xbDiff1 =  rnd( (close(0, sym(iSymbol2) ) - zbMid1) ,iDecimals ) ;

        if( xbDiff1  > 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.lime;
             ;        } 
        else
        if( xbDiff1 < 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.red;
               }
       else {   
           xbFGColor = Color.black;
          xbBGColor = Color.yellow;
           
           }

           sStr     = "" + xbDiff1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xbFGColor, xbBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col1", nColWidth, nRowThickness);


// PROCESS ROW 2 COLUMN 2 


        if( zbGap  > 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.lime;
                  } 
        else
        if( zbGap  < 0  ) {
           xbFGColor = Color.black;
          xbBGColor = Color.red;
             }
       else {   
           xbFGColor = Color.black;
          xbBGColor = Color.yellow;
          }

           sStr     = "" + zbGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xbFGColor, xbBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col2", nColWidth, nRowThickness);
       

// PROCESS ROW 2 COLUMN 3 


        xbHiOp =  rnd( ( zbHigh - zbOpen ) ,iDecimals) ;

        if( xbHiOp  > 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.lime;
                    } 
        else
        if( xbHiOp  < 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.red;
               }
       else {   
           xbFGColor = Color.black;
          xbBGColor = Color.yellow;
            }
        sStr     = "" + xbHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xbFGColor, xbBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 2 COLUMN 4


 
        xbOpLo =  rnd( ( zbOpen - zbLow ) ,iDecimals) ;


        if( xbOpLo  > 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.lime;
                   } 
        else
        if( xbOpLo  < 0 ) {
           xbFGColor = Color.black;
          xbBGColor = Color.red;
               }
       else {   
           xbFGColor = Color.black;
          xbBGColor = Color.yellow;
           }

        sStr     = "" + xbOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xbFGColor, xbBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col4", nColWidth, nRowThickness);
       



// PROCESS ROW 2 COLUMN 5


 
        xbClOp =  rnd( ( zbClose - zbOpen ) ,iDecimals) ;

        mClOp =  Math.abs(xbClOp);

        if( mClOp  >= iTrade1 && mClOp  <= iTrade2 ) {
           xFGColor = Color.green;
          xBGColor = Color.white;
                   } 
        else
        if( xbClOp  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                   } 
        else
        if( xbClOp  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           }

        sStr     = "" + xbClOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row2Col5", nColWidth, nRowThickness);
       

// PROCESS ROW 3 COLUMN 1 
 
nX = inputXstart;
nY -= nFontCY; ;

           sStr     = iSymbol3.toUpperCase() ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col0", nColWidth, nRowThickness);


var zcOpen    = xcOpen.getValue(0) ;

var zcClose   = xcClose.getValue(0) ;
 
var zcClose1  = xcClose.getValue(-1) ;

var zcHigh    = xcHigh.getValue(0) ;

var zcHigh1   = xcHigh.getValue(-1) ;

var zcLow     = xcLow.getValue(0) ;

var zcLow1    = xcLow.getValue(-1) ;

var zcMid1   = rnd( (( zcHigh1 + zcLow1) * .50) , 2 )   ;

var zcGap    = rnd( ( zcOpen - zcClose1) , 2) ;

        xcDiff1 =  rnd( (close(0, sym(iSymbol3) ) - zcMid1) ,iDecimals ) ;

        if( xcDiff1  > 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.lime;
             ;        } 
        else
        if( xcDiff1 < 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.red;
               }
       else {   
           xcFGColor = Color.black;
          xcBGColor = Color.yellow;
           
           }

           sStr     = "" + xcDiff1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xcFGColor, xcBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col1", nColWidth, nRowThickness);


// PROCESS ROW 3 COLUMN 2 


        if( zcGap  > 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.lime;
                  } 
        else
        if( zcGap  < 0  ) {
           xcFGColor = Color.black;
          xcBGColor = Color.red;
             }
       else {   
           xcFGColor = Color.black;
          xcBGColor = Color.yellow;
          }

           sStr     = "" + zcGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xcFGColor, xcBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col2", nColWidth, nRowThickness);
       

// PROCESS ROW 3 COLUMN 3 


        xcHiOp =  rnd( ( zcHigh - zcOpen ) ,iDecimals) ;

        if( xcHiOp  > 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.lime;
                    } 
        else
        if( xcHiOp  < 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.red;
               }
       else {   
           xcFGColor = Color.black;
          xcBGColor = Color.yellow;
            }
        sStr     = "" + xcHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xcFGColor, xcBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col3", nColWidth, nRowThickness);


// PROCESS ROW 3 COLUMN 4


 
        xcOpLo =  rnd( ( zcOpen - zcLow ) ,iDecimals) ;


        if( xcOpLo  > 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.lime;
                   } 
        else
        if( xcOpLo  < 0 ) {
           xcFGColor = Color.black;
          xcBGColor = Color.red;
               }
       else {   
           xcFGColor = Color.black;
          xcBGColor = Color.yellow;
           }

        sStr     = "" + xcOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xcFGColor, xcBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col4", nColWidth, nRowThickness);
       


// PROCESS ROW 3 COLUMN 5


 
        xcClOp =  rnd( ( zcClose - zcOpen ) ,iDecimals) ;

        mClOp =  Math.abs(xcClOp);

        if( mClOp  >= iTrade1 && mClOp  <= iTrade2 ) {
           xFGColor = Color.green;
          xcGColor = Color.white;
                   } 
        else
        if( xcClOp  > 0 ) {
           xFGColor = Color.black;
          xcGColor = Color.lime;
                   } 
        else
        if( xcClOp  < 0 ) {
           xFGColor = Color.black;
          xcGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xcGColor = Color.yellow;
           }

        sStr     = "" + xcClOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xcGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row3Col5", nColWidth, nRowThickness);
       


// PROCESS ROW 4 COLUMN 1 
 
nX = inputXstart;
nY -= nFontCY; ;

           sStr     = iSymbol4.toUpperCase() ;
        drawTextPixel(nX, nY, sStr, Color.white, Color.black,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col0", nColWidth, nRowThickness);


var zdOpen    = xdOpen.getValue(0) ;

var zdClose   = xdClose.getValue(0) ;
 
var zdClose1  = xdClose.getValue(-1) ;

var zdHigh    = xdHigh.getValue(0) ;

var zdHigh1   = xdHigh.getValue(-1) ;

var zdLow     = xdLow.getValue(0) ;

var zdLow1    = xdLow.getValue(-1) ;

var zdMid1   = rnd( (( zdHigh1 + zdLow1) * .50) , 2 )   ;

var zdGap    = rnd( ( zdOpen - zdClose1) , 2) ;

        xdDiff1 =  rnd( (close(0, sym(iSymbol4) ) - zdMid1) ,iDecimals ) ;

        if( xdDiff1  > 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.lime;
             ;        } 
        else
        if( xdDiff1 < 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.red;
               }
       else {   
           xdFGColor = Color.black;
          xdBGColor = Color.yellow;
           
           }

           sStr     = "" + xdDiff1 ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xdFGColor, xdBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col1", nColWidth, nRowThickness);


// PROCESS ROW 4 COLUMN 2 


        if( zdGap  > 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.lime;
                  } 
        else
        if( zdGap  < 0  ) {
           xdFGColor = Color.black;
          xdBGColor = Color.red;
             }
       else {   
           xdFGColor = Color.black;
          xdBGColor = Color.yellow;
          }

           sStr     = "" + zdGap ;

        drawTextPixel(nX+=nFontCX, nY, sStr, xdFGColor, xdBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col2", nColWidth, nRowThickness);
       

// PROCESS ROW 4 COLUMN 3 


        xdHiOp =  rnd( ( zdHigh - zdOpen ) ,iDecimals) ;

        if( xdHiOp  > 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.lime;
                    } 
        else
        if( xdHiOp  < 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.red;
               }
       else {   
           xdFGColor = Color.black;
          xdBGColor = Color.yellow;
            }
        sStr     = "" + xdHiOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xdFGColor, xdBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col3", nColWidth, nRowThickness);
       

// PROCESS ROW 4 COLUMN 4


 
        xdOpLo =  rnd( ( zdOpen - zdLow ) ,iDecimals) ;


        if( xdOpLo  > 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.lime;
                   } 
        else
        if( xdOpLo  < 0 ) {
           xdFGColor = Color.black;
          xdBGColor = Color.red;
               }
       else {   
           xdFGColor = Color.black;
          xdBGColor = Color.yellow;
           }

        sStr     = "" + xdOpLo ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xdFGColor, xdBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col4", nColWidth, nRowThickness);
       

// PROCESS ROW 4 COLUMN 5


 
        xdClOp =  rnd( ( zdClose - zdOpen ) ,iDecimals) ;


        mClOp =  Math.abs(xdClOp);

        if( mClOp  >= iTrade1 && mClOp  <= iTrade2 ) {
           xFGColor = Color.green;
          xBGColor = Color.white;
                   } 
        else

        if( xdClOp  > 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.lime;
                   } 
        else
        if( xdClOp  < 0 ) {
           xFGColor = Color.black;
          xBGColor = Color.red;
               }
       else {   
           xFGColor = Color.black;
          xBGColor = Color.yellow;
           }

        sStr     = "" + xdClOp ;
        drawTextPixel(nX+=nFontCX, nY, sStr, xFGColor, xBGColor,
        Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
        null, nFontSize, "Row4Col5", nColWidth, nRowThickness);


    return; // MAIN
}


//==rnd will round to N digits.
function rnd(value, N) {
    var n;
    var mult=1;
    for(n=0;n<N;n++) mult*=10;
    value*=mult;
    return Math.round( value,N)/mult;
}

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