Jump to content
Medved Trader Forums

Calculations including PreMarket


Recommended Posts

Hello.

I am searching for Volumespikes. I compare them to the Moving average based on the volume bars.

Especially near the open it is important that the Moving Average also uses the PreMArket Date. If not I always get alerts.

I thought If I choose in the scanner "Extended Hours = Always" This should be ok. But it is not. MT calculates the MA based on the volume only for the regula session.

How can I fix this?

Thanks!

 

I use this code:

 


    // Reversal Volume Spike
    if (Volume_Bar > ((Volume_SMA)*1.5) && Volume_Bar[1] > Volume_SMA[1] && BarVolume > 30000)
    {
        // Reversal Top
        if (Close > Open && Close[1] > Open[1] && Close[2] > Open[2] && Close[2] < Close[1] && Close[1] < Close && RSI_Line > 70)
        {
            SetColor(0, Color.DarkGreen);   TriggerAlert("Vol Spike Top", @"Vol Spike Top");   SetScanResult(@"Vol Spike Top");
            SetScanResult(1,Volume_Bar);
            SetScanResult(2,Volume_SMA);
        }
    
        // Reversal Bottom
        if (Close < Open && Close[1] < Open[1] && Close[2] < Open[2] && Close[2] > Close[1] && Close[1] > Close && RSI_Line < 30)
        {
            SetColor(0, Color.DarkRed);   TriggerAlert("Vol Spike Bottom", @"Vol Spike Bottom");   SetScanResult(@"Vol Spike Bottom");
            SetScanResult(2,Volume_Bar);
            SetScanResult(3,Volume_SMA);
        }   

Edited by ocram1980
Link to comment
Share on other sites

I checked, and the MA is calculated on whatever shows, if you show premarket, MA is calculated using premarket values.

 

Of course, as soon as the market starts, the volume jumps, becomes way over MA and you would get an alert.

 

What you see (first opened the chart only with bars within the regular session. And after a few seconds he added the MA) is if you don't have premarket data to begin with, and get it from a backfill. But once you do get the backfilled data, next time you open the chart, it will be there.

Also - alerts in MT only happen on "latest" data - that is, if you have a chart for a day and the alert condition is satisfied let's say 20 minutes ago, it won't trigger. It is only triggered on the last - rightmost - candle.

Link to comment
Share on other sites

Hi Mike.

Thanks for the response.

My scanner runs on the 5 min chart. I know that in the opening I have volume spikes and they would trigger my alert. This is why I use the parameter to start the scanner at least 10 min after the open. And I know that the scanner will only use the latest candle on the right.

Anyway I think there is a problem.. I started my trading day today late. So I just went into trading (2 hours before the close).

After 10 minutes the scanner starts alerting almost all my 200 stocks of the watchlist. So this time it is not the problem with premarket. It is the problem with backfill data... The scanner uses only the live data, and not the backfill data.

 

Attached there is a screenshot which shows the problem exactly.

In picture_1 you see the alert on SQ. In the column "Scan R1" you see the volume of the calculation which is 53,512. In column "Scan R2" you can see the value of the Moving Averag on the volume which is 7,354.20. This is why I got the alert, beause the volume of the bar is more than 1.5 times higher than the moving average on the volume bar. And you can see it fits with the chart. Right on the bottom there are the same values. But on this chart there is still no backfill data. So the value of the Moving Average is wrong because it is calculated WITHOUT the back fill data. I can not use this values. MT has to calculate only including the backfilldata.

On "Picture _2" you can see the Values of the SQ chart a few seconds later. As you can see the Volume is a bit higher because its a few seconds later. But the important thing is the Moving Average is near the value of the volume. Maybe even a bit higher than the Volume bar. So no Way there is a volume spike. 

So my problem is still the MT dont uses the backfill data. How can I fix this?

Thanks in Advance!

Picture_1.PNG

Picture_2.PNG

Link to comment
Share on other sites

Maybe I am just stupid. Do I have to check this on?

Or to change my question above from the previous post: How do I say MT that it should backfill all stocks from my portfolio, for the current day including Premarket BEFORE it starts scanning?? I think this is the correct question.

Picture_3.PNG

Edited by ocram1980
Link to comment
Share on other sites

Hello Guys.

 I am sorry for asking again. But:

With activating "Auto-backfill" it draws the premarket data in the chart. This is ok.

But in my opinioin the calculation is still without Premarket data. As you can see in the screenshot: 

The EMA in the chart for the current candle is near 43,000. 20 bars before (This is during pre MArket) the EMA is about at 14,000.

On the left I printed 4 colums:

ScanR1 = current Volume

ScanR2 = current EMA on the Volume

ScanR3 = current EMA on the Volume 1 bar before

ScanR4 = current EMA on the Volume 20 bars before

So you can see the calculation in "ScanR2" is at 27,790. It should be at 43,000

ScanR4 is at 220. about equal to zero. It should be at about 14,000.

The Calculation is too less.

What do I wrong?

 

Thanks in Advance! Marco.

 

a3d45e61542bc241a6cf514784013a98.png

Link to comment
Share on other sites

On 11/5/2023 at 5:46 AM, Mike Medved said:

1. EMA is weird. It wants a LOT of data.

2. You do have the extended hours in scan set to "Always" same as in the chart right?

3. Try this: if your chart is showing let's say 20 days, do a SetDaysNeeded(20) call in your paintbar code.

 

As you can see in the screenshot I set the "Extended Hours" to "Always". And as you can see in the attached code, I included the code " SetDaysNeeded(20);"

But it did not work. You can see in the Screenshot the chart and the calculation for CARR. The EMA in Premarket should be near 10-20K. But it is near zero (0.364).

Thanks for helping. I appreciate very much!

Medved Trader Screnshot.PNG

Strategy.PBExport

Link to comment
Share on other sites

Thanks. I will watch it closely and try to find an example. Currently I got no problems. Confusing.

Let me start with a similar question: I am already running the scanner for 1.5 hours. But TSLA has still not filled the historic data? I see this every day. Always with TSLA. What is going on with this stock?

Marco.

Link to comment
Share on other sites

On 11/16/2023 at 10:26 AM, ocram1980 said:

Thanks. I will watch it closely and try to find an example. Currently I got no problems. Confusing.

Let me start with a similar question: I am already running the scanner for 1.5 hours. But TSLA has still not filled the historic data? I see this every day. Always with TSLA. What is going on with this stock?

Marco.

Not sure. But you can manually backfill. Just right click on TSLA and choose the option to backfill.

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...