Announcement

Collapse
No announcement yet.

function parameter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • function parameter

    I'm Looking for an example for function parameter, similar to as in properties of alerts with a alert tab and customized popup message box to select options like page name and time of alert etc

  • #2
    Alert routine

    Is this the sort of routine you are looking for?

    AlertExamp_1.efs

    PHP Code:
    //Basic List and/or Sound alert function
    //provided by red49er                   

    var aFPArray = new Array();
    var 
    0;

        
    aFPArray[x] = new FunctionParameter("nAlerts"FunctionParameter.STRING);
        
    with(aFPArray[x++]){
            
    setName"Select the alerts you want" );
            
    addOption("list"); 
            
    addOption("sound");
            
    addOption("list & sound");
            
    addOption("none");
            
    setDefault("list & sound"); 
        }

    function 
    preMain(){
        
    //only calc on each new bar, else alert will sound on every tick
        
    setComputeOnClose();
    }

    var 
    bInit false;
    var 
    aInit false;      //alert function initiate flag
    var alerts null;      //holds list/sound user selection
    var listAlertFlag false;
    var 
    soundAlertFlag false;
    var 
    trigger true;     //alter this to trigger LONG or SHORT alerts whilst testing

    function main(nAlerts){
        if (
    bInit == false) {
            
    //set up alerts and sounds
            
    alerts nAlerts;
            
    Alert_Actions(alerts);
            
    bInit true;
        }

    //do your indicator calculations
    //and trigger Alert if conditions met
        
    if(trigger == true){
            var 
    tmp "LONG ALERT AT "+formatPriceNumber(close(0));
            
    Alert_Actions(tmp);
        }
        if(
    trigger == false){
            var 
    tmp "SHORT ALERT AT "+formatPriceNumber(close(0));
            
    Alert_Actions(tmp);
        }
    return 
    close(0);    //your indicator
    }
    //== Alert_Actions function ----------------------------------------
    function Alert_Actions(tem){
    var 
    tmp tem;
        
    //scan user selection and initiate Flags
        
    if(!aInit){
            if(
    tmp.indexOf("list")!= -1){
                
    listAlertFlag true;
            }
            if(
    tmp.indexOf("sound")!= -1){
                
    soundAlertFlag true;
            }
            if(
    tmp.indexOf("none")!= -1){
                
    listAlertFlag  false;
                
    soundAlertFlag false;
            }
            
    aInit true;
            return;
        }
        if(
    soundAlertFlag){
            
    Alert.playSound("Ding.wav"); //select sound of your choice
        
    }                                //C:\Program Files\eSignal\Sounds
        
    if(listAlertFlag){
            
    nHour getHour();
            
    nMins getMinute();
            
    time nHour+":"+nMins;
            if(
    tmp.indexOf("LONG")!= -1){       //Long breakout
                
    Alert.addToList(getSymbol()+"  "+getInterval(),tmp+" : "+time,Color.black,Color.green);
            }
            else if(
    tmp.indexOf("SHORT")!= -1){ //Short breakout
                
    Alert.addToList(getSymbol()+"  "+getInterval(),tmp+" : "+time,Color.black,Color.red);
            }
            
        }    
     return;    

    Comment

    Working...
    X