logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
parimalp  
#1 Posted : Wednesday, February 8, 2012 12:36:15 PM(UTC)
parimalp

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/4/2011(UTC)
Posts: 7
Location: New Bombay, India

Hi,
I am new to MetaStock coding and have written my first "Expert Advisor" to generate Buy / Sell signals using EMA Crossover System basis whatever I have read in some of the Trading Books. (Posting this message again as I am not sure I had posted it correctly earlier).

Pls find below some information about me :
(i) I trade the Indian Markets and usually trade the Nifty Index (Options segment)
(ii) I use the Daily & 5-Minute Time Frames to monitor the Nifty-EQ Charts
(iii) I have recently started trading and initially thought Day Trading was my style but after going thru some of the books, i think Swing Trading would suit me better and feel it would also be more profitable.
(iv) I want to create an "Expert Advisor" which will give me Buy & Sell signals and also want to create a System Tester to check if the system is profitable or not.
(v) I have no prior experience of coding MS programme and have written the attached Expert by going through the Formula Primer. (I have so far found MS programming language to be quite easy "as long as one knows what he wants".)

The Expert that I have written is displaying the Buy & Sell signals on the Nifty chart. I have manually checked some of the signals and feel it is working fine. But before I start using the same, I wanted the assistance of this forum on the following :
(a) If an expert in MetaStock can Validate the coding that I have done and
(b) Help me understand as to how to create a System Tester for the coding that I have done

In the attached note, I have first given basic information on what I had in my mind while creating the 'Expert Advisor'.

Thanks in advance for your assistance.
henry1224  
#2 Posted : Wednesday, February 8, 2012 1:21:20 PM(UTC)
henry1224

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Hi, I can't open your attachment, so I don't know your code!

About your expert,
I'll assume that your system Plots +1 for a long position and -1 for a short position and 0 for when you take a neutral position.

In the enhanced system tester

you will see 4 tabs buy order, sell order, sell short order, and buy to cover order

in the buy order tab : enter your long entry code ie: System = 1 and Ref(System,-1) <> 1
in the sell order tab : enter your long Exit code ie: System <> 1 and Ref(System,-1) = 1
in the sell short order tab : enter your Short entry code ie: System = -1 and Ref(System,-1) <> -1
in the Buy to cover Tab : enter your Short Exit Code ie: System <> -1 and Ref(System,-1) =-1

A few words about the enhanced system tester, most advanced users of metastock will only use it as a basic tool. For a better results try TradeSim or VST Pro from Metastocktools.com

Metastock cannot test systems from 2 different time frames against each other nor can it use code for a daily bar chart and code for a 5 minute bar chart at the same time

Also in the future, please post your code, so that you can get the correct response that you are looking for.

you can also upload a chart to imgur.com and post the link in the forum
so that we can see the chart for further help




parimalp  
#3 Posted : Thursday, February 9, 2012 12:33:12 AM(UTC)
parimalp

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/4/2011(UTC)
Posts: 7
Location: New Bombay, India

Hi Henry,
Thnx for your prompt revert. I actually didn't expect such an immediate revert.

Had posted the message twice as I was not sure if I had posted it in the correct forum. Shall be careful h
enceforth.

Nope, I have not plotted +1 / -1 / 0 for Long / Short / Neutral position.
Since this is my first one, I tried to keep it simple (atleast I think so.....may be there are easier ways of writing codes). Pls have a look at the code, I have uploaded the same on 4shared.com. The link for the same is :
http://www.4shared.com/rar/xGe0XQRB/Exponential_Moving_Average_Cro.html

I have also uploaded the Nifty EQ Daily Chart in .xps, .gif & ,jpg formats. Pls use one of the links to download the same:
http://www.4shared.com/file/IY57iRDH/Nifty_EQ_-_Daily_Chart__08-02-.html
http://www.4shared.com/photo/atJKr1Nd/Nifty_EQ_-_Daily_Chart__08-02-.html
http://www.4shared.com/photo/KSKyO1uj/Nifty_EQ_-_Daily_Chart__08-02-.html

At the beginning of the code, I have explained the rules and what I wanted to achieve thru this expert. Kindly go thru the code and the chart and let me know your views. Do let me know if the code is correct and giving correct signals. Also, let me know how I can improve on the same further....may be if I should add some more rules, if required.

If you can, can you also help me on how to write the code for the following or alteast direct me to where I can get assistance on the same :
(i) How to exit the Long / Short trade entered (I am currently using the opposite signal generated to exit out of the trade).
(ii) Stop Loss
(iii) Target using ATR
(iv) Support (S1, S2, S3), Resistance (R1, R2, R3) & Pivot Point (PP) Lines
(v)
Automatic Trendlines,
(vi) Automatic Channel

(vii) which Candlesticks can be used to generate Buy / Sell signals and how to use them in expert
(viii) if any other indicators should be added to the system

Shall try out the suggestion for the enhanced system tester as well as the TradeSim & VST pro. Shall get back in case of any further queries.

As regards your suggestion "
....please post your code, so that you can get the correct response that you are looking for." Pls let me know how to do so as I do not know the process for the same.

Thnx Henry once again for your assistance. Really appreciate the same.

Regards,

Pankaj
henry1224  
#4 Posted : Thursday, February 9, 2012 12:36:14 PM(UTC)
henry1224

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Pan, I can't open the file for the ema cross,but I can view the charts.

First things first, I don't like to have to jump thru hoops to try and open a file. It's a waste of my time!
I also don't like to download any file from a file sharing site!

Posting code on this site is as easy as highlighting the code from an indicator, hit control C , go back to this site and click on an open part of the dialog and then hit control V

posting a chart, you can go to imgur.com create your profile and then upload your chart there and then copy the link into your post.

From your charts it seems that your ema's use some sort of forward reference because they are not showing any value on the last bar of the chart.

I recommend that if your code has any forward Ref( Mov(C,5,E),5) type of code to stop trading with it.

All moving averages create some sort of lag, meaning that price must move first before the average picks up from that move.

also they don't line up with the prices of the chart.

look at merging your indicator with the scale on the right when you plot an indicator
parimalp  
#5 Posted : Saturday, February 11, 2012 1:24:36 PM(UTC)
parimalp

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/4/2011(UTC)
Posts: 7
Location: New Bombay, India

Hi Henry,
Apologies for the delay in replying to your message. Your post somehow didn't hit my mail box and hence was wondering if you forgot to read my message. Was going to remind you today but saw your reply when I logged on to the forum.

Pls find the code below. I have made few additions to the code => Crossovers of Stoch (%K with %D).

I have not used any forward reference, though reference has been made to the previous bar to catch the PDI & MDi crossovers.

Have uploaded the charts on imgur.com. The links are as follows,
Nifty Daily Chart 1 : http://i.imgur.com/bmydW.png
Nifty Daily Chart 2 : http://i.imgur.com/SS9BQ.png
Nifty Daily Chart 3 : http://i.imgur.com/nld4m.png
Nifty Daily Chart 4 : http://i.imgur.com/8rZO7.png
Nifty Daily Chart 5 : http://i.imgur.com/223b3.png

Pls find a few details of the expert :

Normal 0 false false false EN-IN X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Calibri","sans-serif"; mso-bidi-font-family:"Times New Roman";}

1. The Buy & Sell Signals have been generated using the following :

a. Moving Average Crossovers with 3, 9, 18, 50, 100 & 200 EMAs,

b. ADX(14) >= 25 for crossovers of 3, 9 & 18 EMAs and ADX >= 20 for crossovers with 50, 100 & 200 EMAs,

c. PDI(14) & MDI(14) Crossovers and

d. %K & %D Crossovers [Stoch(5,3,3)]

2. Once a Buy Signal is generated on a Daily Chart, the trade will be entered only after the candle of the following day breaches the High of the previous day (i.e., the day on which the Buy signal was generated). Similarly, once a Sell Signal is generated on a Daily Chart, the trade will be entered only after the candle of the following day breaches the Low of the previous day (i.e., the day on which the Sell signal was generated).

3. If the system generates more than one Buy signal, the next buy signal is used to add to the Long position; while if more than one Sell signal is generated, the next Sell signal is used to add to the Short position.

4. This Expert also works on Intraday charts of 5-minutes and higher time frames. For 1-minute time frame, a lot of whipsaws take place.

5. I plan to use the same on the Daily Chart first (for generating the signals) and then use the 10-minute and/or 5-minute charts to enter or exit the trades.

6. Separate rules have not been written for exiting out of the Buy / Sell trade. Once a Sell signal is generated, it will be used as an exit from a Buy trade (generated earlier) and it will also be used to enter the Sell trade. Similarly, once a Buy signal is generated, it will be used as an exit from a Sell trade (generated earlier) and it will also be used to enter the Buy trade.

7. I don’t know how to write a code for setting a Stop Loss, Trailing Stop Loss and the Target in this system and was planning to do the same manually as follows :

a. Buy Signal : The Stop Loss & Trailing Stop Loss would be the Low of the previous 3 candles.

b. Sell Signal : The Stop Loss & Trailing Stop Loss would be the High of the previous 3 candles.

c. Buy Signal : The Target would be manually calculated using ATR => [Entry Point + (ATR Value x 2)].

d. Sell Signal : The Target would be manually calculated using ATR => [Entry Point - (ATR Value x 2)].


Expert :
*******************************************************************************************,
Normal 0 false false false EN-IN X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Calibri","sans-serif"; mso-bidi-font-family:"Times New Roman";}

1. Buy Signal 1 – Condition (L1 – Long 3 9) :

Cross( Mov(C, 3, E ) , Mov(C, 9, E ))

AND

(ADX(14) >= 25

OR

Cross(PDI(14),MDI(14))

OR

Ref(Cross(PDI(14),MDI(14)),-1))

2. Buy Signal 2 – Condition (L2 – Long 3 18) :

Cross(Mov(C, 3, E ) , Mov(C, 18, E ))

AND

(ADX(14) >= 25

OR

Cross(PDI(14),MDI(14))

OR

Ref(Cross(PDI(14),MDI(14)),-1))

3. Buy Signal 3 – Condition (L3 – Long 9 18) :

Cross(Mov(C, 9, E ) , Mov(C, 18, E ))

AND

(ADX(14) >= 25

OR

Cross(PDI(14),MDI(14))

OR

Ref(Cross(PDI(14),MDI(14)),-1))

4. Buy Signal 4 – Condition (L4 – Long 3 50) :

Cross( Mov(C, 3, E ) , Mov(C, 50, E ))

AND

(ADX(14) >= 20

OR

Cross(PDI(14),MDI(14))

OR

Ref(Cross(PDI(14),MDI(14)),-1))

5. Buy Signal 5 – Condition (L5 – Long 9 50) :

Cross( Mov(C, 9, E ) , Mov(C, 50, E ))

AND

(ADX(14) >= 20

OR

Cross(PDI(14),MDI(14))

OR

Ref(Cross(PDI(14),MDI(14)),-1))

6. Buy Signal 6 – Condition (L6 – Long 18 50) :

Cross( Mov(C, 18, E ) , Mov(C, 50, E ))

AND

(ADX(14) >= 20

OR

Cross(PDI(14),MDI(14))

OR

Ref(Cross(PDI(14),MDI(14)),-1))

7. Buy Signal 7 – Condition (L7 – Long 3 100) :

Cross( Mov(C, 3, E ) , Mov(C, 100, E ))

AND

(ADX(14) >= 20

OR

Cross(PDI(14),MDI(14))

OR

Ref(Cross(PDI(14),MDI(14)),-1))

8. Buy Signal 8 – Condition (L8 – Long 9 100) :

Cross( Mov(C, 9, E ) , Mov(C, 100, E ))

AND

(ADX(14) >= 20

OR

Cross(PDI(14),MDI(14))

OR

Ref(Cross(PDI(14),MDI(14)),-1))

9. Buy Signal 9 – Condition (L9 – Long 18 100) :

Cross( Mov(C, 18, E ) , Mov(C, 100, E ))

AND

henry1224  
#6 Posted : Sunday, February 12, 2012 8:27:41 AM(UTC)
henry1224

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
pan you certainly have alot of buy and sell conditions!

your code of

Cross(MDI(14),PDI(14))

OR

Ref(Cross(MDI(14),PDI(14)),-1))


could be written as

Alert(Cross(MDI(14),PDI(14)),2)


What you are really doing is combining 17 separate systems into one system


Here is an example of your buy1 signal and sell 1 signal


Entry:=Cross(Mov(C,3,E),Mov(C,9,E)) AND
(ADX(14) >= 25 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,9,E),Mov(C,3,E)) AND
(ADX(14) >= 25 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


here is your Buy2 sell 2 signals


Entry:=Cross(Mov(C,3,E),Mov(C,18,E)) AND
(ADX(14) >= 25 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,18,E),Mov(C,3,E)) AND
(ADX(14) >= 25 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Here is your Buy 3 Sell 3 signals


Entry:=Cross(Mov(C,9,E),Mov(C,18,E)) AND
(ADX(14) >= 25 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,18,E),Mov(C,9,E)) AND
(ADX(14) >= 25 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

Buy 4 Sell 4 Signals


Entry:=Cross(Mov(C,3,E),Mov(C,50,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,50,E),Mov(C,3,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy5 sell 5 Signals


Entry:=Cross(Mov(C,9,E),Mov(C,50,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,50,E),Mov(C,9,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy6 sell 6 Signals


Entry:=Cross(Mov(C,18,E),Mov(C,50,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,50,E),Mov(C,18,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy7 Sell 7 Signals


Entry:=Cross(Mov(C,3,E),Mov(C,100,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,100,E),Mov(C,3,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy8 sell 8 Signals


Entry:=Cross(Mov(C,9,E),Mov(C,100,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,100,E),Mov(C,9,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy9 sell9 signals


Entry:=Cross(Mov(C,18,E),Mov(C,100,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,100,E),Mov(C,18,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy10 sell10 signals


Entry:=Cross(Mov(C,50,E),Mov(C,100,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,100,E),Mov(C,50,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy11Sell 11 Signals


Entry:=Cross(Mov(C,3,E),Mov(C,200,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,200,E),Mov(C,3,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy12 sell 12 Signals


Entry:=Cross(Mov(C,9,E),Mov(C,200,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,200,E),Mov(C,9,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy13 sell13 signals


Entry:=Cross(Mov(C,18,E),Mov(C,200,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,200,E),Mov(C,18,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy14 sell14 signals


Entry:=Cross(Mov(C,50,E),Mov(C,200,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,200,E),Mov(C,50,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


Buy15 sell15 signals


Entry:=Cross(Mov(C,100,E),Mov(C,200,E)) AND
(ADX(14) >= 20 OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,200,E),Mov(C,100,E)) AND
(ADX(14) >= 20 OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short


henry1224  
#7 Posted : Sunday, February 12, 2012 11:24:13 AM(UTC)
henry1224

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Pan, one thing that you have to be careful with is the use of "AND' & "Or" functions in your systems

Also too many indicators and conditions are going to eliminate trades, making your system less profitable

The code that I provided helps in eliminating redundant signals.
Remember though that all moving average systems have lag built into them, you will miss the begining and end of trends
parimalp  
#8 Posted : Sunday, February 12, 2012 1:32:51 PM(UTC)
parimalp

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/4/2011(UTC)
Posts: 7
Location: New Bombay, India

Hi Henry, this now looks like a real MetaStock code..... Thnx a ton. Looking back at my code now makes me feel like a tiny dot in this vast universe of Tech Analysis. I do have a long way to go & lots to learn. But I am sure that with assistance from such supportive pals like you and lots of effort from me, I will surely be able to learn it fast.

I shall first try out the code that u sent. It will take me some time to understand & interpret the modified code but will get back to you in case of any further queries. I at least now know that I have made a start in the right direction (this being my first code).

Shall surely take your advice on the use of 'AND' & 'OR' functions. Also, while reading "High Probability Trading" by Marcel Link, understood how to use Stochastics & RSI. While testing it on my EMA Cross System, it did give early signals of the beginning & end of trends but I will need to be wary of the false signals that it generates sometimes.

I was unable to understand what you exactly meant when you stated "
What you are really doing is combining 17 separate systems into one system". Is it something that I should avoid or is it fine to do so. I basically want a system wherein I can get all the signals in one place.

Thnx once again.

Regards,

Pankaj


henry1224  
#9 Posted : Sunday, February 12, 2012 2:03:19 PM(UTC)
henry1224

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Too many indicators or systems combined, hamper your profit line.They eliminate many trading opportunities from happening,thus you end up missing the trade.

I feel that one or two indicators and a trend filter work best.
As for trailing stops, they tend to take you out of the trade before it starts to get profitable.

Your post had about 34 different buy or sell systems. You will never get them to fire off a signal at the same time. The fastest ema crossover will take you in and out of trades before your longest ema crossover. you might get 10 smaller trades with the faster ema versus 2 with the longer ema.
Compare the results from the systems. the faster ema system will have more whipsaws, more commissions and fewer profitable trades than the longer ema system. Compare profit vs risk


henry1224  
#10 Posted : Sunday, February 12, 2012 2:43:42 PM(UTC)
henry1224

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Here are 2 charts comparing a fast crossover vs a slow crossover

UserPostedImage

UserPostedImage
henry1224  
#11 Posted : Sunday, February 12, 2012 2:56:07 PM(UTC)
henry1224

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Here's a chart of the 3 9 EMA x over with reversed signals

UserPostedImage

Here's a chart of the 3,9 EMA with the MTF Filter

UserPostedImage
parimalp  
#12 Posted : Sunday, February 12, 2012 2:58:24 PM(UTC)
parimalp

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/4/2011(UTC)
Posts: 7
Location: New Bombay, India

Get your point.....shall keep that in mind.

Thnx.

Regards,

Pankaj[:)]
henry1224  
#13 Posted : Sunday, February 12, 2012 3:03:49 PM(UTC)
henry1224

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Here is the code for your system as an indicator

pds1:=Input("Parameter 1 periods",1,260,3);
pds2:=Input("Parameter 2 periods",1,260,9);
LVL:=Input("ADX Levels",5,100,25);
Entry:=Cross(Mov(C,Pds1,E),Mov(C,Pds2,E)) AND
(ADX(14) >= LVL OR Alert(Cross(PDI(14),MDI(14)),2));
exit:= Cross(Mov(C,Pds2,E),Mov(C,Pds1,E)) AND
(ADX(14) >= LVL OR Alert(Cross(MDI(14),PDI(14)),2));
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1);
Long-Short;
parimalp  
#14 Posted : Monday, February 13, 2012 12:45:30 PM(UTC)
parimalp

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/4/2011(UTC)
Posts: 7
Location: New Bombay, India

Thnx a ton Henry for this code....got more than what I asked for.[:D]
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.