Jump to content
Medved Trader Forums

Mike Medved

Administrators
  • Posts

    1,559
  • Joined

  • Last visited

  • Days Won

    126

Posts posted by Mike Medved

  1. Binance (and most other crypto exchanges) does not send that data. IN fact, I think only GDAX bothers to send the current bid/ask. For others, you have to subscribe to the order book and figure it out yourself, which we don't want to do for portfolios, since it would be incredibly wasteful.

  2. If you want specifically NEW low (and not just at the low), you can't do it in basic.

     
    
     
    /// <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
    {
       public Boolean IsNewLow;   
       public Double PrevLow;
    }
     
    /// <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.IsNewLow  = false;
        CurrentState.PrevLow = 0;    
    }
     
    /// <summary>
    /// Saves paintbar state (called internally).
    /// </summary>
    private void PaintbarSaveState()
    {
       SavedState = CurrentState;
    }
     
    /// <summary>
    /// Restores paintbar state (called internally).
    /// </summary>
    private void PaintbarRestoreState()
    {
       CurrentState = SavedState;
    }
     
    public void MainCalculation()
    {
    
        if ((Close == SymbolData.Low AND CurrentState.IsNewLow) OR Close<CurrentState.PrevLow)
        {
            SetScanResult("New Low");
            CurrentState.IsNewLow = true;
            CurrentState.PrevLow  = Close;
        }
        else 
            CurrentState.IsNewLow = false;
     
    }
    
     

     

  3. 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
      }
    }
    
     
  4. 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

     

     

  5. public void MainCalculation()
    {

        // this parameter will show in the scan/paintbar parameter editor and can be changed by the user

        DefinePaintbarParameter("PCT", "Percentage", false, 0, 200, 1, 0.2);

        // get the percent paramer

        var Per = GetPaintbarParameter("PCT");

        if (Close > Low[1] * (1 + Per/100))
        {
            SetColorAndShape("Breakeout", PBShape.ArrowNE, 0xFF00C50C);
            TriggerAlert("Breakeout");
            SetScanResult("Breakeout");
            return;
        }
    }

     

    As for your other suggestion - you can either sort on the scan column or filter the portfolio so that only the rows that have some scan result show.

     

  6. That's a good question MTG - it is actually a pretty complicated formula, I tinkered with it until I found something that works reasonably well.

    it is Max(emamax, Min(average * 6, max * 1.02)

    where

    emamax = the max value of visible volume EMA, if you have it with the volume

    average = the average value of visible volume bar, and

    max = the maximum value of visible volume bar

×
×
  • Create New...