Hi. The following code gives buy orsell signalwith alertwhen bSetuporsSetupequel to 5. I want to have buy and sell signals with alert when sSetup or bSetup equel to 5, 11, 13, 15.
Can anyone solve the problem?
//+-------------------------------------------n-----------------------+//| MAB_TD_Sequential |//| v1.2 |//| |//| Indicator based off of Tom DeMarks' TD Sequential indicator as |//| described in Jason Perl's book "DeMark Indicators" |//| |//| 05/22/2009 - Created Buy and Sell Setup along with TDST lines |//| and set up criteria for arrow and alert to appear |//| for a perfect setup. |//| issues: TDST line starts updating before a full setup is |//| made |//| still needs: Countdown criteria |//| |//| 05/26/2009 - Added the Countdown criteria. Countdown will also|//| create a "+" when 13 is reach but not perfected. |//| still needs: Countdown recycle criteria(currently recycles |//| automatically when setup completed) | //+------------------------------------------------------------------+#property copyright""#property link""#property indicator_chart_window#property indicator_buffers6#property indicator_color1 Black
#property indicator_color2 Black
#property indicator_color3 Black
#property indicator_color4 Black
#property indicator_color5 Black
#property indicator_color6 Black
externcolor Setup=Black;
externcolor Countdown=Black;
externint NumBars=1000;
externint Space=50; //space above or below high to place numberexternbool Alerts=false;
double Support[], Resistance[], bPerfected[], sPerfected[], Buy[], Sell[];
datetime last_alert = 0;
#define SIGNAL_BAR 2//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
//---- indicators//TDST linesSetIndexBuffer(0,Support);
SetIndexStyle(0,DRAW_LINE, STYLE_DOT, 1);
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexBuffer(1,Resistance);
SetIndexStyle(1,DRAW_LINE, STYLE_DOT, 1);
SetIndexEmptyValue(1, EMPTY_VALUE);
//Perfected SetupSetIndexBuffer(2,bPerfected);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,217);
SetIndexBuffer(3,sPerfected);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,218);
//CountdownSetIndexBuffer(4,Buy);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,217);
SetIndexBuffer(5,Sell);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,218);
//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----for(int i=0;i<Bars;i++)
{
ObjectDelete(""+i);
ObjectDelete("cd"+i);
}
//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int start()
{
int counted_bars=IndicatorCounted();
int bSetup, sSetup, bCountdown, sCountdown;
int x;
double tfm=Space*Point;
bool bSetupInd, sSetupInd;
//----for(int i=NumBars; i>=0; i--)
{
ObjectDelete(""+i);
ObjectDelete("cd"+i);
//+------------------------------------------------------------------+//| Buy Setup |//+------------------------------------------------------------------+if(Close[i]<=Close[i+4] && Close[i+1]>=Close[i+5] && bSetup==0)//start setup
{
bSetup++;
// ObjectCreate(""+i,OBJ_TEXT,0,Time[i],Low[i]-tfm);// ObjectSetText(""+i,""+bSetup,8,"Arial",Setup);
}
if(Close[i]<Close[i+4] && bSetup!=0 && ObjectFind(""+i)==-1)
{
bSetup++;
if(bSetup==5)
{
ObjectCreate(""+i,OBJ_TEXT,0,Time[i],Low[i]-tfm);
ObjectSetText(""+i,9,10,"Arial Black",Blue);
bSetup=0;
bPerfected [i]=Low[i]-(WindowPriceMax()-WindowPriceMin() )/20;
bSetupInd=true;
sSetupInd=false;
sCountdown=0;
}
}
//Deletes numbers that were created if there is a break in sequence before 9 is reachedelseif(Close[i]>=Close[i+4] && bSetup!=0)
{
for(x=i+1; x<=i+bSetup-1; x++) ObjectDelete(""+x);
bSetup=0;
}
//+------------------------------------------------------------------+//| Sell Setup |//+------------------------------------------------------------------+if(Close[i]>=Close[i+4] && Close[i+1]<=Close[i+5] && bSetup==0)//start setup
{
sSetup++;
// ObjectCreate(""+i,OBJ_TEXT,0,Time[i],High[i]+tfm);// ObjectSetText(""+i,""+sSetup,8,"Arial",Setup);
}
if(Close[i]>=Close[i+4] && sSetup!=0) //&& ObjectFind(""+i)==-1)
{
sSetup++;
if(sSetup==5)
{
ObjectCreate(""+i,OBJ_TEXT,0,Time[i],High[i]+(WindowPriceMax()-WindowPriceMin() )/20);//+tfm);
ObjectSetText(""+i,9,10,"Arial Black",Red);
sSetup=0;
sPerfected [i]=High[i]+(WindowPriceMax()-WindowPriceMin())/20;
sSetupInd=true;
bSetupInd=false;
bCountdown=0;
}
}
//Deletes numbers that were created if there is a break in sequence before 9 is reachedelseif(Close[i]<=Close[i+4] && sSetup!=0)
{
for(x=i+1; x<=i+sSetup-1; x++) ObjectDelete(""+x);
sSetup=0;
}
}
//----////Print( bPerfected[SIGNAL_BAR-1]," ",sPerfected[SIGNAL_BAR]);staticint PrevSignal = 0, PrevTime = 0;
if(SIGNAL_BAR > 0 && Time[0] <= PrevTime )
return(0);
PrevTime = Time[0];
if(PrevSignal <= 0)
{
/////////Buy Alert //////////////////////////////////////////if(bPerfected[SIGNAL_BAR] > 0 && bPerfected[SIGNAL_BAR]!=2147483647)
{
PrevSignal = 1;
Alert("", Symbol(), ", ", Period(), " - BUY!!!");
}
}
///////////Sell Alert//////////////////////////////////////////if(PrevSignal >= 0)
{
if(sPerfected[SIGNAL_BAR]>0 && sPerfected[SIGNAL_BAR]!=2147483647)
{
PrevSignal = -1;
Alert("", Symbol(), ", ", Period(), " - SELL!!!");
}
}
return(0);
};
//+------------------------------------------------------------------+
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Can anyone solve the problem?