Search code examples
if-statementgoogle-sheetsarray-formulasgoogle-sheets-formulagoogle-finance

Convert this formula into arrayformula


short and simple, how can this formula be rewritten into array formula variant? Thanks

=iferror(if(and(GOOGLEFINANCE(B2, "High")>=D2+Now()-Now(), GOOGLEFINANCE(B2,"Low")<=D2),"Filled",if(F2<0.005, "In Threshold",if(and(E2="Long", GOOGLEFINANCE(B2,"priceOpen")<D2),"JumpedG ap",if(and(E2="Short",GOOGLEFINANCE(B2,"priceOpen")>D2),"Jumped Gap","Active")))))

Solution

  • try like this if it works for you:

    =ARRAYFORMULA(IFERROR(
     IF((GOOGLEFINANCE(B2:B, "High")>=D2+NOW()-NOW()) * (GOOGLEFINANCE(B2:B, "Low")<=D2), "Filled",
     IF(F2:F<0.005, "In Threshold",
     IF((E2:E="Long")  * (GOOGLEFINANCE(B2:B, "priceOpen")<D2), "JumpedG ap",
     IF((E2:E="Short") * (GOOGLEFINANCE(B2:B, "priceOpen")>D2), "Jumped Gap", "Active"))))))
    

    or maybe:

    =ARRAYFORMULA(IFERROR(
     IF((GOOGLEFINANCE(B2:B, "High")>=D2:D+NOW()-NOW()) * (GOOGLEFINANCE(B2:B, "Low")<=D2:D), "Filled",
     IF(F2:F<0.005, "In Threshold",
     IF((E2:E="Long")  * (GOOGLEFINANCE(B2:B, "priceOpen")<D2:D), "JumpedG ap",
     IF((E2:E="Short") * (GOOGLEFINANCE(B2:B, "priceOpen")>D2:D), "Jumped Gap", "Active"))))))