Jump to content
Medved Trader Forums

SetInterVar & GetInterVar


Recommended Posts

Let's say I want to run a scan on a historical Daily Chart triggering an Alert if today's Volume is greater than the average volume. Something like this for explanation purpose:

image.png

Now, let's assume I have a second portfolio which is exactly the same as the first one. For every symbol where the condition from the historical scan is true, I want an Alert if the Symbol trades in the bottom 20% of its day range. (or some other stuff that needs to be done in an intraday scan)

image.png

I am not looking for some kind of workaround to put this into one scan, but I use this as a plain example to ask for a concrete illustration of how the Inter-Paintbar Communication works. My question is, where and how to implement both the SetInterVar and the GetInterVar functions into the code. I added as //comments into the snippets what I have tried so far, but apparently this is not how to do it. 

A huge thanks in advance for anyone who devotes his time and skill to helping this medved newbie :)

Edited by Dalewoods
Link to comment
Share on other sites

In the Historical scan, when you call the command to trigger the alert, also set the Intervar. For example 

    if (true) // use your condition instead of just true
    {    
        SetScanResult(0, true);
        SetInterVar("histHighVol", 1);
    }

Then, in your intraday scan, you use GetInterVar for histHighVol and then if it is 1 (or just greater than zero) do whatever else. For example:
 

public void MainCalculation()
{
    if (GetInterVar("histHighVol") > 0)
    {
        var IsBottom20Range = true; // add your own actual condition instead of true
        
        if (IsBottom20Range)
            SetScanResult(0, true);
    }
}

 

Link to comment
Share on other sites

NOTE: if the Historical scan causes the histHighVol InterVar to be changed, the intraday scan will not see the change till next time it is triggered (next quote). So you may need 2 quotes to actually trigger the 2nd scan - one that gets the historical scan to update, and then the next quote would get intraday quote to update, since you cannot assume which order the scans will be processed in .

Link to comment
Share on other sites

Posted (edited)

I am not sure if I get this right. As the list of collected historical scan results is extending, the intraday scan can only further process these symbols if.. what happens? Do you mean that the intraday scan will only consider the new symbols (in its check for fulfillment) as of the timestamp of the very next tick since its appeareance in the historical scan?

Edited by Dalewoods
Link to comment
Share on other sites

not timestamps.  just occurrence of quotes.  so:


* quote comes in. Intraday scan checks - var is 0. Hist scan runs - sets var to 1

* next quote comes in. Intraday scan checks - var is 1 so it does stuff.....

as you see, 2 quotes needed for the intraday scan to see the change.

 

Link to comment
Share on other sites

Hi,

Very new to Medved and C# in general. Trying to set up something similar using SetInterVar(). I have a portfolio with S&P 500 stocks that I run a historical scan through to narrow down to under the 100 symbol limit for a live intraday scan. I then have a second portfolio with the same 500 stocks and wanted to run the intraday scan on them, but only if they met the historical scan conditions. 

 

The Historical Scan is set up with an If and Else statement giving an output that labels stocks as bullish or bearish on the Daily. Where I put the SetScanResult, I have also included SetInterVar() like Jerry has above. But it's not working. 

Not sure if I understood correctly but here are the steps I'm doing

1. Open portfolio #1, run historical scan, and stop scan

2. Open Portfolio #2 and run intraday scan, however, it is pulling stocks not meeting the historical scan criteria. 

I can't seem to understand this, any help would be appreciated. Thank you!

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.

 Share

×
×
  • Create New...