Traderji.com - Discussion forum for Stocks Commodities & Forex

Bar Delay in Trading System

Discuss Bar Delay in Trading System at the MetaStock within the Traderji.com - Discussion forum for Stocks Commodities & Forex; I´m putting together a trading system to generate buy and sell signals (only operating long) ...


Go Back   Traderji.com - Discussion forum for Stocks Commodities & Forex > TOOLS & RESOURCES > Software > MetaStock

Notices


Advertise Here

Reply
 
Thread Tools
Sponsored Links
  #1  
Old 7th July 2007, 01:10 AM
Member
 
Join Date: Jun 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
traderbrazil is on a distinguished road
Reputation: 20
Default Bar Delay in Trading System

I´m putting together a trading system to generate buy and sell signals (only operating long) and I would appreciate if someone could help me with Metastock language.
How can I tell Metastock to buy or sell only if the following bar is not opposite to the first one?
Ex:
bar 1: buy signal
bar 2: buy signal
bar 3: execute buy

bar 1: buy signal
bar 2: sell signal
bar 3: ignore signal

Thanks a lot for your help!!!
Traderbrazil
Reply With Quote
  #2  
Old 8th July 2007, 03:48 AM
Member
 
Join Date: Jun 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
traderbrazil is on a distinguished road
Reputation: 20
Default Re: Bar Delay in Trading System

Hello SNIGDHA!!
Thanks for your reply although I´m not really familiar with MS language yet.
Below is the formula I'm using for buy signal:
C>Fml("Ehlers Distant Coefficient Filter")
If it´s not too much trouble for you please write down how I could use the if function attached to it with the delay (3rd bar buy if 2nd bar is not sell)

thanks a lot!
Traderbrazil
Reply With Quote
  #3  
Old 8th July 2007, 03:55 PM
Member
 
Join Date: Sep 2006
Location: Chennai
Posts: 914
Thanks: 3
Thanked 9 Times in 6 Posts
oxusmorouz will become famous soon enough
Reputation: 85
Default Re: Bar Delay in Trading System

Quote:
Originally Posted by traderbrazil View Post
Hello SNIGDHA!!
Thanks for your reply although I´m not really familiar with MS language yet.
Below is the formula I'm using for buy signal:
C>Fml("Ehlers Distant Coefficient Filter")
If it´s not too much trouble for you please write down how I could use the if function attached to it with the delay (3rd bar buy if 2nd bar is not sell)

thanks a lot!
Traderbrazil
Tools ---> Expert adviser ---> new ---> Name it ---> Symbol ---> New

Name : Long Enter
Condition:
a:= Fml("Ehlers Distant Coefficient Filter");
b:= Sum( C > a,2) = 2;
d:= Your Exit condition {Say, C < a};
f:= If(BarsSince(b) < BarsSince(d),1,0);
f > Ref(F,-1);


Name: Long Exit
Condition:
a:= Fml("Ehlers Distant Coefficient Filter");
b:= Sum( C > a,2) = 2;
d:= Your Exit condition {Say, C < a};
f:= If(BarsSince(b) > BarsSince(d),1,0);
f > Ref(F,-1);

Name : Short Enter
Condition:
a:= Fml("Ehlers Distant Coefficient Filter");
b:= Sum( C < a,2) = 2;
d:= Your Exit condition {Say, C > a};
f:= If(BarsSince(b) < BarsSince(d),1,0);
f > Ref(F,-1);

Name: Short Exit
Condition:
Condition:
a:= Fml("Ehlers Distant Coefficient Filter");
b:= Sum( C < a,2) = 2;
d:= Your Exit condition {Say, C > a};
f:= If(BarsSince(b) > BarsSince(d),1,0);
f > Ref(F,-1);

Regards.

Last edited by oxusmorouz; 8th July 2007 at 04:02 PM.
Reply With Quote
  #4  
Old 10th July 2007, 11:15 PM
Member
 
Join Date: Jun 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
traderbrazil is on a distinguished road
Reputation: 20
Default Re: Bar Delay in Trading System

Hello Oxusmorouz!

Thanks a lot for your input! I´ll try it out and let you know how it worked..

best regards,
traderbrazil
Reply With Quote
  #5  
Old 14th July 2007, 07:35 PM
Member
 
Join Date: Apr 2007
Posts: 78
Thanks: 1
Thanked 2 Times in 2 Posts
basudeo is on a distinguished road
Reputation: 27
Default Re: Bar Delay in Trading System

Hello oxusmorouz,

I find your answer very brilliant to the querry of traderbrazil.

I am new to metastock and shall be very grateful to know the answers of my innocent looking questions;

============================

po:=ref(o,-1);
pl:=ref(l,-1);
ph:=ref(h.-1);
pc:=ref(c,-1);

{fml1}
If(po>=pc,po+(po-pl),po-(ph-po));

{fml2}
if(po>pc,ph,
if(po<pc,pl,po));
================================

suppose signals are:

fml1>fml2 {buy}

fml1<fml2 {sell}

===============================


Que-1: In the above formula, I took all the datas of previous day. Suppose I take today's data and then change the formula as;-
ref(fml1,-1) & ref(fml2,-1)
Is there any difference between two?

Que-2: Is this formula alright to get tomorrow's signal? If not, please suggest the proper way to do the things.

Que-3:Please suggest the proper way to get signals through "EXPERT ADVISOR"; to get the list of stocks of prospect buy for the next day through "EXPLORER" and to test this on "ENHANCED SYSTEM TESTER".

BASUDEO
Reply With Quote
  #6  
Old 14th July 2007, 08:36 PM
Member
 
Join Date: Apr 2007
Posts: 78
Thanks: 1
Thanked 2 Times in 2 Posts
basudeo is on a distinguished road
Reputation: 27
Default Re: Bar Delay in Trading System

Hello OXUS,

I find your expert advice in most of the threads. I shall be very grateful if you please reply my query. I want to change my previous post as follows. Please plot this and give your expert opinion accordingly.

po:=Ref(O,-1);
pl:=Ref(L,-1);
ph:=Ref(H,-1);
pc:=Ref(C,-1);

fml1:=
If(po>=pc,po-(ph-pc),po+(pc-pl));

fml2:=
If(po>pc,pl,
If(po<pc,ph,po));

Mov(fml1,3,S);
Mov(fml2,8,S);

================================

suppose signals are:

fml1<fml2 {buy}

fml1>fml2 {sell}

===============================


Que-1: In the above formula, I took all the datas of previous day. Suppose I take today's data and then change the formula as;-
ref(fml1,-1) & ref(fml2,-1)
Is there any difference between two?

Que-2: Is this formula alright to get tomorrow's signal? If not, please suggest the proper way to do the things.

Que-3:Please suggest the proper way to get signals through "EXPERT ADVISOR"; to get the list of stocks of prospect buy for the next day through "EXPLORER" and to test this on "ENHANCED SYSTEM TESTER".

BASUDEO
Reply With Quote
  #7  
Old 14th July 2007, 09:40 PM
Member
 
Join Date: Sep 2006
Location: Chennai
Posts: 914
Thanks: 3
Thanked 9 Times in 6 Posts
oxusmorouz will become famous soon enough
Reputation: 85
Default Re: Bar Delay in Trading System

Quote:
Originally Posted by basudeo View Post
Hello OXUS,

I find your expert advice in most of the threads. I shall be very grateful if you please reply my query. I want to change my previous post as follows. Please plot this and give your expert opinion accordingly.

po:=Ref(O,-1);
pl:=Ref(L,-1);
ph:=Ref(H,-1);
pc:=Ref(C,-1);

fml1:=
If(po>=pc,po-(ph-pc),po+(pc-pl));

fml2:=
If(po>pc,pl,
If(po<pc,ph,po));

Mov(fml1,3,S);
Mov(fml2,8,S);

================================

suppose signals are:

fml1<fml2 {buy}

fml1>fml2 {sell}

===============================
Quote:
Originally Posted by basudeo View Post
Que-1: In the above formula, I took all the datas of previous day. Suppose I take today's data and then change the formula as;-
ref(fml1,-1) & ref(fml2,-1)
Is there any difference between two?
It seems appropriate to do so.

Quote:
Originally Posted by basudeo View Post
Que-2: Is this formula alright to get tomorrow's signal? If not, please suggest the proper way to do the things.
Yes. Since the delay is by one bar.
Quote:
Originally Posted by basudeo View Post
Que-3:Please suggest the proper way to get signals through "EXPERT ADVISOR"; to get the list of stocks of prospect buy for the next day through "EXPLORER" and to test this on "ENHANCED SYSTEM TESTER".

BASUDEO
If you have an idea in mind and want it coded, I'd be glad to assist you. However, a read of metastock formula premier for coding and use of tradesim for backtesting is recommended.

Sincerely yours.

Last edited by oxusmorouz; 14th July 2007 at 09:46 PM.
Reply With Quote
  #8  
Old 15th July 2007, 03:41 PM
Member
 
Join Date: Apr 2007
Posts: 78
Thanks: 1
Thanked 2 Times in 2 Posts
basudeo is on a distinguished road
Reputation: 27
Default Re: Bar Delay in Trading System

Hello OXUS,

Thank you so much for your such a prompt reply. I have slightly updated the formula. The revised formula is:

{NEUTRAL}

fml1:=If(O>(C*102/100),L,
If(O<(C*98/100),H,(O+C)/2));

Mov(Ref(fml1,-1),3,S);


{Volatile}

a:=C+L-O;
b:=C+H-O;
d:=2*O-H;
f:=2*O-L;
fml1:=If(O>=C,(a*d/f)*O/C,(b*f/d)*O/C);

Mov(Ref(fml1,-1),3,S);

{buy signal}cross(neutral,volatile)

{sell signal}cross(volatile,neutral)

{above formula only shows the trend and I dont know how to optimize it to pick most profitable troughs and peaks}
=============================

dear oxus, I have data upto 13/07/2007. I could not visualize as the bar of 13/07/2007 refers to the data of previous bar so what signal it gives. I mean the signal for 13/07/2007 or 14/07/2007. Where is the signal for actusal 13/07/2007 as the chart is not extending to next bar. If the bar of 13/07/2007 gives the signal for next bar by taking the data of the previous bar, why it is necesaary to take the data of the previous bar? This may seem very innocent but it is boggling me.

You please give a simple example of writing "expert advisor". When I tried to plot the signals I am getting the signal for the same bar and not the next bar.

Thanks a lot,

Basudeo
Reply With Quote
  #9  
Old 15th July 2007, 04:58 PM
Member
 
Join Date: Sep 2006
Location: Chennai
Posts: 914
Thanks: 3
Thanked 9 Times in 6 Posts
oxusmorouz will become famous soon enough
Reputation: 85
Default Re: Bar Delay in Trading System

Quote:
Originally Posted by basudeo View Post
Hello OXUS,

Thank you so much for your such a prompt reply. I have slightly updated the formula. The revised formula is:

{NEUTRAL}

fml1:=If(O>(C*102/100),L,
If(O<(C*98/100),H,(O+C)/2));

Mov(Ref(fml1,-1),3,S);


{Volatile}

a:=C+L-O;
b:=C+H-O;
d:=2*O-H;
f:=2*O-L;
fml1:=If(O>=C,(a*d/f)*O/C,(b*f/d)*O/C);

Mov(Ref(fml1,-1),3,S);

{buy signal}cross(neutral,volatile)

{sell signal}cross(volatile,neutral)

{above formula only shows the trend and I dont know how to optimize it to pick most profitable troughs and peaks}
=============================

dear oxus, I have data upto 13/07/2007. I could not visualize as the bar of 13/07/2007 refers to the data of previous bar so what signal it gives. I mean the signal for 13/07/2007 or 14/07/2007. Where is the signal for actusal 13/07/2007 as the chart is not extending to next bar. If the bar of 13/07/2007 gives the signal for next bar by taking the data of the previous bar, why it is necesaary to take the data of the previous bar? This may seem very innocent but it is boggling me.

You please give a simple example of writing "expert advisor". When I tried to plot the signals I am getting the signal for the same bar and not the next bar.

Thanks a lot,

Basudeo
The bar delay in metastock is used only for testing systems, not for scanning stocks. If you are to write the formula in expert advisor, try using the original code, without the bar delay. Since I use Tradesim for backtest, and since I haven't used metastock's backtester since last november, my knowledge with backtester is a bit shaky.

Regarding the expert advisor, here's an example of a moving average crossover (just an example...)

Tools ---> Expert adviser ---> new ---> Give it a name ---> Symbols ---> new

1) Name = Long Enter.

Formula:
a:= Mov(C,5,S); {Fast MA}
b:= Mov(C,8,S); {Slow MA}
Cross(a,b); {Condition}

2) Short Enter:

Formula:
a:= Mov(C,5,S); {Fast MA}
b:= Mov(C,8,S); {Slow MA}
Cross(b,a); {Condition}

x----------------------------------------x

Go to highlights ---> New

1) Name = Long Phase

Colour = Green

Formula:
a:= Mov(C,5,S); {Fast MA}
b:= Mov(C,8,S); {Slow MA}
BarsSince(a) < BarsSince(b); {Condition}

2) Name = Short Phase

Colour = Red

Formula:
a:= Mov(C,5,S); {Fast MA}
b:= Mov(C,8,S); {Slow MA}
BarsSince(a) > BarsSince(b); {Condition}

x--------------------------------------------------x

Writing commentary is a tricky part and pretty difficult as compared with coding. However, it isn't as important.

Sincerely yours.
Reply With Quote
Sponsored Links

Reply

Bookmarks


Advertise Here


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads for: Bar Delay in Trading System
Thread Thread Starter Forum Replies Last Post
Delay in Quotetracker RT aroonsankar Software 3 29th November 2007 05:35 PM
trading system for beginner oilman5 Technical Analysis 33 5th May 2007 11:51 AM
RMO Trading System raj69 Technical Analysis 1 27th December 2006 07:46 AM
sequential trading system gandhiadg Technical Analysis 4 13th August 2005 11:21 PM
Delay in displaying post neeraj4u Your Feedback & Suggestions 1 26th July 2005 09:50 AM


All times are GMT +5.5. The time now is 03:43 AM.

Indemnity, Disclaimer & Disclosure Notice:
• By visiting Traderji.com you indicate your acceptance of our Forum Rules Disclaimer & Disclosure and indemnify Traderji.com, its associates and related parties of all claims howsoever resulting from the usage of the forum.
Disclaimer: Trading or investing in stocks & commodities is a high risk activity. Any action you choose to take in the markets is totally your own responsibility. Traderji.com will not be liable for any, direct or indirect, consequential or incidental damages or loss arising out of the use of this information.
Disclosure: The information in this forum is neither an offer to sell nor solicitation to buy any of the securities mentioned herein. The writers may or may not be trading in the securities mentioned.
• All names or products mentioned are trademarks or registered trademarks of their respective owners.
General Content Disclaimer Notice:
In light of our policy of encouraging candid, open exchanges of views and the rapid distribution of information originating from many sources, Traderji.com cannot determine the accuracy of information that may be uploaded to the forum. Opinions, advice and all other information expressed by participants in discussions are those of the author. You rely on such information at your own risk. You are urged to seek professional advice for specific, individual situations and not rely solely on advice or opinions given in the discussions. Since Traderji.com is an open and free discussion forum, any comments made by members of this forum in their posts reflect their own views and not of the owner or administrator of Traderji.com. Thus the owner/administrator indemnify themselves of all claims whatsoever and will not be liable or responsible for any members comments/views in this forum Traderji.com. If you find any objectionable or offensive posts made by members of this forum which you would like to bring to our notice for removal then please Contact Us.
 


Copyright © 2001 - 2008, Traderji.com All Rights Reserved.

Recommended Websites - www.TradersEdgeIndia.com - www.TradingPicks.com - www.MasterOfTrading.com