Mike Medved Posted October 1, 2018 Report Share Posted October 1, 2018 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); } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.