Save $100!
   
Support File Library Store Products Home

EFS-Tools.com -> MENT Multi-Data View Window -> Code Examples

Programming eSignal's EFS languages with MENT Multi-Data View Window (MDVW) is simple. In these coding examples, we'll be working with the "Builtin Stochastic" indicator. These examples illustrate the components and uses of the MDVW functions.

This first example illustrates a simple deployment of the MDVW functions to report the stochastic indicator values to the MDVW window. In this example, we are simply reporting the following fields to the MDVW application..

Symbol
Interval
Stochastic FAST value
Stochastic SLOW value

// ----------------------------------------------------------------------
// Sample Stochastics MDVW application

// ----------------------------------------------------------------------

var vStoch = null; // declare the indicator container variable
var mdvwLib = addLibrary("MDVW.efsLib"); // include the MDVW library
var rowID = 0; // declare the MDVW rowID variable
 


function preMain() { // declare all preMain() conditions
   setStudyTitle("MDVW Stochastic");
   setCursorLabelName("%K", 0);
   setCursorLabelName("%D", 1);
   setDefaultBarStyle(PS_SOLID, 0);
   setDefaultBarStyle(PS_SOLID, 1);
   setDefaultBarFgColor(Color.blue, 0);
   setDefaultBarFgColor(Color.red, 1);
   setDefaultBarThickness(1, 0);
   setDefaultBarThickness(1, 1);
   setPlotType(PLOTTYPE_LINE, 0);
   setPlotType(PLOTTYPE_LINE, 1);

   var fp1 = new FunctionParameter("K", FunctionParameter.NUMBER);
     fp1.setLowerLimit(1);
     fp1.setDefault(14); //Edit this value to set a new default

   var fp2 = new FunctionParameter("Fast", FunctionParameter.NUMBER);
     fp2.setLowerLimit(1);
     fp2.setDefault(1); //Edit this value to set a new default

   var fp3 = new FunctionParameter("Slow", FunctionParameter.NUMBER);
     fp3.setLowerLimit(1);
     fp3.setDefault(3); //Edit this value to set a new default

   var fp4 = new FunctionParameter("Upper", FunctionParameter.NUMBER);
     fp4.setLowerLimit(0);
     fp4.setDefault(80); //Edit this value to set a new default

   var fp5 = new FunctionParameter("Lower", FunctionParameter.NUMBER);
     fp5.setLowerLimit(0);
     fp5.setDefault(20); //Edit this value to set a new default

} // end preMain()

//---------------------------------------------------------------
function main(K,Fast,Slow,Upper,Lower) {

   if(vStoch==null) vStoch = new StochStudy(K, Fast, Slow);
   addBand( Upper, PS_SOLID, 1, Color.black,2);
   addBand( Lower, PS_SOLID, 1, Color.black,3);

 // Allow MDVW actions only for most recent bars
 
if (getCurrentBarIndex() >= -1) {
   if (rowID == 0) {
  // if MDVW rowID is NOT DEFINED
     // try to add new row to MDVW
     rowID = mdvwLib.addRow();
     if (rowID != 0) {   // if MDVW rowID is valid
           // then, define MDVW columns
  
  
  
  mdvwLib.addColumn(rowID, "Symbol", "left", 10);
          mdvwLib.addColumn(rowID, "Int", "left", 5);
          mdvwLib.addColumn(rowID, "STO-FAST", "center", 13);
          mdvwLib.addColumn(rowID, "STO-SLOW", "center", 13);
     }
   }

   if (rowID != 0) {   // if MDVW rowID is valid
     // then, update cell values as STRINGS
  
  
mdvwLib.updateCellString(rowID, 0, getSymbol());
     mdvwLib.updateCellString(rowID, 1, getInterval());
     mdvwLib.updateCellString(rowID, 2, vStoch.getValue(StochStudy.FAST).toFixed(4));
     mdvwLib.updateCellString(rowID, 3, vStoch.getValue(StochStudy.SLOW).toFixed(4));
  }
 }

   return new Array(vStoch.getValue(StochStudy.FAST),vStoch.getValue(StochStudy.SLOW));

}// end main()

function postMain() {
     // Called when EFS is removed/reloaded
     // removes the existing MDVW row

     mdvwLib.removeRow(rowID);