3acor Posted December 14, 2023 Report Share Posted December 14, 2023 What is the formula in the Average function to be able to average something between the current candle and the session open. I am writing this: Average(0,Daytrading.SessionStart,...) but it won't work. Thanks Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted December 14, 2023 Report Share Posted December 14, 2023 What value do you want to average? The "Change from Open" basically? Over how many candles? Average(20, Close-SymbolData.Open) - would do it for the last 20 candles BUT it would only show correctly for the last day (since SymbolData.Open is for current session only) If you want it correct for every day going back, the code needs to figure out what the Open for each day is, so would be a bit more elaborate. Quote Link to comment Share on other sites More sharing options...
3acor Posted December 14, 2023 Author Report Share Posted December 14, 2023 (edited) I would like to average the BarVolume from the session start to the current timestamp. I would like to use it when running a scan Edited December 14, 2023 by 3acor Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted December 14, 2023 Report Share Posted December 14, 2023 I am not sure what you mean. Wouldn't the "Average" line in the Volume indicator do (if you use "Never" in Extended settings)? Quote Link to comment Share on other sites More sharing options...
3acor Posted December 15, 2023 Author Report Share Posted December 15, 2023 (edited) Which Average line? oh you men the MA line? How can I input that in the scanner? Edited December 15, 2023 by 3acor Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted December 16, 2023 Report Share Posted December 16, 2023 Scanner at the top allows you to add indicators as variables. Add Volume indicator with MA as secondary parameter. 1 Quote Link to comment Share on other sites More sharing options...
3acor Posted January 2 Author Report Share Posted January 2 Is there a way to have the volume being considered starting from the session open? The MA is also including the data in the Pre-market for its calculation or if extended hours are set to Never, it is considering the data of the previous day for the calculation of the MA in the scanner. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 5 Report Share Posted January 5 For that you'd have to keep track of the average yourself. Use StateFIFOQueue of the appropriate size (period), zero it out whenever the new regular session starts (use TradingDay variable - the DayNumber in it changes when the new session starts, and you can figure out if you're in premarket or not as well) and add the candle's volume if regular session. Then take its average. 1 Quote Link to comment Share on other sites More sharing options...
3acor Posted January 7 Author Report Share Posted January 7 (edited) How can I get the difference between the current timestamp and the timestamp of the candle Open and use it in an equation? Example: I am using the scanner on the 15min frequency and currently the time is 10:41am. How can I get the difference of 11min which is the Current Timestamp minus the timestamp of the candle Open? Edited January 7 by 3acor Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 8 Report Share Posted January 8 18 hours ago, 3acor said: How can I get the difference between the current timestamp and the timestamp of the candle Open and use it in an equation? Example: I am using the scanner on the 15min frequency and currently the time is 10:41am. How can I get the difference of 11min which is the Current Timestamp minus the timestamp of the candle Open? (Timestamp.Minute % 15)+1 ? 1 for 1st minute. 2 for second minute. etc. Quote Link to comment Share on other sites More sharing options...
3acor Posted January 9 Author Report Share Posted January 9 8 hours ago, Mike Medved said: (Timestamp.Minute % 15)+1 ? 1 for 1st minute. 2 for second minute. etc. the code wouldn't work. I would like to divide the volume by the difference between the current timestamp and the timestamp of the current 15min candle open. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 10 Report Share Posted January 10 On 1/8/2024 at 6:49 PM, 3acor said: the code wouldn't work. I would like to divide the volume by the difference between the current timestamp and the timestamp of the current 15min candle open. That's what (Timestamp.Minute % 15)+1 gives you. Stick this into a column in a scan and watch it go from 1 to 15 then roll over to 1... Just make sure the scan is run on 15 min candles. Quote Link to comment Share on other sites More sharing options...
3acor Posted January 10 Author Report Share Posted January 10 17 minutes ago, Mike Medved said: That's what (Timestamp.Minute % 15)+1 gives you. Stick this into a column in a scan and watch it go from 1 to 15 then roll over to 1... Just make sure the scan is run on 15 min candles. This is what I get when I insert it Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 11 Report Share Posted January 11 Hm the preprocessor that sprinkles indexing [0]s on indexed variables fails in this case. Try Timestamp[0].Minute 1 Quote Link to comment Share on other sites More sharing options...
3acor Posted May 17 Author Report Share Posted May 17 (edited) It is giving me a constant number which is whatever is after "+". so if I put (Timestamp[0].Minute % 15)+1, it will give me 1. If I put (Timestamp[0].Minute % 15)+2, it will give me 2... Edited May 17 by 3acor Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted May 19 Report Share Posted May 19 On 5/16/2024 at 11:23 PM, 3acor said: It is giving me a constant number which is whatever is after "+". so if I put (Timestamp[0].Minute % 15)+1, it will give me 1. If I put (Timestamp[0].Minute % 15)+2, it will give me 2... Ok so if you have 15 min candles, the Timestamp[0].Minute % 15 will always be 0. I think I misunderstood what you wanted. You want a MTUtil.UtcNowSynced.Minute % 15 This should be sufficient although the data feed timestamps may differ a little bit from the UTC time - depending on the feed. Quote Link to comment Share on other sites More sharing options...
3acor Posted May 19 Author Report Share Posted May 19 So If I am running my scanner on the 15min frequency and I want to have the 15min BarVolume divided by the current timestamp minus the timestamp of the 15min candle open, the formula below works? BarVolume/(MTUtil.UtcNowSynced.Minute % 15) Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted May 20 Report Share Posted May 20 +1 - otherwise you will get a divide by zero error. Quote Link to comment Share on other sites More sharing options...
3acor Posted May 20 Author Report Share Posted May 20 It is still not giving me the right 1min volume Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted May 21 Report Share Posted May 21 On 5/20/2024 at 9:50 AM, 3acor said: It is still not giving me the right 1min volume Try this: make another column and just put the MTUtil.UtcNowSynced.Minute % 15+1 into it. Watch what shows up in the column... Quote Link to comment Share on other sites More sharing options...
3acor Posted May 21 Author Report Share Posted May 21 ok it works now. Even dividing without the +1. Thanks! 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.