Jump to content
Medved Trader Forums

Recommended Posts

Hey Guys,

I was hoping to create a simple price drop scanner that would alert if a stock dropped more than X% in Y minutes. I feel like this should be easy to do but can't seem to figure it out. 

Any help would be appreciated :)

Thanks,

RC

Share this post


Link to post
Share on other sites

You would have to use advanced mode of that. Create a FIFOQueue of the Y (as in Y minutes) size as a state variable and add the Close to it. Then you can get the high and low from the FIFOQueue and compare it to the current value.

Help for FIFOQueue: https://www.medvedtrader.com/trader/WebHelp/circbuffer_class.htm

the example at the end of this page should help too: https://www.medvedtrader.com/trader/WebHelp/state_keeping.htm

 

 

Share this post


Link to post
Share on other sites

@Mike Medved I've read through both of those posts and I honestly don't even know where to start. Not sure how to create a FIFOQueue or do the comparison you are talking about. 

Do you have any more basic explanations written up? Or could you possibly start me off? Would really appreciate it.

 

Share this post


Link to post
Share on other sites
FIFOQueue SavedPrevCloses;
FIFOQueue PrevCloses;
 
/// <summary>
/// Is called at start of paintbar calculation, should be used to initialize anything needed for the paintbar
/// </summary>
private void PaintbarInitialize()
{
 
}
 
/// <summary>
/// Holds paintbar state - fill with variables needed to be preserved for next paintbar calc
/// </summary>
private struct PaintbarState
{
}
 
/// <summary>
/// Holds current PB state - use to calc PB, changes to it carry over to next PB calc
/// </summary>
private PaintbarState CurrentState;
 
/// <summary>
/// Holds saved PB state - internal
/// </summary>
private PaintbarState SavedState;

Double PercentDrop = 0;
 
/// <summary>
/// Is called at start of paintbar calculation, should be used to clear the paintbar state
/// </summary>
private void PaintbarClearState()
{
    DefinePaintbarParameter("Period", "Period", true, 1, 1000, 1, 10);
    DefinePaintbarParameter("Percent", "Drop %", false, 0.001, 100, 0.1, 0.1);
    var N           = Convert.ToInt32(GetPaintbarParameter("Period"));
    PercentDrop     = Convert.ToInt32(GetPaintbarParameter("Percent"));
    CurrentState    = new PaintbarState();
    SavedPrevCloses = new FIFOQueue(N);
    PrevCloses      = new FIFOQueue(N);
}
 
/// <summary>
/// Saves paintbar state (called internally).
/// </summary>
private void PaintbarSaveState()
{
   SavedState = CurrentState;
   PrevCloses.CopyTo(SavedPrevCloses);
}
 
/// <summary>
/// Restores paintbar state (called internally).
/// </summary>
private void PaintbarRestoreState()
{
   CurrentState = SavedState;
   SavedPrevCloses.CopyTo(PrevCloses);
}
 
public void MainCalculation()
{
  // calculate the EMA of the EMA
  PrevCloses.Add(Close);
 
  Double high, low;
  PrevCloses.GetHighLow(out high, out low);
  if (Close < high*(1-PercentDrop/100))
  {
      SetColor(Color.Lime); // if used as a paintbar
      SetScanResult("Dropped!");  // if used as a scan
  }
}

 

Share this post


Link to post
Share on other sites

Thanks, Mike! Really appreciate it.

Where do I input values for my percentage drop variable and time variable? Also, does the scanner constantly run and then alert me when conditions are met for a certain company?

Share this post


Link to post
Share on other sites

In the Scanning tab there is a button to edit parameters - they are at bottom.

As long as the portfolio updates with RT quotes, the scanner runs on every update in it and lights up the results. That's the whole point :)

Share this post


Link to post
Share on other sites

Hey @Mike Medved just wondering if there is an option to have the scanner alert you with a sound and popup? I typically keep the scanner running in the background and need these notifications to ensure I can jump to the chart.

Edited by RadianChoi

Share this post


Link to post
Share on other sites

@Mike Medved Hey Mike, I added it to the last paragraph as so:

Double high, low;
  PrevCloses.GetHighLow(out high, out low);
  if (Close < high*(1-PercentDrop/100))
  {
      SetColor(Color.Lime); // if used as a paintbar
      SetScanResult("Dropped!");  // if used as a scan
      string Msg = "Base Broken";
      TriggerAlert(Msg);

  }

and it's still not popping up? Should I be adding it somewhere else?

 

Share this post


Link to post
Share on other sites

No, that should be it. When you're editing scan parameters, you can see the "Alert" button - you have to set various alert parameters and notifications.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×