MQ4 Code Works

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
Ha yes, that was a buy you say. That was a little system I built on sunday based on JJMA, Alma, and bband breaks... The core filter for longer term trend was PSAR (probably a bad filter), so that is why it looked for longs on that pair.

I am still building what you mentiond... find the trend first. entry second. I just had this being worked on so it's been running in the background while I tinker with tools that will help me answer the questions I laid out in Post 205 using only AO, MAs, and ATR.
 

Attachments

  • FTMO_Testv_2.mq4
    18.5 KB · Views: 8

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
bband breaks...
//-----

keep it simple at first...... plenty of time to get complicated later......

just sayin......h
//------

eurcad-h4-oanda-division1-240.png

//----


eurcad-d1-oanda-division1-just-sayin.png
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
I am gaining appreciation for your thoughts on "it may have been an ea, but I allowed it".

I am just getting started, but have pretty much built every function I can think of with the AO, ZZ, and MA's including trade functions. There is a common theme... I can make some profitable strategies - albeit very minimal profit and not worth the drawdown.

common theme is if you can remain solvent, just wait for the TP. Most of my backtests were run on Daily and 4H charts. Just trying to see if I can get the most basic structure down (when I want to be long, and when I want to be short, am I buying into a down zz leg, vice versa, etc.).

The dream would be everything 100% code. More realistically, I see myself needing to create a few strategies (send grid every AOcross, Send Grid/Market order when crossing 50-fib level, etc) and then couple them with alerts that show me favorable market conditions to turn them off, as well as unfavorable market conditions for knowing when to leave.

finally, this is all high tf, wait for my tp to get his strategy and not coded to FiFO. I figure I will worry about FiFO once I can be profitable.

I invite any feedback that comes to mind!

attached is an include and an EA (just shows my tinkering around with trying to find a first-level signal based on the daily 50/200MA).
 

Attachments

  • ThinkLikeHayseed.mq4
    4.7 KB · Views: 9
  • HayseedStrategyFunctions.mqh
    16.8 KB · Views: 9

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
I invite any feedback that comes to mind!
//-----

your code is looking better..... reduce it more..... 50% more.....

it's a good practice to not post anything with the actual ordersend function in it that might place trades....... unless you are absolutely certain it's coded correctly.... once it's out there, it's out there......

most brokers will not allow the stoploss and profit targets to be set with the order..... they might be sent with the order, as seen in the journal, but will be 0.0000 in the trades.... send first, modify second....

it looks like your order close functions will close every order on that pair...... what if someone has other orders not associated with the ea..... use a magic number or the comments to limit orders it controls...... unless you want to close them all.....

take a closer look at your filters....... keep in mind, the 50 can be above the 200 and both be falling like a rock..... or it can be below the 200 and both rising like penny rockets.....

when using > and < , it's occasionally better to use > and <= ..... the <= covers the possibility of them being equal.....

sometimes i forget and other times i might just not be wanting to be precise...... but <= is better.....h
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
Couple things to explain on that:

Regarding your comments on the 50 being above 200 but still dropping. I was using that as my red light green light. If 50>200, that means there was a golden cross more recently then a death cross, so “buys only”. I figured this is what you meant by “find the trend first” - pick a filter for trend and trade in that direction only. Is that not what you had meant?

I did have the close all orders. I was using just to see what it would look like if I pulled the plug on the whole thing if the right conditions were met. Each method I’ve been testing entails a take profit, so the close all orders function is only for when “it hit the fan in testing”

I also have one that deletes pending. This was simply for the fact that if I send a sell grid, once the ZZ is down, I’m didnt want those sell limits lingering forever.

Was Incorrect in regards to my comments about simply coding EA’s to fit a condition? Or is it feasible to fully code an EA, and just walk away (assuming your coding is sound)?
 
Last edited:

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
That first part of that response was regarding this challenge:
 

Attachments

  • 900D3E34-1B75-4FF7-8CBC-1096ADC30647.jpeg
    900D3E34-1B75-4FF7-8CBC-1096ADC30647.jpeg
    95.6 KB · Views: 5

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
Regarding your comments on the 50 being above 200 but still dropping. I was using that as my red light green light. If 50>200, that means there was a golden cross more recently then a death cross, so “buys only”. I figured this is what you meant by “find the trend first” - pick a filter for trend and trade in that direction only. Is that not what you had meant?

Was Incorrect in regards to my comments about simply coding EA’s to fit a condition? Or is it feasible to fully code an EA, and just walk away (assuming your coding is sound)?
//-----

look at the code in post 201...... and keep in mind it's just an idea...... there are probably better trend indicators/ideas.....

the 50, 100 and 200 are all moving up, and the 50>200 and 100>200..... this assures they all are moving up......

Code:
             bool fast = (iMA(symbol,tfs[j], 50,0,0,0,1) > iMA(symbol,tfs[j], 50,0,0,0,2));
             bool mid  = (iMA(symbol,tfs[j],100,0,0,0,1) > iMA(symbol,tfs[j],100,0,0,0,2));
             bool slow = (iMA(symbol,tfs[j],200,0,0,0,1) > iMA(symbol,tfs[j],200,0,0,0,2));
                      
             bool up = ( fast &&  mid &&  slow && iMA(symbol,tfs[j],50,0,0,0,1) > iMA(symbol,tfs[j],200,0,0,0,1)) && (iMA(symbol,tfs[j],100,0,0,0,1) > iMA(symbol,tfs[j],200,0,0,0,1));
             bool dn = (!fast && !mid && !slow && iMA(symbol,tfs[j],50,0,0,0,1) < iMA(symbol,tfs[j],200,0,0,0,1)) && (iMA(symbol,tfs[j],100,0,0,0,1) < iMA(symbol,tfs[j],200,0,0,0,1));

//------

yes it is feasible to code a ea and just run it...... but i would not assume my code was correct even after demo testing......

rare or obscure things can expose flaws unseen.....h
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
are you saying you would view this as an entry trigger or a “Trade/Don’t Trade” filter?

I tested with both, but I couldn’t seem to bend it in away that consistently performed.

If you look at my EA code, that’s actually what I had commented out in the if-statement to test.

If daily Momentum is true, trade with that momentum. Perhaps I just need to keep playing with it
 

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
are you saying you would view this as an entry trigger or a “Trade/Don’t Trade” filter?

I tested with both, but I couldn’t seem to bend it in away that consistently performed.
//------

keep bending......

i have 1 account that has 100 open eurusd shorts right now...... all that account does is trade the eurusd...... nothing more.....

i can not recall the last time i bought the eurusd, eurcad, gbpusd and several more pairs in any account...... the reason is the perfect falling of 50, 100 and 200 daily moving averages......

that does not mean someone could not buy while those moving averages are falling and make money.....

1.... i don't like trading against the 50, 100 and 200 daily moving averages..... but i will sometimes.....
2.... i don't like trading against the 60 minute qqe...... but i will sometimes.....
3.... i don't like trading against the ao..... but i will sometimes.....

if i get 1, 2 and 3 right, the actual trigger is almost immaterial to me....h
//-----

eurcad-d1-ftmo-s-r.png
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
1.... i don't like trading against the 50, 100 and 200 daily moving averages..... but i will sometimes.....

Do you include this to mean that they are also falling? Or simply they are below each other in order?

For example, the pink x’s are when they are in order and all falling. I took a picture from you last post about early in the EURUSD trend. All MA’s are in the proper order and bearish, but no x’s (thus not all moving down).

Do you consider trading when there are no x’s “trading against them? Or would that only be when the MA’s aren’t in the proper order that you’d call it “trading against”?
 

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
Do you include this to mean that they are also falling? Or simply they are below each other in order?

For example, the pink x’s are when they are in order and all falling. I took a picture from you last post about early in the EURUSD trend. All MA’s are in the proper order and bearish, but no x’s (thus not all moving down).

Do you consider trading when there are no x’s “trading against them? Or would that only be when the MA’s aren’t in the proper order that you’d call it “trading against”?
//-----

your over thinking again ......

the magenta x's are the premium sell days...... the ma's are falling and in order..... that same indicator will places vertical lime/red lines at the ao 0 line cross.....

look at this eurcad daily chart..... which would be easier...... buying or selling..... why.....
//-----

now...... next chart.....

the aqua x's are the premium buy days...... the ma's are rising and in order..... that same indicator will places vertical lime/red lines at the ao 0 line cross.....

look at this usdjpy daily chart..... which would be easier...... buying or selling..... why....

in each of those charts, where would your first trade have been..... why.....
//-----

yes, if you drop down to lower timeframes the ma's might say something different..... just like almost all indicators.....

the trend indicators are causing you problems..... choose one.....

the multiple timeframes are causing you problems..... choose one.....

the multiple indicators are causing you problems..... choose one....

the multiple pairs are causing you problems..... choose one....

one trade a day..... 0.01 lots..... both charts below would have doubled the account....h
//-----

eurcad-d1-oanda-division1-whack.png


//-----

usdjpy-d1-oanda-division1-buy-every-dip.png
 

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
examples.....

daily downtrends.....

last daily zigzag leg up, with exceptions of eurusd and gbpusd..... both those fell today......

ao above 0 and falling.....

daily counts supportive....

expect some retrace..... esp, eurusd and gbpusd.....

each chart is from a single account which trades that pair and that pair only..... small accounts.....h
//-----
gbpusd-d1-oanda-division1.png

//-----
audusd-d1-oanda-division1.png

//----


eurusd-d1-oanda-division1.png

//-----

audcad-d1-oanda-division1.png

//-----
nzdusd-d1-oanda-division1.png

//------

nzdcad-d1-oanda-division1.png
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
That’s awesome. You toe the line if making it look so easy despite knowing being so consistent is exactly the opposite.
 

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
That’s awesome. You toe the line if making it look so easy despite knowing being so consistent is exactly the opposite.
//----

do you see the similarity in the charts..... keep in mind both the gbpusd and eurusd zigzags were up yesterday afternoon..... check the daily counts for yesterday.....

scan for those conditions...... put them in a simple dashboard.....

you can double up wingdings to conserve space......

tell me what the set of arrows and squares in the blue rectangle represent......

what about those in the lime rectangle......

the answer is in the charts above.....h
//----

usdjpy-d1-oanda-division1.png
 

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
Aunty Entity, " But how the world turns. One day, cock of the walk. Next, a feather duster."
//-----

clock is tickin on those jpy pairs.....

some of the up count is consumed in the down turn....h
//-----

usdjpy-d1-oanda-division1-feather-duster.png
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
//----

do you see the similarity in the charts..... keep in mind both the gbpusd and eurusd zigzags were up yesterday afternoon..... check the daily counts for yesterday.....

scan for those conditions...... put them in a simple dashboard.....

you can double up wingdings to conserve space......

tell me what the set of arrows and squares in the blue rectangle represent......

what about those in the lime rectangle......

the answer is in the charts above.....h
//----

usdjpy-d1-oanda-division1.png
My gut tells me Blue would be MA direction, and arrow would be if all MA’s are sloped down.

Green I assume the square is whether AO is above or below 0-line, and arrow is whether histogram is rising or falling.

Other possibility is that zz direction is in the mix too, but not sure
Post automatically merged:

And I definitely do see the likeness across the charts. Trend is down, last leg is up, momentum is falling. All ingredients for a great entry for sure and certainly something one can code with relative simolicity
 

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
My gut tells me Blue would be MA direction, and arrow would be if all MA’s are sloped down.

Green I assume the square is whether AO is above or below 0-line, and arrow is whether histogram is rising or falling.

Other possibility is that zz direction is in the mix too, but not sure
//-----

pretty close.....

first set.... in the blue, the square is last zigzag leg up or down, arrow if all are pointing same way.....

your correct on the second set......

at that charts point in time, the daily audusd and nzdusd last zigzag leg was up, lime square..... and the daily ma's were trending down properly....

ao was above 0 and falling....

the daily counts were red 0's and 1's......

in simple terms, the buzzards were circling......h
 

hayseed

Master Trader
Jul 27, 2010
1,011
258
149
usa
be sure to leave some head space...... that 240 chart can kick it back up pretty good, maybe 50%.. ... avoid having too many low trades go under water......

once the 240 zigzag prints up , i'll look to fill that gap on the fall back...... if it does.....

don't chase it.....h

//-
gbpusd-d1-oanda-division1.png

//----
audusd-d1-oanda-division1.png


//-----
eurusd-d1-oanda-division1.png


//-----
audcad-d1-oanda-division1.png

//-----
nzdusd-d1-oanda-division1.png


//-----
nzdcad-d1-oanda-division1.png








-----