Jump to content
Medved Trader Forums

Average between current candle and Open


Recommended Posts

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.
Link to comment
Share on other sites

  • 3 weeks later...

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.

 

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

Posted (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 by 3acor
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 

image.thumb.png.c52d086d3d1e434c04c9c6106f32d451.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...