Wavetrend Buy Sell Formula rule..help please

#1
Dear Friends

This is wavetrend formula.I want to ad one rule for buy sell.

Rule for Buy: Wavetrend1 cross "0" AND if buy , when prices increased 0.5% .If dont increades 0.5 and more dont buy

Rule for Sell: "0" cross wavetrend 1 AND if sell ,when price decreased 0.5% .If dont decreased 0.5% and more dont sell




How to add this rules ?

SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkGrey),ParamColor("Lower Chart",colorDarkGrey));
GraphXSpace = Param("GraphXSpace",7,0,20,0.5);

_SECTION_BEGIN("WaveTrend");
OptimizerSetEngine("cmae");
Period = Param( "Period", 10, 1, 200, 1 ); // Channel periods default is 10.
AvgPeriod = Param ( "AvgPeriod", 20, 1, 200, 1 ); // Average periods default is 21.
Period = Optimize ( "Period", 10, 1, 200, 1 ); // Channel periods default is 10.
AvgPeriod = Optimize( "AvgPeriod", 20, 1, 200, 1 ); // Average periods default is 21.
AP = Avg; // Typical Price = ( High + Low + Close ) / 3
ESA = Wilders(AP, Period);
D = Wilders(abs(AP - ESA), Period);
CI = (AP - ESA) / (0.015 * D);

WaveTrend1 =EMA(CI, AvgPeriod); // Gold Color ( BUY )
WaveTrend2 = MA(WaveTrend1,4); // Turquoise Color ( SELL )

Plot(WaveTrend1,"WaveTrend1",colorGold,styleDots | styleThick);
Plot(WaveTrend2,"WaveTrend2",colorTurquoise,styleDots);

Buy=Cross(Wavetrend1,0);
Sell = Cross(0, Wavetrend1);

//Buy=Cross(Wavetrend1,-60)OR Cross(Wavetrend1,-40) OR Cross(Wavetrend1,-20) OR Cross(Wavetrend1,0) OR Cross(Wavetrend1,20) OR Cross(Wavetrend1,40) OR Cross(Wavetrend1,60);
//Sell = Cross(60, Wavetrend1)OR Cross(40, Wavetrend1)OR Cross(20, Wavetrend1)OR Cross(0, Wavetrend1)OR Cross(-20, Wavetrend1)OR Cross(-40, Wavetrend1)OR Cross(-60, Wavetrend1);
Short=Sell;
Cover=Buy;

Plot(0,"",colorBlue,styleNoLabel);

Plot( -60 , "", colorGreen,styleDashed);
Plot( -50 , "", colorGreen,styleDashed);
Plot( 50 , "", colorRed,styleDashed);
Plot( 60 , "", colorRed,styleDashed);

_SECTION_END();

Title=EncodeColor(colorYellow)+ Name()+ EncodeColor(colorLime) +" Wavetrend " + EncodeColor(colorPaleTurquoise) +"(" +Period+ ") = " + EncodeColor(colorWhite) + WaveTrend1;

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;

bbt = BBandTop( P, Periods, Width );
bbb = BBandBot( P, Periods, Width );

PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, colorDarkGrey, 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();
 
#3
hi tugiacar

It seems you were waiting with hope to get your problem solved.
Our experts here will try to help.just have patience.

First thing
your rules are not defined correctly as I feel.
what instrument do you like to trade-stocks or futures?
what time frame do you like to use your formula?

not mentioned.
you included bollinger bands but used price instead of wavetrend1.
Price rise in how many bars-may be needed.it helps

Can you test the method in future zone for 30 trades and confirm your rules are really good enough?
Futurezone is the data zone that lies beyond right edge of your chart.it is unknown & invisible at the start.
UNless yuu test in future zone ,you really never know if your method has winning edge or not.


If you are Amibroker user,you know it when you run bar replay tool and observe how price changes at right edge of chart as time passes.
If you are trying to look at leftside of chart and test based on visible past history then you ar possibly on wrong track.
test based on just rules and rules alone on your selected timeframe as new prices come into visibility.
can you do that and finalise your rules?
It looks like you try to buy when WT1 CROSS ABOVE -60 AND SELL WHEN WT1 CROSS BELOW 60.
IF you dont test you will have many many rules & most may be useless. Reduce these rules to 4 or 5.
Hope you can.

HTML:
Ruleset
BUY
WT1 cross WT2(Goldline above Aqua line)
WT1  above zero line
price rise>0.5%

SELL
WT1 cross below WT2
WT1<ZEROLINE
PRICE FALL>0.5%
see chart attached.
 
Last edited:
#4
Thank You ford7k

I've been happy with your explanations.As I understood the problem.

I tested 6 months this formula with 15 minutes chart.with the default settings

And results are not bad . I know need to do more tests.Therefore, would make testing with formula

I apply the simple rules;

Ruleset
BUY
WT1 > 0 line (Goldline above 0 line )
price rise>0.25% ( when WT1 > "0" price must be above 0.25% compared to the previous bar if not above %0,25 dont buy

Example = WT1 > "0" line
close price 97250 before bar 97150 (under 0 line ...this bar price important for us) DONT BUY..WAİT
next bar close price 97300 DONT BUY... WAIT ( price is not greater than %0,25 from 97150)
next bar close price 97250 DONT BUY... WAIT (price is not greater than %0,25 from 97150)
next bar close price 97450... BUY (97450 greater than %0,25 from 97150).WT1 have to above "0" line

SELL
WT1 < "0" line
PRICE FALL>0.25% ( when WT1 < "0" price must be under 0.25% compared to the previous bar if not under %0,25 dont sell


Rules are simple but my english poor so may be this reason I can not good explain
 
#5
Wavetrend and many other indicators are the indicators which simply oscillate between OVERBOUGHT and OVERSOLD zones............its not as simple as the indicator trys to show u that stock is in OVERBOUGHT zone and look for selling and viceversa..........market and trading is much much beyond OB/OS levels.
 
#6
hi tugiacar

here is the code
first stage = code streamlining
second stage= exploration and search signals for buy and sell using Amibroker

the code is here but not yet perfect-need time to settle things

HTML:
//code request by  tugiacar-user timeframe 15minute chart
//version 1.0

grid_day = IIf(Day()!=Ref(Day(),-1),1,0);  
Plot(grid_day,"",colorOrange,styleHistogram|styleDashed|styleNoLabel|styleOwnScale);
//==========================


SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkGrey),ParamColor("Lower Chart",colorDarkGrey));
GraphXSpace = Param("GraphXSpace",7,0,20,0.5);

_SECTION_BEGIN("WaveTrend");
OptimizerSetEngine("cmae");
Period = Param( "Period", 10, 1, 200, 1 ); // Channel periods default is 10.
AvgPeriod = Param ( "AvgPeriod", 20, 1, 200, 1 ); // Average periods default is 21.
Period = Optimize ( "Period", 10, 1, 200, 1 ); // Channel periods default is 10.
AvgPeriod = Optimize( "AvgPeriod", 20, 1, 200, 1 ); // Average periods default is 21.
AP = Avg; // Typical Price = ( High + Low + Close ) / 3
ESA = Wilders(AP, Period);
D = Wilders(abs(AP - ESA), Period);
CI = (AP - ESA) / (0.015 * D);

WaveTrend1 =EMA(CI, AvgPeriod); // Gold Color ( BUY )
WaveTrend2 = MA(WaveTrend1,4); // Turquoise Color ( SELL )

Plot(WaveTrend1," gold-WaveTrend1-EMA10 of(avg-wilders)",colorGold,styleDots | styleThick);
Plot(WaveTrend2," blue-WaveTrend2 =SMOOTH OF WT1",colorTurquoise,styleDots);

Plot(0,"",colorBlue,styleNoLabel);

Plot( -60 , "", colorGreen,styleDashed);
Plot( -50 , "", colorGreen,styleDashed);
Plot( 50 , "", colorRed,styleDashed);
Plot( 60 , "", colorRed,styleDashed);

_SECTION_END();

Title=EncodeColor(colorYellow)+ Name()+ EncodeColor(colorLime) +" Wavetrend " + EncodeColor(colorPaleTurquoise) +"(" +Period+ ") = " + EncodeColor(colorWhite) + WaveTrend1;

_SECTION_BEGIN("Bollinger Bands");
P1 = wavetrend1 ;
Periods1 = 10; 
Width = 2;//Param("Width", 2, 0, 10, 0.05 );
Color = colorLightGrey;//ParamColor("Color", colorLightGrey );
Style = styleThick;//ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;

bbt = BBandTop( Wavetrend1, Periods1, Width );
bbb = BBandBot( Wavetrend1, Periods1, Width );

PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, colorDarkGrey, 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END(); 
PCTRISE =ROC(C,1)>0.25;
Line1=0;
kku =100*(C-Ref(C,-1))/C ;
kkd =100*(Ref(C,-1)-C)/C ;

Buy = Cross(WaveTrend1, Line1) AND kku>0.25;

Sell = Cross(Line1,WaveTrend1 )  AND kkd >0.25;
Short=Sell;
Cover=Buy;


Buy =ExRem(Buy,Sell); Sell =ExRem(Sell,Buy);





PlotShapes(IIf(Buy, shapeUpArrow , shapeNone), colorGreen);
PlotShapes(IIf(Sell, shapeDownArrow , shapeNone), colorRed);
Danger with bounded indicators
All ob-os overbought oversold indicators have a basic problem.
It is that in a strong uptrend they give more SELL signals and in a strong downtrend,the indicators give lot of BUY signals
At the end of the day,you will be pushed out of the market when real movemnt starts in your favour.
Not ready to believe me? just check stochastics signals.
 
#7
Dear Friends

This is wavetrend formula.I want to ad one rule for buy sell.


Wavetrend with buy-sell arrows, Try it :clap:

Code:
_SECTION_BEGIN("Wavetrend with Buy-sell arrows");
ChannelPeriods = Param("Channel Periods",10,1,50,1);
AvgPeriods = Param("Average Periods",31,1,50,1);
OverBought = Param("Over Bought Line",64,0,100,1);
OverSold = Param("Over Sold Line",-64,-100,0,1);
ColTCI = ParamColor("TCI Line Color",colorBrown);
ColOB = ParamColor("Over Bought Color",colorRed);
ColOS = ParamColor("Over Sold",colorGreen);
XSpace = Param("GraphXSpace",7,0,20,0.5);

n1 = ChannelPeriods; // Channel periodsdefault is 10.
n2 = AvgPeriods; // Average periodsdefault is 31.

AP = Avg; //Typical Price
ESA = EMA(AP, n1);
D = EMA(abs(AP - ESA), n1);
CI = (AP - ESA) / (0.015 * D);
TCI = EMA(CI, n2);

WaveTrend1 = TCI;
WaveTrend2 = MA(WaveTrend1,4);

myColor = 
IIf (WaveTrend1 > WaveTrend2, colorLavender,
IIf (WaveTrend2 > WaveTrend1, colorRed ,colorLightYellow));

Plot(WaveTrend1,"WaveTrend ",myColor,styleDots | styleThick);

//Plot(WaveTrend2,"WaveTrend2",colorLightYellow,styl eDashed); 
Plot(WaveTrend2,"WaveTrend2",ParamColor("Signal Line color", colorPaleBlue),styleDots); 

Plot(OverBought,"OB Line",ColOB,8+16);//|styleNoLabel);//8+16
Plot(OverSold,"OS Line",ColOS,8+16);//|styleNoLabel);
Plot(n1,"Channel Periods",colorBlue,styleNoLabel |styleNoRescale |styleNoDraw);
Plot(n2,"Avg Periods",colorBlue,styleNoLabel |styleNoRescale | styleNoDraw);
Plot(0,"0",colorRed,styleNoLabel);
//Plot(100,"",9 ,styleOwnScale | styleArea | styleNoLabel,-5,100);
//Background pane coloring

GraphXSpace = XSpace; 

_SECTION_END();

_SECTION_BEGIN("Buy Sell Signal");
x = WaveTrend1;
y = WaveTrend2;
 
Buy=Cross(x,y);
Sell=Cross(y,x);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

PlotShapes(shapeUpArrow*Buy,colorGreen);
PlotShapes(shapeDownArrow*Sell,colorRed);
_SECTION_END ();


Enjoy , Happy n safe trading:clapping:
 

Vipul_84

Well-Known Member
#8
Slightly different wave trend indicator as it plots in BB than in OB/OS zones
(COPIED FROM FIRST POST)
===================

SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkGrey),ParamColor("Lower Chart",colorDarkGrey));
GraphXSpace = Param("GraphXSpace",7,0,20,0.5);

_SECTION_BEGIN("WaveTrend");
OptimizerSetEngine("cmae");
Period = Param( "Period", 10, 1, 200, 1 ); // Channel periods default is 10.
AvgPeriod = Param ( "AvgPeriod", 20, 1, 200, 1 ); // Average periods default is 21.
Period = Optimize ( "Period", 10, 1, 200, 1 ); // Channel periods default is 10.
AvgPeriod = Optimize( "AvgPeriod", 20, 1, 200, 1 ); // Average periods default is 21.
AP = Avg; // Typical Price = ( High + Low + Close ) / 3
ESA = Wilders(AP, Period);
D = Wilders(abs(AP - ESA), Period);
CI = (AP - ESA) / (0.015 * D);

WaveTrend1 =EMA(CI, AvgPeriod); // Gold Color ( BUY )
WaveTrend2 = MA(WaveTrend1,4); // Turquoise Color ( SELL )

Plot(WaveTrend1,"WaveTrend1",colorGold,styleDots | styleThick);
Plot(WaveTrend2,"WaveTrend2",colorTurquoise,styleD ots);

Buy=Cross(Wavetrend1,0);
Sell = Cross(0, Wavetrend1);

//Buy=Cross(Wavetrend1,-60)OR Cross(Wavetrend1,-40) OR Cross(Wavetrend1,-20) OR Cross(Wavetrend1,0) OR Cross(Wavetrend1,20) OR Cross(Wavetrend1,40) OR Cross(Wavetrend1,60);
//Sell = Cross(60, Wavetrend1)OR Cross(40, Wavetrend1)OR Cross(20, Wavetrend1)OR Cross(0, Wavetrend1)OR Cross(-20, Wavetrend1)OR Cross(-40, Wavetrend1)OR Cross(-60, Wavetrend1);
Short=Sell;
Cover=Buy;

Plot(0,"",colorBlue,styleNoLabel);

Plot( -60 , "", colorGreen,styleDashed);
Plot( -50 , "", colorGreen,styleDashed);
Plot( 50 , "", colorRed,styleDashed);
Plot( 60 , "", colorRed,styleDashed);

_SECTION_END();

Title=EncodeColor(colorYellow)+ Name()+ EncodeColor(colorLime) +" Wavetrend " + EncodeColor(colorPaleTurquoise) +"(" +Period+ ") = " + EncodeColor(colorWhite) + WaveTrend1;

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;

bbt = BBandTop( P, Periods, Width );
bbb = BBandBot( P, Periods, Width );

PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, colorDarkGrey, 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();
 

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?