Announcement

Collapse
No announcement yet.

Decimals

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

  • Decimals

    I'm using a calculation of a 5 bar average for my target, and ig it's possible I would like to be able to show the number in pips automaticly. The problem right now is that the different markets has different decimals. I added a multiplier, but is it possible to let the efs do this in auto. I was thinking something like this:

    if(decimals = 2){
    Target = Sum/5 * 100}
    if(decimals = 4){
    Target = Sum/5 * 10000}


    etc.

    Is this possible? An if it is, how do I apply it. Would be very happy if someone could help me here.

    Regards
    Karfhans
    Attached Files

  • #2
    Hi,

    I've been thinking about doing this for a while so I took your request as incentive. Here is my rendition.

    PHP Code:
    debugClear();

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Target 1");
        
    setShowCursorLabel(true);
        
    setShowTitleParameters(false)
    }
    var 
    vDecimal 0;
    var 
    bInit false;
    var 
    Target 0;
    var 
    Multi 0;

    function 
    main() {
        
            if(!
    bInit){
                var 
    MinTick getMinTick("6E #F").toString();//replace "6E #F" with your own symbol
                
    if(!isNaN(MinTick)) vDecimal MinTick.slice(2).length;  // returns -4- decimal places for 0.0001
                //debugPrintln(vDecimal);  // prints -4- decimal places for 0.0001
                
    Multi Math.pow(10,vDecimal);
                
    bInit true;
            }
            
    //debugPrintln(Multi); //prints 10000 for symbol -6E #F-
            //Calculate Target***********************************************
            
    Value1 high(-1) - low(-1)
            
    Value2 high(-2) - low(-2)
            
    Value3 high(-3) - low(-3)
            
    Value4 high(-4) - low(-4)
            
    Value5 high(-5) - low(-5)

            
    Sum Value1+Value2+Value3+Value4+Value5
            Target 
    Sum /Multi
            
            drawTextPixel
    (1305" Target 1: " +Target.toFixed(0)+" P "Color.whiteColor.blue
            
    Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.FRAME
            
    "Arial"12"Target_1"); 
            return;


    Wayne
    Attached Files
    Last edited by waynecd; 04-09-2010, 11:14 PM.

    Comment

    Working...
    X