Jump to content
Medved Trader Forums
Sign in to follow this  
Mike Medved

Sample scan/paintbar - price at last 15 candle's high

Recommended Posts

I just sent this to one of the clients, posting it here as an example:
 

 

/// Note that some functions are empty as is the PaintbarState - that's because they
/// are automatically put in by the Advanced paintbar generators and are just
/// placeholders if they are not needed

FIFOQueue SavedCandleHigh;

FIFOQueue CandleHigh;

/// <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;

/// <summary>

/// Is called at start of paintbar calculation, should be used to clear the paintbar state

/// </summary>

private void PaintbarClearState()

{

   CurrentState    = new PaintbarState();

   SavedCandleHigh = new FIFOQueue(15);

   CandleHigh      = new FIFOQueue(15);

}

/// <summary>

/// Saves paintbar state (called internally).

/// </summary>

private void PaintbarSaveState()

{

   SavedState = CurrentState;

   CandleHigh.CopyTo(SavedCandleHigh);

}

/// <summary>

/// Restores paintbar state (called internally).

/// </summary>

private void PaintbarRestoreState()

{

   CurrentState = SavedState;

   SavedCandleHigh.CopyTo(CandleHigh);

}

public void MainCalculation()

{

  CandleHigh.Add(High);

  double high, low;

  CandleHigh.GetHighLow(out high, out low);

  //
Can instead do if (High >= high) depending on what functionality you want

  if (Close >= high)  // if current candle's close is at 15-candle high.

  {

        SetColor(SysColor.MainIndicator);

        TriggerAlert("at 15 candle high", "15 hi");

        SetScanResult(true);

  }

}

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...