How to scan ToS for certain bid/ask spreads?

Discussion in 'Retail Brokers' started by sgjohnson, Apr 6, 2020.

  1. sgjohnson

    sgjohnson

    I've exhausted my brain trying to figure this out. It works on the chart...sort of. I just copy and pasted the code from the ToS tutorial on data not connected to a chart. It had me attach the bid and ask price to the close price. Good enough for that I guess. I defined a plot variable spread in the study, but the scanner doesn't seem to call the variable correctly. Can see it plotted on the chart though. Here's the thinkscript code:

    Code:
    plot ask = close(priceType = "ASK");
    plot bid = close(priceType = "BID");
    plot spread = ask - bid;
    Here's the thinkscript version of the condition:

    Code:
    BidAskSpread()."spread" is less than 0.5
    I didn't actually manually type that in. I used the "Condition Wizard." Anyone tell me what I'm doing wrong?
     
  2. Whenever I have issues with the scanner it usually has to do with the aggregation period. How are you setting up your scan?
     
  3. sgjohnson

    sgjohnson

    I've used different periods. Daily, hourly...increasing the number of bars. Nothing works. Am I missing other setup parameters?
     
  4. Overnight

    Overnight

    This is just a larky thing that came up in my head, but try plot spread = bid - ask?
     
  5. schizo

    schizo

    Try this
    Code:
    def BidAskSpread = spread < 0.5;
     
  6. You probably need to watch training webinars to do the right thing
     
  7. sgjohnson

    sgjohnson

    Why would I do that? The bid is almost always lower than the ask.

    In the study or in the condition? "BidAskSpread" is the name of the study, not a variable really. The condition actually had the study in lower case letters. Changed it to the same way it is in the name of the study. Made no difference. Used operators instead of syntax in the condition. Made no difference. Didn't get any errors, but nothing happened. Same thing: no symbols found. Doesn't matter if I increase the value to 100.
     
  8. schizo

    schizo

    First, I am not entirely sure what you want to achieve. Do you want to merely scan for stocks that have the spread under 0.50 and see the result in the watchlist? If so, then review the following videos:



     
  9. sgjohnson

    sgjohnson

    Thanks schizo. I actually found the first video there about ten minutes ago. I had watched one video on watchlists where they merely mentioned custom columns but didn't detail how to. Didn't immediately strike me to search "custom columns thinkorswim." I'll give this a shot and see how it goes. Thanks again.
     
  10. sgjohnson

    sgjohnson

    Deleted the first two lines and it seems to work now. Though if I have somewhere over a thousand results there's an error in two custom columns: "custom expression subscription limit exceeded." I have a custom column ADX. Doesn't seem like a person should require a custom column for that but whatever. If I remove that column, I can see the spread column for all ~1500 results. Oh well. Best it can do I guess. Sad that I did what the documentation states for that study. The ask keyword is only available in "integration features" like Custom Quotes, otherwise you have to define it or plot it first. They should make all of it consistent.
     
    #10     Apr 7, 2020