Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 12:42:12 +0000



Post From: How to compare EMA to price?

[2014-05-21 20:56:29]
User12676 - Posts: 70
Strange, when I put it in a study file all by itself, it works. When I add if to my study, it doesnt....
I modified the zig zag study and added it there

SCSFExport scsf_ZigZagCumulativeVolumeStudy(SCStudyInterfaceRef sc)
{
  SCSubgraphRef ZigZagLine = sc.Subgraph[0];

  SCSubgraphRef Accumulated = sc.Subgraph[4];
  sc.Subgraph[4].LineWidth = 6;
  
  SCSubgraphRef VPM = sc.Subgraph[7];
  
  SCSubgraphRef AccumulatedVolumeOpenClose = sc.Subgraph[6];
  SCSubgraphRef ER = sc.Subgraph[8];
  
  AccumulatedVolume = sc.Subgraph[9];
  AccumulatedDiffVolume = sc.Subgraph[10];
  AccumulatedLegTime = sc.Subgraph[11];

  ZA = sc.Subgraph[12];
  ZU = sc.Subgraph[13];
  ZD = sc.Subgraph[14];

  SCSubgraphRef Long = sc.Subgraph[20];
  SCSubgraphRef Short = sc.Subgraph[21];


  SCSubgraphRef ExponentialMA = sc.Subgraph[99];

  SCInputRef VolumeToAccumulate = sc.Input [0];
  
  SCInputRef VersionUpdate = sc.Input[14];
  SCInputRef CalculationMode = sc.Input[17];
  SCInputRef ReversalAmount = sc.Input[19];
  SCInputRef NumberBarsForReversal = sc.Input[20];
  SCInputRef RangeRatio = sc.Input[21];
  SCInputRef Invert = sc.Input[22];
  SCInputRef ShowBidVolumePositive = sc.Input[23];
  SCInputRef BlendedVolumePeriod = sc.Input[24];
  SCInputRef ActiveMarketHours = sc.Input[25];
  
  //HIDDEN
  SCInputRef CalcOnBarClose = sc.Input[49];
  SCInputRef InputDataHigh = sc.Input[50];
  SCInputRef InputDataLow = sc.Input[51];
  SCInputRef ReversalPercent = sc.Input[54];
  
  if(sc.SetDefaults)
  {
    //During development set this flag to 1, so the DLL can be modified.
    //When development is completed, set it to 0 to improve performance.
    sc.FreeDLL = 1;  
  
    sc.GraphName="MIKE WAVE ALERT";
  
    //Manual looping
    sc.AutoLoop = 0;
    sc.ValueFormat= 0;
    //MIKE sc.GraphRegion = 1;
    sc.GraphRegion = 0;

    ZigZagLine.Name = "MIKE WAVE ALERT";
    ZigZagLine.DrawStyle = DRAWSTYLE_IGNORE;

    Accumulated.Name= "Accumulated";
    //MIKE Accumulated.DrawStyle = DRAWSTYLE_BAR;
    Accumulated.DrawStyle = DRAWSTYLE_IGNORE;
    Accumulated.SecondaryColorUsed = 1;
    Accumulated.PrimaryColor = RGB(90,150,231);
    Accumulated.SecondaryColor = RGB(167,48,48);

    ER.Name= "Effort Reward Bars";
    ER.DrawStyle = DRAWSTYLE_COLORBAR;
    ER.SecondaryColorUsed = 1;
    ER.PrimaryColor = RGB(0,255,255);
    ER.SecondaryColor = RGB(255,0,0);    
      
    VolumeToAccumulate.Name= "Volume To Accumulate";
    VolumeToAccumulate.SetCustomInputStrings("Total Volume;Ask Bid Volume Difference;Force Ratio;Cum Momentum + Cum Momentum Diff;Cum Momentum + Per Bar Momentum Diff;Cum Momentum + Per Bar Momentum and Volume Diff;Cum Momentum;Cum Momentum + Per Bar Volume Diff;Blended Volume Diff;Blended Volume Total;Leg Time");
    VolumeToAccumulate.SetCustomInputIndex(10);

    VersionUpdate.SetInt(1);

    InputDataHigh.Name = "Input Data for High";
    InputDataHigh.SetInputDataIndex(SC_LAST);

    InputDataLow.Name = "Input Data for Low";
    InputDataLow.SetInputDataIndex(SC_LAST);

    CalculationMode.Name = "Mode (1,2,3)";
    CalculationMode.SetInt(2);
    CalculationMode.SetIntLimits(1, 3);

    ReversalPercent.Name = "Reversal % for Mode 1";
    ReversalPercent.SetFloat(.05f);

    //ORIG ReversalAmount.Name = "Reversal Amount for Mode 2,3";
    ReversalAmount.Name = "Reversal Amount";
    ReversalAmount.SetFloat(0.5f);

    NumberBarsForReversal.Name = "Bars Required for Reversal (Mode 2)";
    NumberBarsForReversal.SetInt(1);

    CalcOnBarClose.Name = "Calculate New Values On Bar Close";
    CalcOnBarClose.SetYesNo(1);
    
    ShowBidVolumePositive.Name = "Show Bid Volume As Positive";
    ShowBidVolumePositive.SetYesNo(0);
    
    RangeRatio.Name = "Range Ratio (Per bar, not cumulative)";
    RangeRatio.SetCustomInputStrings("None;Open / Close;High / Low");
    RangeRatio.SetCustomInputIndex(0);    

    Invert.Name = "Invert";
    Invert.SetYesNo(0);

    BlendedVolumePeriod.Name = "Blended Volume Period";
    BlendedVolumePeriod.SetInt(10);
    
    ActiveMarketHours.Name = "Active Market Hours (For Leg Time)";
    ActiveMarketHours.SetString("0630-1115");

    // Volume Price Mismatch Bars
    VPM.Name = "Volume Price Mismatch";
    VPM.DrawStyle = DRAWSTYLE_BAR;
    VPM.DrawZeros = false;
    VPM.SecondaryColorUsed = 1;
    VPM.PrimaryColor = RGB(128,128,128);  
    VPM.SecondaryColor = RGB(128,128,128);  

    // Long Color
    Long.Name = "Long";
    Long.DrawStyle = DRAWSTYLE_COLORBAR;
    Long.PrimaryColor = RGB(90,150,231);
    Long.DrawZeros = false;            

    // Short Color
    Short.Name = "Short";
    Short.DrawStyle = DRAWSTYLE_COLORBAR;
    Short.PrimaryColor = RGB(204,88,146);
    Short.DrawZeros = false;  

    ExponentialMA.Name = "Exponential Moving Average";
    ExponentialMA.DrawStyle = DRAWSTYLE_LINE;
    ExponentialMA.PrimaryColor = RGB(255,0,255);

    return;
  }

  sc.ExponentialMovAvg(sc.Close, ExponentialMA, 20);