BlueCollarDayTrading Posted June 10, 2021 Report Share Posted June 10, 2021 Is there any way I can reference the OHLC of a candle with time ie Checking the close of the bar at 9am within a scan/paintbars Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted June 10, 2021 Report Share Posted June 10, 2021 It can be done pretty easily - but not directly. The thing is, the paintbar/scan always runs through ALL the candles it has before it starts chugging on incoming data with the last candle only. So look at this. Note that I am doing the PrevTimestamp thing just to make sure it records the first candle at after 10 minutes after session start - in case there is no candle exactly at 10 min after session start. Modify it to change the time you're checking. Double At10MinAfterSessionStart=0; // Close of first candle 10 minutes after session start or after DateTime PrevTimeStamp; public void MainCalculation() { var Cutoff = TradingDay.SessionStart.AddMinutes(10); if (Timestamp >= Cutoff && PrevTimeStamp<Cutoff) { At10MinAfterSessionStart = Close; } PrevTimeStamp = Timestamp; } Quote Link to comment Share on other sites More sharing options...
BlueCollarDayTrading Posted June 10, 2021 Author Report Share Posted June 10, 2021 (edited) Not sure how your code is working. How can I check if a candle close is greater than a candle open at 9am EST . (9am is in the premarket as you know) and if a candle close is less than candle open Edited June 10, 2021 by BlueCollarDayTrading Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted June 10, 2021 Report Share Posted June 10, 2021 "How can I check if a candle close is greater than a candle open at 9am EST" - the "candle close" in that statement - is that at 9am or is it current? If current - then this code: (make sure you run it with extended hours turned on) Double At30MinBeforeSessionStart=0; // Open of first candle that shows up at 30 minutes or less before session start DateTime PrevTimeStamp; public void MainCalculation() { var Cutoff = TradingDay.SessionStart.AddMinutes(-30); if (Timestamp >= Cutoff && PrevTimeStamp<Cutoff) { At30MinBeforeSessionStart= Open; } PrevTimeStamp = Timestamp; // this checks if current Close is greater than the Open at 9am if (Timestamp >= TradingDay.SessionStart && Close > At30MinBeforeSessionStart) // checks if in regular session AND close > open-at-9am { ... do something here... } } Quote Link to comment Share on other sites More sharing options...
BlueCollarDayTrading Posted June 10, 2021 Author Report Share Posted June 10, 2021 What I am trying to do is check the Open and Close of the 9am candle only and then do something. for example after 45 mins into the market open (1015am EST) I still want to check if the 9am candle close was above or below the 9am candle open. Then I will run some calculations depending on if the 9am candle is a green or red bar. I want to run a scan/paintbar that checks the 9am candle for red or green close and then does some calculations on the current bar. I have the calculations for the current bar I just can't figure out how to do a specific bar in the past data. Been trying to use time. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted June 10, 2021 Report Share Posted June 10, 2021 Ah ok. I misunderstood. Boolean Green9AMCandle; DateTime PrevTimeStamp; public void MainCalculation() { var Cutoff = TradingDay.SessionStart.AddMinutes(-30); if (Timestamp >= Cutoff && PrevTimeStamp<=Cutoff) { Green9AMCandle = Open>Close; } PrevTimeStamp = Timestamp; if (Green9AMCandle) { ... do something here... } } Quote Link to comment Share on other sites More sharing options...
BlueCollarDayTrading Posted June 11, 2021 Author Report Share Posted June 11, 2021 Been working this since yesterday. I am not able to get it to work for the simplest thing. I am trying to simply get it to work for Green if true and Red if false. Then I tried to get it to simply do Green if true and nothing if false. All I get is a green. I set a paintbar to do a green band at top if true and nothing if false. It give me a green band at top on all charts no matter. Can you show me how I can get a Green if True, A Red if False, and White if Close==Open Programing is not my thing but I am trying to figure this out Quote Link to comment Share on other sites More sharing options...
BlueCollarDayTrading Posted June 12, 2021 Author Report Share Posted June 12, 2021 On 6/10/2021 at 1:30 PM, Mike Medved said: Ah ok. I misunderstood. Boolean Green9AMCandle; DateTime PrevTimeStamp; public void MainCalculation() { var Cutoff = TradingDay.SessionStart.AddMinutes(-30); if (Timestamp >= Cutoff && PrevTimeStamp<=Cutoff) { Green9AMCandle = Open>Close; } PrevTimeStamp = Timestamp; if (Green9AMCandle) { ... do something here... } } Been working this since yesterday. I am not able to get it to work for the simplest thing. I am trying to simply get it to work for Green if true and Red if false. Then I tried to get it to simply do Green if true and nothing if false. All I get is a green. I set a paintbar to do a green band at top if true and nothing if false. It give me a green band at top on all charts no matter. Can you show me how I can get a Green if True, A Red if False, and White if Close==Open Programing is not my thing but I am trying to figure this out Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted June 14, 2021 Report Share Posted June 14, 2021 On 6/11/2021 at 9:33 PM, BlueCollarDayTrading said: Been working this since yesterday. I am not able to get it to work for the simplest thing. I am trying to simply get it to work for Green if true and Red if false. Then I tried to get it to simply do Green if true and nothing if false. All I get is a green. I set a paintbar to do a green band at top if true and nothing if false. It give me a green band at top on all charts no matter. Can you show me how I can get a Green if True, A Red if False, and White if Close==Open Programing is not my thing but I am trying to figure this out Well, was the 9am candle Green? Because if it was, then it would show green band. Export your paintbar and send it to us support@medvedtrader.com Quote Link to comment Share on other sites More sharing options...
BlueCollarDayTrading Posted June 14, 2021 Author Report Share Posted June 14, 2021 It works correctly now. Thanks very much for the help, I really appreciate it. Quote Link to comment Share on other sites More sharing options...
BlueCollarDayTrading Posted August 6, 2021 Author Report Share Posted August 6, 2021 Been trying to use this but it does not work in real time. It only works correctly in backfills, so good for back testing. I have been trying to figure out what makes it work consistently and what makes it fail. I believe it has to do with the first tick of the candle being an uptick to be green and a down tick to be red. It may have something to do with using a Boolean. On 6/13/2021 at 7:54 PM, Mike Medved said: Well, was the 9am candle Green? Because if it was, then it would show green band. Export your paintbar and send it to us support@medvedtrader.com Been trying to use this but it does not work in real time. It only works correctly in backfills, so good for back testing. I have been trying to figure out what makes it work consistently and what makes it fail. I believe it has to do with the first tick of the candle being an uptick to be green and a down tick to be red. It may have something to do with using a Boolean. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted August 6, 2021 Report Share Posted August 6, 2021 Send me again the paintbar you're using I will take a look. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.