Announcement

Collapse
No announcement yet.

adding symbol param problem

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

  • adding symbol param problem

    For drawing a circle on top of a bar when that bar's High is higher than the (-1) bar's High by, say, 4 cents, the following works fine.

    PHP Code:
    //{{EFSWizard_Expression_1
            
    if (
                
    high() >= high(-1) + .04
            
    onAction1();
        
    //}}EFSWizard_Expression_1


    //{{EFSWizard_Action_1
        
    function onAction1() {
            
    drawShapeRelative(0high(), Shape.CIRCLE""Color.RGB(0,0,0), Shape.TOP);
            
    vLastAlert 1;
        }
        
    //}}EFSWizard_Action_1 
    However, when I add a symbol parameter as below, circles are drawn on every higher High, not just the ones at least 4 cents higher.

    How can I draw a circle on top of a bar on a QQQQ chart every time SPY goes higher by at least 4 cents instead of every time SPY goes higher?


    PHP Code:
    //{{EFSWizard_Expression_1
            
    if (
                
    high(01"spy") >= high(-11"spy") + .04
            
    onAction1();
        
    //}}EFSWizard_Expression_1 

  • #2
    checkraise
    I am not at my computer at this time so I am unable to verify this but if I remember correctly adding a value to price(-x, n, "symbol") [which I believe is an array object] concatenates that value rather than adding it.
    For example if the value of ES U6 was 1280.25 then high(-1,1,"es u6")+0.05 will return 1280.250.05 instead of 1280.30.
    To verify this run the following code on a chart and check the output in the Formula Output Window. You should see the effect I described.
    PHP Code:
    function main(){
        var 
    high(0,1,"es u6");
        
    debugPrintln(x+0.05);

    The solution to that is to convert price(-x,n,"symbol") to a value prior to performing a calculation and that can be easily done by multiplying or dividing that price by 1. In your condition try replacing the following
    high(0, 1, "spy") >= high(-1, 1, "spy") + .04
    with
    high(0, 1, "spy") >= (high(-1, 1, "spy")*1) + .04
    I think that will give you the result you want
    Alex

    Comment


    • #3
      Alex, everything was just exacly like you said. It was indeed concatenating (nice word) - multiplying by 1 did the trick.

      Thanks very much.

      Comment


      • #4
        checkraise
        You are most welcome
        Alex

        Comment

        Working...
        X