Jump to content
Medved Trader Forums

Price Drop Scanner


Recommended Posts

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

 

 

Link to comment
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
  }
}

 
Link to comment
Share on other sites

  • 2 weeks later...

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

 

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