going to draft out the program I am going to write an EA for,
find the closest sunday candle and draw a box and SL TP with it
=====> set inMarket, OSP_Buy_inMarket, OSP_Sell_inMarket = false
=====> after this is done, do not do it again
=====> this should probably be put in the init module
if the Day=Monday, and 0100 hour candle is just formed
=====> draw the box with SL and TP
=====> set inMarket flag = true
if inMarket flag is true
=====> if Ask price >= OSP_Buy, send in buy order at ask price, with SL/TP, set OSP_Buy_inMarket flag = true
=====> if Bid price <= OSP_Sell, send in sell order at bid price, with SL/TP, set OSP_Sell_inMarket flag = true
=====> check if current ATR is more than 40% of the weekly ATR(14), if true, remove all pending orders
=====> check if Friday GMT 1200, close all inMarket Orders, set inMarket, OSP_Buy_inMarket, OSP_Sell_inMarket = false
=====> if OSP_Buy_inMarket = true
==========> if Ask price >= OSP_Buy_BE, modify orderās SL to BE
=====> if OSP_Sell_inMarket = true
==========> if Bid price <= OSP_Sell_BE, modify orderās SL to BE
hi phil, have been wanting to ask you these 2 questions for a long time:
Q1
We have the sunday candle say 40 pips long end to end.
We have oanda spreads (i also use that broker) at 5 pips on sunday morning.
I assume we enter with the spreads, resulting in longer candle length +2.5 pips on entry, and +2.5 pips on SL.
Is this your understanding too?
The added length will decrease profitability by about 10% overall from your excel backtest. e.g. if your annual return is 50%, you will be down to 45%.
In recent weeks, I have seen the price bounce off the SL, and find this puzzling (e.g. this week). It makes me feel I should add more pips to the sunday candel (and consequently reduce profitability)
Q2
am wondering if you had considered the occurrence (it happened last week) that price whiplashed and stopped out the long and short trades. However, on a 4 hr chart, it seems like a profitable 2nd trade. (u know what i mean?)
We canāt see this unless we drill to a 1 hr chart or less.
First off, if you are both charting and trading with Oanda then you donāt have to factor in spreads at all!
Oanda is one of the weird brokers that draw their charts on the bid/ask average, instead of drawing them on the actual bid price like almost every other broker does. So the spread is already factored into the candle when it is drawn on the Oanda charts. The general rule of adding the spread into long orders does not apply to Oanda.
However, if you do your charting in MT4 with another broker, and just place your trades with Oanda like I do then you do need to add in the spread on long trades, because your MT4 charts are drawn on the bid price. Technically you should factor in 1/2 the Oanda spread on all trades, but I never worry about it. I can recall one time in the last 2 years that the charting differences caused me to lose a tradeā¦
I donāt think we need to add any more than the 10 pip buffer to the Sunday candle. I may not fully understanding your thought process here, but it seems to me youāre wanting to increase the win rate at the expense of profit!! If adding extra pips to the candles will reduce profitability, then why do you want to add extra pips??
Sure, it might up the win rateā¦ But a higher win rate does not necessarily mean more profit!
As for question 2ā¦ Yes, I considered that and factored it into my backtesting. If that happened I dropped down to a lower time frame so I could tell what really happened.
gone thru many times, i think this should be right?
find the closest sunday candle and draw a box and SL TP with it
=====> set inMarket, OSP_Buy_inMarket, OSP_Sell_inMarket = false
=====> after this is done, do not do it again
=====> this should probably be put in the init module
if the Day=Monday, and 0100 hour candle is just formed
=====> draw the box with SL and TP
=====> set inMarket flag = true
if inMarket flag is true
=====> if Ask price >= OSP_Buy, send in buy order at ask price, with SL/TP, set OSP_Buy_inMarket flag = true
=====> if Bid price <= OSP_Sell, send in sell order at bid price, with SL/TP, set OSP_Sell_inMarket flag = true
=====> check if current ATR is more than 40% of the weekly ATR(14), if true, remove all pending orders
=====> check if Friday GMT 1200, close all inMarket Orders, set inMarket, OSP_Buy_inMarket, OSP_Sell_inMarket = false
=====> if OSP_Buy_inMarket = true
==========> if Ask price >= OSP_Buy_BE, modify orderās SL to BE
=====> if OSP_Sell_inMarket = true
==========> if Bid price <= OSP_Sell_BE, modify orderās SL to BE
You need a flag to check if the BE point has already been changed, and to make sure itās only changed once, otherwise the EA is going to change it again everytime the price moves.
Itās a bug that wouldnāt hurt the EA since itās being changed to the same value over and over, but itās still a bug.
Welcome back Phil! quite a dramatic come back i must say.
Iāve only just gone live with this method this week. Not a great start but im not bothered. The previous couple of weeks were so good I was wishing the demo profits were real.
GBP USD was a loss and a BE for me by a couple of pips. But GBP JPY was a loss and currently in a free trade going short. If i get a win with this one trade it will more than cancel the other two losses.
I donāt think we need to add any more than the 10 pip buffer to the Sunday candle. I may not fully understanding your thought process here, but it seems to me youāre wanting to increase the win rate at the expense of profit!! If adding extra pips to the candles will reduce profitability, then why do you want to add extra pips??
==> Yes, my concern arises because of so many close shaves, such has this weekās - just off by 1.5 pip in my case.
Sure, it might up the win rateā¦ But a higher win rate does not necessarily mean more profit!
==> agreed, itās the animal in me again!:o
As for question 2ā¦ Yes, I considered that and factored it into my backtesting. If that happened I dropped down to a lower time frame so I could tell what really happened.
==> and you said you did this back test manuallyā¦:eek:
I was programming one EA already, anyway do yours and i will continue mine.
1- not reallyā¦ only in the part of being on the init module, you still need to keep track of the values and many cases will arise were init is not enouthā¦
2- be carefull not all broker have same timezones
3- try to use metatrader price orders has flags and not logic flags unless you really have no choice, metatrader flags lets you better backtest + its more reliable in actual foward testing. the only good thing logic flags has is that sometimes in diference of small ammount of āpipsā it will prevent your order from being closed prematurely.
[QUOTE=gif;130077]I was programming one EA already, anyway do yours and i will continue mine.
1- not reallyā¦ only in the part of being on the init module, you still need to keep track of the values and many cases will arise were init is not enouthā¦
2- be carefull not all broker have same timezones
[QUOTE]
for (1) itās only trying to draw on the screen for the user, esp when itās tuesday, and they want to know whatās going on, donāt have to open mt4 to wait for Monday GMT 0000
yes and no. il explain for the server they are, for your metatrader client they arent. metatrader client builds history with imcoming data tick, if you lag abit, metatrader will not build the last tick and will prioritise the most recent, and what happens is that if you use logic flags sometimes orders wont trigger and other orders wont be closed because even if the ea executes every single tick if data is missing the code is strict and nothing will happen and in this case (if <= value -> close) if theres no thick even if it was there it wont close.
if you use metatrader flags the order is already there (pending orders) what happens is even if you miss that tick it doesnt matter, the server has all values in correct orders and there and for real every value is check so your order will be more ārealā and will be opened or closed.
im not good at explaining, anyway feel free to ask more questions.
1 - the first one is solved by itself, for the ea to work properly you will have to have it on at the time of change (when the 4H sunday bar just finished closing), what you have to keep in mind is that everytime the user turns on the metatrader the init() function will be used once, so yes to ease your work you could use it to read some values from files and make some check up to see if those are the correct values, but later you will need to keep track of those values because many things can depend on that, not only during week days and people needing to see whats going on and all, but you will need then for future improvements, making reports, tracking bugs, use management, and alot other stuff.
2 - im making mine adaptable to any broker so that everyone can use in any broker they would like, and im even building something for much later, im gonna place the āreal broker (your primary broker since many people dont use IBFx has main) + IBFxā working together exchanging info in case someone wants to keep track of those values, it will be better and worst in some stuff but yes it is possible.
You may want to consider the e-video course like NickBās. Have your own blog and forum, I believed people want support you as you are more patience and supportive in helping newbies esp.
A question to the strategy author, is it absolutly necessary for the 2 pending orders to be opened at the same time? I need to know this to continue making the ea.
EDIT: Since no one replied i made it a ruleā¦ 2 orders or no order. the EA is ready and i will be adding the module later to support any broker at all based on user input! now il take a break! btw results seam promising.