Simple Coding Help - No Promise.

pratapvb

Well-Known Member
i am trading in 15m tf with a system in which multitf support is taken from daily ...............
now i apply same system on 5m tf .............and i need that signal of 15m tf to be shown in 5m tf ................it may be inform of a ribbon also .........or in shapes also.............is here also gfx function is use or any other function ............
how it can be done .............any reference link plz ..............
should be just timeframeset to 15min...do calculation....and then timeframeexpand to 5min and show on 5min
 
Can anyone please help me with plotting High/Low lines of the currently selected bar? Also option to turn this off will make it perfect.

I am thinking SELECTEDVALUE & LINEARRAY might useful, but not a programmer so...

I will then use this code to implement in my current chart so I do not need any other plots. Just plot H-L lines where the cursor lays.

Thanks in advance.
 
Last edited:
hello, happy singh

i am trying to add an exploration to the sequential system AFL but cant seem to get it properly executed.

what i want is :

the exploration should find stocks that has " EOD close" value with in +-3% of tdst support\blue\buy line or with in +-3% of tdst resistance\red\sell line.

any help will be appriciated.

the full afl is below

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C;

_SECTION_END();

_SECTION_BEGIN("TD Systems");
// Parameters
ShowNumbers= ParamToggle("Show 1-8 Numbers","No|Yes", 1);
ShowTDPoints = ParamToggle("Show TD Points", "No|Yes", 1);
ShowTDST = ParamToggle("Show TD Setup Trend", "No|Yes", 1);
ShowBuyCountDown = ParamToggle("Show Buy TD CountDown", "No|Yes", 0);
ShowSellCountDown = ParamToggle("Show Sell TD CountDown", "No|Yes", 0);
tdstsa = 0;
tdstba = 0;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//********************************************** TD Points******************************************** ************************/
function TD_Supply()
{
return ( H > Ref(H, 1) AND H > Ref(H, -1) AND H > Ref(C, -2));
}
function TD_Demand()
{
return ( L < Ref(L, 1) AND L < Ref(L, -1) AND L < Ref(C, -2));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *********************************************** TD Sequential**************************************** ********************/
// *** Setup Buy Signal ***
//nine consecutive days closes less than the close four days earlier
Con = C < Ref( C, -4);
Buy9Bars = BarsSince(BarsSince(Con));
Buy9Signal = Buy9Bars == 9;

// *** Requirements ***
//The first day of the nine-day must be preceded by a close day immediately before it that is greater than OR equal to the Close four days earlier
Con = Ref(C, -9) >= Ref(C, -13);
Buy9Req = Buy9Signal AND Con;

// *** Intersection ***
// the high of either day 8 or day 9 is greater than or equal to the low three,four, five, six, OR seven days earlier
Con1 = (H >= Ref(L, -3)) OR ( Ref(H, -1) >= Ref(L, -3));
Con2 = (H >= Ref(L, -4)) OR ( Ref(H, -1) >= Ref(L, -4));
Con3 = (H >= Ref(L, -5)) OR ( Ref(H, -1) >= Ref(L, -5));
Con4 = (H >= Ref(L, -6)) OR ( Ref(H, -1) >= Ref(L, -6));
Con5 = (H >= Ref(L, -7)) OR ( Ref(H, -1) >= Ref(L, -7));

Buy9Intr = Buy9Req AND (Con1 OR Con2 OR Con3 OR Con4 OR Con5);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *** Setup Sell Signal ***
//nine consecutive days closes greater than the Close four days earlier.
Con = C > Ref( C, -4);
Sell9Bars = BarsSince(BarsSince(Con));
Sell9Signal = Sell9Bars == 9;

// *** Requirements ***
//The first day of the nine-day must be preceded by a Close day immediately before it that is less than the Close four days earlier
Con = Ref(C, -9) < Ref(C, -13);
Sell9Req = Sell9Signal AND Con;

// *** Intersection ***
//the low of either day 8 or day 9 is less than or equal to the high three,four, five, six, OR seven days earlier
Con1 = (L <= Ref(H, -3)) OR ( Ref(L, -1) <= Ref(H, -3));
Con2 = (L <= Ref(H, -4)) OR ( Ref(L, -1) <= Ref(H, -4));
Con3 = (L <= Ref(H, -5)) OR ( Ref(L, -1) <= Ref(H, -5));
Con4 = (L <= Ref(H, -6)) OR ( Ref(L, -1) <= Ref(H, -6));
Con5 = (L <= Ref(H, -7)) OR ( Ref(L, -1) <= Ref(H, -7));

Sell9Intr = Sell9Req AND (Con1 OR Con2 OR Con3 OR Con4 OR Con5);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(StrToNum(NumToStr(Buy9Intr))) Sell9Intr = False;
if(StrToNum(NumToStr(Sell9Intr))) Buy9Intr = False;
BuySignal = Flip(Buy9Intr, Sell9Intr);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *** Buy Countdown ***
//With respect to a pending Buy Signal, the close must be less than the low two days earlier
Con = C < Ref(L, -2);
Buy13Count = Sum(Con AND BuySignal, BarsSince(Buy9Intr));
Buy13Signal = Buy13Count == 13;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *** Sell Countdown ***
//with respect to a pending Sell Signal, the Close must be greater than the High two trading days earlier.
Con = C > Ref(H, -2);
Sell13Count = Sum(Con AND NOT BuySignal, BarsSince(Sell9Intr));
Sell13Signal = Sell13Count == 13;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************** TD Sequential Plotting area********************************************** ***/
Plot(C, "", IIf(O>=C, colorRed, colorGreen), styleBar);
PlotShapes(IIf(Buy9Intr OR Sell9Intr, shapeDigit9, shapeNone),colorBlue, 0, H, 20);
// Print Setup
if(ShowNumbers)
PlotShapes(IIf(Buy9Bars==1, shapeDigit1,
IIf(Buy9Bars==2, shapeDigit2,
IIf(Buy9Bars==3, shapeDigit3,
IIf(Buy9Bars==4, shapeDigit4,
IIf(Buy9Bars==5, shapeDigit5,
IIf(Buy9Bars==6, shapeDigit6,
IIf(Buy9Bars==7, shapeDigit7,
IIf(Buy9Bars==8, shapeDigit8,
IIf(Buy9Bars >9, shapeStar,shapeNone))))))))),colorGreen, 0, H, 10);
if(ShowNumbers)
PlotShapes(
IIf(Sell9Bars==1, shapeDigit1,
IIf(Sell9Bars==2, shapeDigit2,
IIf(Sell9Bars==3, shapeDigit3,
IIf(Sell9Bars==4, shapeDigit4,
IIf(Sell9Bars==5, shapeDigit5,
IIf(Sell9Bars==6, shapeDigit6,
IIf(Sell9Bars==7, shapeDigit7,
IIf(Sell9Bars==8, shapeDigit8,
IIf(sell9bars>9, shapeStar,shapeNone))))))))),colorRed, 0, H, 10);
// Print Countdown
if(ShowBuyCountDown)
PlotShapes(IIf(Buy13Count==1, shapeDigit1,
IIf(Buy13Count==2, shapeDigit2,
IIf(Buy13Count==3, shapeDigit3,
IIf(Buy13Count==4, shapeDigit4,
IIf(Buy13Count==5, shapeDigit5,
IIf(Buy13Count==6, shapeDigit6,
IIf(Buy13Count==7, shapeDigit7,
IIf(Buy13Count==8, shapeDigit8,
IIf(Buy13Count==9, shapeDigit9,shapeNone))))))))),colorGrey50, 0, L, -20);
if(ShowBuyCountDown)
PlotShapes(IIf(Buy13Count==10, shapeDigit0,
IIf(Buy13Count==11, shapeDigit1,
IIf(Buy13Count==12, shapeDigit2,
IIf(Buy13Count==13, shapeDigit3,shapeNone)))),colorBlue, 0, L, -20);
if(ShowSellCountDown)
PlotShapes(IIf(Sell13Count==1, shapeDigit1,
IIf(Sell13Count==2, shapeDigit2,
IIf(Sell13Count==3, shapeDigit3,
IIf(Sell13Count==4, shapeDigit4,
IIf(Sell13Count==5, shapeDigit5,
IIf(Sell13Count==6, shapeDigit6,
IIf(Sell13Count==7, shapeDigit7,
IIf(Sell13Count==8, shapeDigit8,
IIf(Sell13Count==9, shapeDigit9,shapeNone))))))))),colorGrey50, 0, L, -40);
if(ShowSellCountDown)
PlotShapes(IIf(Sell13Count==10, shapeDigit0,
IIf(Sell13Count==11, shapeDigit1,
IIf(Sell13Count==12, shapeDigit2,
IIf(Sell13Count==13, shapeDigit3,shapeNone)))),colorBlue, 0, L, -40);

Sell = Sell13Signal AND NOT BuySignal;
Buy = Buy13Signal AND BuySignal;
Sell = ExRem(Sell, Buy);
Buy = ExRem(Buy, Sell);

PlotShapes(Sell*shapeCircle, colorBlue, 0, H, 25);
PlotShapes(Sell*shapeDownArrow, colorRed, 0, H, -40);

PlotShapes(Buy*shapeCircle, colorBlue, 0, L, -5);
PlotShapes(Buy*shapeUpArrow, colorGreen, 0, L, -20);

//if(StrToNum(NumToStr(BuySignal)))
//bgColor = ColorRGB(0,66, 2);
//else
//bgColor = ColorRGB(66,2, 0);
//SetChartBkGradientFill( colorBlack, bgColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************** TD Points Plotting area********************************************** ***/

if(ShowTDPoints)
{
PlotShapes(TD_Supply()*shapeSmallCircle, colorRed, 0, H, H*.001);
PlotShapes(TD_Demand()*shapeSmallCircle, colorGreen, 0, L, -L*.001);
///////////////////////////////////////////////////////////////////////////
y0 = StrToNum(NumToStr(ValueWhen(TD_Demand(), L)));
x = LineArray(0, y0, (BarCount-1), y0);
Plot(x, "", colorGold, styleDashed);
y0 = StrToNum(NumToStr(ValueWhen(TD_Supply(), H)));
x = LineArray(0, y0, (BarCount-1), y0);
Plot(x, "", colorGold, styleDashed);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************** TDST Plotting area *************************************************/
// ---------------->>>> Code from Dave <<<---------------------- //
if(ShowTDST)
{
tdstba =Cum(0);
tdstb = Null;
HHV9 = HHV(H,9);
for (i = 0; i < 10; i++) tdstba = Null;

for( i = 10; i < BarCount; i++ )
{
if (Buy9Bars == 9)
{
HHV_b = HHV9;
if (HHV_b > C[i-9])
tdstb = HHV_b;
else tdstb = C[i-9];

for (j = 0; j < 9; j++ )
tdstba[i-j] = tdstb;
}
else tdstba = tdstb;
}

tdstsa =Cum(0);
tdsts = Null;
LLV9 = LLV(L,9);
for (i = 0; i < 10; i++) tdstsa = Null;

for( i = 10; i < BarCount; i++ )
{
if (Sell9Bars == 9)
{
LLV_b = LLV9;
if (LLV_b < C[i-9])
tdsts = LLV_b;
else tdsts = C[i-9];

for (j = 0; j < 9; j++ )
tdstsa[i-j] = tdsts;
}
else tdstsa = tdsts;
}
Plot(tdstba, "TDSTb", colorBlue,styleStaircase | styleThick|styleDots);
Plot(tdstsa, "TDSTs", colorRed,styleStaircase | styleThick|styleDots);

}
_SECTION_END();

Regards
Ritesh banfa
 
Can anyone please help me with plotting High/Low lines of the currently selected bar? Also option to turn this off will make it perfect.

I am thinking SELECTEDVALUE & LINEARRAY might useful, but not a programmer so...

I will then use this code to implement in my current chart so I do not need any other plots. Just plot H-L lines where the cursor lays.

Thanks in advance.
Just replace SELECTEDVALUE(H) and SELECTEDVALUE(L) in the plot statements . . . rest is same

for on / off

put both the plots inside an if condition


Code:
if (ParamToggle("Plot HI LO","NONE|YES",1))
{
	Plot(SelectedValue(H), "High", colorGreen, styleThick,0,0,10);  	
	Plot(SelectedValue(L), "Low", colorRed, styleThick,0,0,10);  	
}

:) Happy
 
Happy,

Assume there is a signal bar, and I will to go long over it's high. Without looping, is there a way to identify the bar that triggers the long? Need this to make backtesting more efficient.

In case this is already answered in this thread, please let me know. I'll search it out.

Rewording: i want to find the bar whose high is higher than the current bar's high.
augubhai


Code:
MyTriggerCondition = XYZCondition;
TradeTrigeredOnTouch = High > ValueWhen(MyTriggerCondition, High); 
TradeTrigeredOnClosingBasis = Close > ValueWhen(MyTriggerCondition, High);
In case of second condition, you may want to Ref ... -1 the whole thing ..
 
Perfect! Thanks a bunch!!! :clap:

Just replace SELECTEDVALUE(H) and SELECTEDVALUE(L) in the plot statements . . . rest is same

for on / off

put both the plots inside an if condition


Code:
if (ParamToggle("Plot HI LO","NONE|YES",1))
{
	Plot(SelectedValue(H), "High", colorGreen, styleThick,0,0,10);  	
	Plot(SelectedValue(L), "Low", colorRed, styleThick,0,0,10);  	
}

:) Happy
 

zabeen2004

Well-Known Member
Hi Happy Singh,

Would you be helping in setting up an buy/sell alert in MT4 indicator with SL. I am not knowledgeable in MT4 but I have the ideas and an indicator which works much more comfortable for me in Scalping. I would be more than happy if you could help in setting up the alerts... Please reply when time permits

Thanks
 
Another simple question...

I want to plot plain text on a bar -- either below Low or above High. I looked at the PlotText function and I cannot understand how to apply.

Thanks in advance.

EDIT: Ok I figured out how to plot the text. Now how do I stack different texts at different distances from High/Low? The texts are from different indicators so cannot use "\n" See example below...

a
b
c
[] <-- Bar
 
Last edited:

Similar threads