Jump to content
Medved Trader Forums

Recommended Posts

Posted

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

Posted

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

 

 

Posted

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

 

Posted
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
  }
}

 
Posted

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?

Posted

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 :)

Posted (edited)

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
  • 2 weeks later...
Posted

@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?

 

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