♥ 0 |
Hi, I am looking to plot on a Watchlist column if the RTH Low / High Crossed Pre Market Low / High, and color code. Using some of the code you posted on another study I was able to define and see the premarket levels on the watchlists. But when I want to compare them to the RTH Low/High, given it’s working on intraday mode with Ext checked, it compares to the actual bar, not the Low /High of the day. So basically I need to fix how to reference the Low/High of day ONLY since the RTH Start. Idea is if to plot “BOTH”, if High>ONH and Low<ONL, plot “ONH” if High>ONH, plot “ONL” if Low<ONL, plot “-” if inside ON range. Will add some color coding but I guess I can do that if the rest is working. Below the code I am using. Thanks for your help. #PreMarket Session and ONH / ONL #Regular Trading Session LOD / HOD def stageOneR = RegularTradingEND(GetYYYYMMDD()); def LOD = if RTHStart and RTHSession then low else if low < LOD[1] and RTHSession then low else LOD[1]; AddLabel (yes,if HOD > PMH and LOD < PML then “BOTH” else if HOD > PMH then “ONH” else if LOD < PML then “ONL” else “—“);
RESOLVED
Marked as spam
|
Private answer
Here is the final code. I tested it thoroughly and it's working. Hope I did not miss anything. # Pre Market High / Low Levels Hit at last once wiht Color Coding. #PreMarket Session Levels and Start/Ending Times #PreMkt High and Low #Regular Trading Session Start/Ending Times #RTH High and Low #Definition of variable Outputs #Plots on Watchlist with Text Color Coding #Background Color Coding Marked as spam
|
|||||
Private answer
I am inclined to start from scratch here rather than try to modify your code. The first problem I have though is the use of the following abbreviations: ONH, ONL, ON. Does the ON stand for Overnight? Using abbreviations in the code makes it much more difficult to read and understand. Especially when the code does not work and the only way to tell what you are trying to do is to read the code. So spell things out in your variable names. HOD should be highOfDay, LOD should be lowOfDay.... got it? Ok. The use of the function named RegularTradingEnd() is not going to work here. Simply plot the following as a lower study on a chart and you will see why:
I usually will take the time to explain where the code is wrong and teach you how to correct things. But those abbreviations are making that too difficult. I only allow about 15 mins to provide solutions in the Q&A forum. We need code that is very easy to read and understand. So go back to the charts and rework your code. Clean up those abbreviations so the code is readable and implement SecondsTillTime() and/or SecondsFromTime() functions instead of RegularTradingEnd(). For that, you can examine the code in the following post: https://www.hahn-tech.com/ans/premarket-highlow-label/
Marked as spam
|
Please log in to post questions.