• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 11:59am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 11:59am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Looking for Death Cross and Golden Cross indicators 4 replies

Jake Bernstein 10 SMA high 8 SMA low trading system 93 replies

SMA 200+SMA 55+SMA 5 is very profitable 49 replies

AUDUSD/AUDCHF/NZDJPY basket trading using 50 sma and 200 sma 16 replies

ATR vs (H-L)SMA programming help. 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: Programming of SMA and SMA cross over
Exit Attachments
Tags: Programming of SMA and SMA cross over
Cancel

Programming of SMA and SMA cross over

  • Last Post
  •  
  • Page 1 2
  • Page 1 2
  •  
  • Post #1
  • Quote
  • First Post: Jan 8, 2010 5:19am Jan 8, 2010 5:19am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
Hi, i am using this website to build my own simple ea
http://sufx.core.t3-ism.net/ExpertAd...ndex.html#Buy1

But how do i code for to go for a sell Entry when SMA(26) cross over SMA(8) and buy entry when SMA(8) cross over SMA(26)?

I not sure what is the alogorithm for crossing over for MA? is it >= or other stuff? please help.. thanks
  • Post #2
  • Quote
  • Jan 8, 2010 5:23am Jan 8, 2010 5:23am
  •  luxinterior
  • Joined Nov 2006 | Status: MT4 EA Coder Since 2006 | 300 Posts
Check the link in my sig. It will walk you through how to create an MA crossover and you can see the logic. You don't need any prior programming experience to follow it.

Hope that helps.

Lux
MT4 EA, Indicator and Alert Coder Since 2006
 
 
  • Post #3
  • Quote
  • Jan 9, 2010 4:18am Jan 9, 2010 4:18am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
yo, can anyone help? thanks
 
 
  • Post #4
  • Quote
  • Jan 9, 2010 7:36am Jan 9, 2010 7:36am
  •  LittleLuca
  • | Joined Feb 2009 | Status: BoB | 97 Posts
Its the >= "stuff". http://www.hermit.cc/teach/HO/dbms/OPTABLE.HTM

This link should give you a basic over view of the comparison of different values!

But yes you wish to use SMA(28) >= SMA(8) (which means when the value of sma28 is greater than (or equal to) sma8 then sell!)

HTH
The winner of the rat race is still a rat.
 
 
  • Post #5
  • Quote
  • Jan 9, 2010 11:27am Jan 9, 2010 11:27am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
I seee... thanks...

So for SMA(28) cross over SMA(8), that means is equivalent to SMA(28) >= SMA (8)?

thanks


Quoting LittleLuca
Disliked
Its the >= "stuff". http://www.hermit.cc/teach/HO/dbms/OPTABLE.HTM

This link should give you a basic over view of the comparison of different values!

But yes you wish to use SMA(28) >= SMA(8) (which means when the value of sma28 is greater than (or equal to) sma8 then sell!)

HTH
Ignored
 
 
  • Post #6
  • Quote
  • Jan 9, 2010 11:43am Jan 9, 2010 11:43am
  •  hayseed
  • Joined Nov 2006 | Status: Member | 3,636 Posts
hey kp...... crossings usually require 2 conditions..... SMA(28) >= SMA (8) one part..... such as below........h




Inserted Code
 
     double fast        = iMA(NULL, 0, fastmaperiods, 0,  fastmethod, fastprice, 1);
     double fast2       = iMA(NULL, 0, fastmaperiods, 0,  fastmethod, fastprice, 2);   
     double slow        = iMA(NULL, 0, slowmaperiods, 0,  slowmethod, slowprice, 1); 
     double slow2       = iMA(NULL, 0, slowmaperiods, 0,  slowmethod, slowprice, 2);   
 
     if(fast > slow && fast2 <= slow2) {macrossbuy  = true;} else  {macrossbuy  = false;} 
     if(fast < slow && fast2 >= slow2) {macrosssell = true;} else  {macrosssell = false;}
to trade and code, keep both simple... no call to impress....h
 
 
  • Post #7
  • Quote
  • Jan 10, 2010 6:26am Jan 10, 2010 6:26am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
what if i am using the http://sufx.core.t3-ism.net/ExpertAd...ndex.html#Buy1

Quoting hayseed
Disliked
hey kp...... crossings usually require 2 conditions..... SMA(28) >= SMA (8) one part..... such as below........h




[code]...
Ignored
 
 
  • Post #8
  • Quote
  • Jan 10, 2010 8:10am Jan 10, 2010 8:10am
  •  hayseed
  • Joined Nov 2006 | Status: Member | 3,636 Posts
hey kp..... it's admirable of you to attempt the ea on your own....


there are several versions of those 'zero code' programs.... sufx core is one...... all have the same basic design, change the shift variable to help create the two conditions..... as example, the before condition would have a shift value of 2, and the after condition would have a shifit value of 1.......

//----

those type 'zero code' programs were/are abused to the point that i just about can't even look at the code they produce..... so, due to that personal flaw, my expierence with them is limited......h
to trade and code, keep both simple... no call to impress....h
 
 
  • Post #9
  • Quote
  • Jan 11, 2010 1:28am Jan 11, 2010 1:28am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
ok thanks. is it possible to help me with this simple EA? thanks

Quoting hayseed
Disliked
hey kp..... it's admirable of you to attempt the ea on your own....


there are several versions of those 'zero code' programs.... sufx core is one...... all have the same basic design, change the shift variable to help create the two conditions..... as example, the before condition would have a shift value of 2, and the after condition would have a shifit value of 1.......

//----

those type 'zero code' programs were/are abused to the point that i just about can't even look at the code they produce..... so, due to that...
Ignored
 
 
  • Post #10
  • Quote
  • Jan 11, 2010 11:00am Jan 11, 2010 11:00am
  •  hayseed
  • Joined Nov 2006 | Status: Member | 3,636 Posts
hey kp..... sure, we can give it a shot..... just post your buy/sell rules and such..... give them plenty of thought and try to be as explict as possible....h
to trade and code, keep both simple... no call to impress....h
 
 
  • Post #11
  • Quote
  • Jan 11, 2010 11:22am Jan 11, 2010 11:22am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
ok, here we goes:::

Indicator: EMA8(blue), SMA26(red), CCI55(with zero as centre readin), CCI34(with zero as centre reading) and RSI26 (with 48 as centre reading)


BUY Entry

1) When EMA crosses SMA to the upside, CCI55 and CCI34 crosses the zero reading and RSI26 crosses the 48 reading

SELL Entry

1)the reverse of buy

Note:
1) never take a trade if one of the indicators is doing otherwise of the other indicators

2) if all the requirement is meant for the trade, the next thing to watch for is the deviation of the PA from the MA crosses

3) never take a trade with opposing candle ( i mean dont go long with a closed bear canndle and vice versa)

4) before taking a trade wait for the current candle to close meaning only take a trade at the opening of another candle

5) if the deviation of the PA from the MA is wide wait for the price consolidation towards the MA and obey rule 3&4 before taking a trade

Money Management:
SL: 30 pips (can adjust)
TP: 20 pips (can adjust)

Quoting hayseed
Disliked
hey kp..... sure, we can give it a shot..... just post your buy/sell rules and such..... give them plenty of thought and try to be as explict as possible....h
Ignored
 
 
  • Post #12
  • Quote
  • Jan 11, 2010 2:23pm Jan 11, 2010 2:23pm
  •  hayseed
  • Joined Nov 2006 | Status: Member | 3,636 Posts
hey kp..... i'll be in my prefered office shortly, a deer stand..... will code it up there.....

but can tell without a doubt it will not work as you hope..... your using 2 momentum indicators with 3 different period settings in conjunction with 2 moving averages....

the odds of all 5 needed conditions to happen on the same bar are just about 0.... you might get a few signals a year....

then when you throw the bullish/bearish candle into the mix, well, it's just far to restricitive to place trades.....

place all those indicators on a chart and scroll back..... likely you'll give up before 3 trades are found.....


momentum indicators like, rsi, cci, wpr, stoch, are thought by some as leading indicators.... with leading indicators, many will just require that the indicator be above or below a value rather than crossing a value, when used in a ma cross system....

so instead of,

CCI55 and CCI34 crosses the zero reading and RSI26 crosses the 48 reading

they would use,

CCI55 and CCI34 > zero and RSI26 > 48 , for a buy..... along with the ma cross.....


//----

of course if it's just a pure momentum system, then rsi/cci/wpr/stoch crossing a value is widely used.....


//----

you've been mentioning sma's so far, but in the rules you say,

Indicator: EMA8(blue), SMA26(red),

did you mean sma8(blue) .......h
to trade and code, keep both simple... no call to impress....h
 
 
  • Post #13
  • Quote
  • Jan 12, 2010 12:11am Jan 12, 2010 12:11am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
Oh i see.. but u put it in a H1 TF, it will match sometimes.. maybe once a day. Maybe u can help me to program it and we will test together...

anyway it is EMA(8) and SMA(26)....

Quoting hayseed
Disliked
hey kp..... i'll be in my prefered office shortly, a deer stand..... will code it up there.....

but can tell without a doubt it will not work as you hope..... your using 2 momentum indicators with 3 different period settings in conjunction with 2 moving averages....

the odds of all 5 needed conditions to happen on the same bar are just about 0.... you might get a few signals a year....

then when you throw the bullish/bearish candle into the mix, well, it's just far to restricitive to place trades.....

place all those indicators on a chart...
Ignored
 
 
  • Post #14
  • Quote
  • Jan 12, 2010 7:54am Jan 12, 2010 7:54am
  •  hayseed
  • Joined Nov 2006 | Status: Member | 3,636 Posts
hey kp...... here ya go..... all values are your default settings except for the one you have not mentioned, the distance from the ma...... pips sets that value..... if the price is less than the ma +/- that value it will trade.... if not, it will wait..... the larger the timeframe, the larger that setting should be.....

your tying it's hands and feet pretty tight with so many strict conditions...... so don't expect a whole lot of action.....h
Attached File(s)
File Type: mq4 KPForex.mq4   4 KB | 557 downloads
to trade and code, keep both simple... no call to impress....h
 
 
  • Post #15
  • Quote
  • Jan 12, 2010 8:48am Jan 12, 2010 8:48am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
Quoting hayseed
Disliked
hey kp...... here ya go..... all values are your default settings except for the one you have not mentioned, the distance from the ma...... pips sets that value..... if the price is less than the ma +/- that value it will trade.... if not, it will wait..... the larger the timeframe, the larger that setting should be.....

your tying it's hands and feet pretty tight with so many strict conditions...... so don't expect a whole lot of action.....h
Ignored

really appreciate ur prompt action man... will test it out tomorrow in my office. By the way, have u done any testing so far on all pairs? hehe
 
 
  • Post #16
  • Quote
  • Jan 12, 2010 9:42am Jan 12, 2010 9:42am
  •  hayseed
  • Joined Nov 2006 | Status: Member | 3,636 Posts
hey kp..... i ran it on all timeframes on just a couple pairs, more for code check than anything else..... trades less than once a month , as expected.......

i'm back in the deer stand now..... things are slow so i'll add the ability to switch to a less restrictive and more conventional way of thinking.....

unless that trophy 3 point steps out......h
to trade and code, keep both simple... no call to impress....h
 
 
  • Post #17
  • Quote
  • Jan 12, 2010 9:49am Jan 12, 2010 9:49am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
thanks man...maybe u can put in ur ideas on how we can improve this EA?

Quoting hayseed
Disliked
hey kp..... i ran it on all timeframes on just a couple pairs, more for code check than anything else..... trades less than once a month , as expected.......

i'm back in the deer stand now..... things are slow so i'll add the ability to switch to a less restrictive and more conventional way of thinking.....

unless that trophy 3 point steps out......h
Ignored
 
 
  • Post #18
  • Quote
  • Jan 12, 2010 9:41pm Jan 12, 2010 9:41pm
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
Hi Hayseed,

I thought of one simple strategy.. but need ur help to change the EA... it works on one pair. GBPUSD for 1H TF. The criteria is as below... pretty simple.

Buy Signal
Criteria - SMA(5)and SMA(10) is above SMA(62)

Sell Signal
Criteria - SMA(5)and SMA(10) is below SMA(62)

For money management wise, is as follows:

the EA would open and close trade on time 00:00hrs daily.

For example, it will open a new trade at 00:00 hrs (13 Jan), if SMA(5)and SMA(10) is above SMA(62), it will just trigger a long signal. Then the next day at 00:00hrs(14 Jan), it will close the trade regardless of whether loss or profit. Then it will again look for the criteria, if it is SMA(5)and SMA(10) is below SMA(62), then will do a short signal.

I forsee that it will be beneficial. is it possible to come out a EA like this? thanks
 
 
  • Post #19
  • Quote
  • Jan 13, 2010 1:01am Jan 13, 2010 1:01am
  •  tommbstone
  • | Joined Dec 2009 | Status: Member | 618 Posts
hahah I can see him now up in the deer stand clicking away.. The sound of the clicking must lure them in.
 
 
  • Post #20
  • Quote
  • Jan 13, 2010 1:25am Jan 13, 2010 1:25am
  •  KPForex
  • | Joined Dec 2009 | Status: Member | 241 Posts
Quoting tommbstone
Disliked
hahah I can see him now up in the deer stand clicking away.. The sound of the clicking must lure them in.
Ignored
what does that means?
 
 
  • Platform Tech
  • /
  • Programming of SMA and SMA cross over
  • Reply to Thread
    • Page 1 2
    • Page 1 2
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023