Forex Zone - Forex Forum

Simple system

Discussion started on New EA Coding

  • Jr. Member
  • Posts: 62
  • Points: 0
  • Likes Received: 14
  • Reputation: +1/-0
Hi francois, I've put it on a chart and will report back. What is the purpose of the new function?
#61 - January 19, 2019, 12:25:08 PM

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
You can easily test this EA in strategy tester too.

The new function calculates the hi to low range for a number of candles, it then sets the X-Diff to the range.
It is totally optional, if it is set to false the EA uses X-Diff in the inputs as the trading range.
#62 - January 19, 2019, 06:32:28 PM

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
I like the name you gave to this topic.
I can tell you one thing though, as a newby to coding, this is everything BUT a simple system to code.
Anyway, I enjoy this challenge as I am more into coding of systems where indicators are involved, so, thanks.
SO the latest is this, I've run this through it's paces over and over, on different X-Diff's, currencies etc etc etc, 
Just a few more tweaks, and I will post your final version.
#63 - January 21, 2019, 11:13:54 PM

  • Jr. Member
  • Posts: 62
  • Points: 0
  • Likes Received: 14
  • Reputation: +1/-0
Hi francois, I do appreciate your efforts on this project and am glad it's challenged you. I'm still unable to understand what the xdiff is for, what exactly is it doing? T
#64 - January 22, 2019, 01:16:01 AM

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
X-Diff is the X Amount you want the EA to place stop orders.
I will rename it in the EA to something like Grid Size 
I am very happy with the way it places and modifies Stop Orders now.
Now just the closing of orders , but I'm nearly done, I hope to have the final version out today still.
#65 - January 22, 2019, 04:54:40 PM

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
Tony ( And other interested parties 8))
I think this is it.
Just a few pointers:

You mentioned you want to select the amount of pips the EA must place Stop Orders.  - This will be the X-Diff  you asked about (I have renamed the "Grid Size" ), You can change this setting in the "Inputs" tab.

 You can also change the arrow colors in the Inputs,  I've set the defaults as follows: 

  • New Buy Stop: Black
  • Buy Stop Modify: Green
  • Buy Stop Triggered : Blue
  • Buy Trade Closed: Blue
  • New Sell Stop: White
  • Sell Stop Modify: Orange
  • Sell Stop Triggered: Red
  • Sell Trade closed: Red
The reason for different colors is you can see immediately what the EA did, and when it did it (You can also look in your Experts Tab)


When the EA is running, you will see in the top left corner info about how many stops/orders you have open, as well as the target closing price for each direction.

I have not tested this for profitability , the Grid size as default is as per your initial description of 25 pips. ( PLEASE REMEMBER, 1 Pip = 10 Points, all the inputs are in POINTS)


Please let me know how it does.

F

( PS, Admin and CP, if you have any more ideas about this, I will send you the MQL versions, if you want)



#66 - January 22, 2019, 11:14:19 PM
Attachments:

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
:-[:-[:-[

This doesn't change anything about the EA's execution of orders etc, but I have disabled the "Auto X_Diff"  (which automatically calculates the grid size based on previous HigestHi/LowestLo or previous HiClose/LoClose) option in the EA, but forgot to remove it from the inputs.
It only works on the grid size input currently.
If anyone wants to use the auto calculate function, please let me know, and I will enable it again.
#67 - January 23, 2019, 12:10:43 AM

  • Jr. Member
  • Posts: 62
  • Points: 0
  • Likes Received: 14
  • Reputation: +1/-0
Once again, a huge thank you for this francois... I realize how much time you have spent on it. I have quickly ran it through the built in strategy tester for a two week period with five each side and at the end of the period it seemed as if it took all ten orders on day one and carried them all though until the period expired... I must admit that I don't understand the strategy tester so it could be me. T
#68 - January 23, 2019, 12:12:02 AM
« Last Edit: January 23, 2019, 12:14:04 AM by Blanco »

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
The strategy tester is basically a rerun of history.
It retrieves historical data and then runs your indicators or EA's based on that.
Within that you can the optimize your values etc.
I would suggest, go through a couple of youtube videos on the tester. It is quite a good weapon in your armory if you want to test your ideas with price action or indicator based strategies, but don't cheat. the good thing is you can pause it any time, draw your lines and resume it, and see if your ideas work out.
Please note, if you want to see your EA perform "live", make sure "Visual mode" is checked, else you won't see anything happening except results, graph and report.
In spite of all the jibber jabber above, live trading has the final say...
 
#69 - January 23, 2019, 01:05:57 AM

  • Jr. Member
  • Posts: 62
  • Points: 0
  • Likes Received: 14
  • Reputation: +1/-0
Hi francois,

sorry to be the bearer of bad news so early on but the ea isn't doing what it should be. As the profitable orders increase the unprofitable ones aren't being cancelled at the right time. I ve tested it several times on two either side with a gap of ten points for quickness but each time it's hanging on to the losers without replacing them with pending orders. T

When the price hit 1.13910 the furthest sell should have been replaced with a pending sellstop for 1.13900 and when it reached 1.3920 the other sell should have been replaced by a sellstop for 1.13910 ... When it got to 1.3930 the 1.1390 Sellstop should have been modified to 1.13920.

Edit... Am I right in assuming that if every order has a stop loss of whatever the gap is would fix that? ... Math isn't my strong point. T

Edit... Ignore that last suggestion, it wouldn't work with more than one order would it?
#70 - January 23, 2019, 05:38:14 PM
Attachments:
« Last Edit: January 23, 2019, 08:52:34 PM by Blanco »

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
The exit strategy for each trade is the same mechanism used in cancelling and replacing the pending orders.

So, say we are two either side with a 50 gap and the price has been rising, the pending orders have been following.

Buy 1.0550  (+350)
Buy 1.0500.  (+400)
Price 1.0900
Sellstop 1.0850
Sellstop 1.0800

The price reverses

Buy 1.0550  (+250)
Buy 1.0500  (+300)
Price 1.0800
Sell 1.0850  (+50)
Sell 1.0800  (0)

When it reverses to a point that we need to follow with a pending order the the furthest away buy in the example has to be exited to maintain the balance of orders either side.

Buy 1.0550  (+200) (cashed in when new buystop triggered)
Buy 1.0500  (+250)
Buystop 1.0800 (activated when our nearest sell hit 50 pip gap)
Price 1.0750
Sell 1.0850  (+100)
Sell 1.0800  (+50)

If the price continued to 1.0700 then the other market buy is cashed in and replaced with a another buystop at 1.0750

I hope this explains it. T
Hi Tony
Remember in the very beginning of discussions on the EA I suggested a trailing stop for open orders, because if a sell stop gets filled on a buy position, it won't close the buy (where it would've closed it in a profit)
I coded the closing as follows:
It closes the highest buy when the lowest open sell is in profit with the gap amount of pips. ( That is how I understood it or interpreted it in the closing details you posted).
Likewise, it will close the lowest sell if the highest open buy is in X_Diff amount of profit.
It actually does bother me that there are 2 buys open at the same price, I spent a lot of time (and lines of code) to make sure a buy stop doesn't open on or get modified to an already open order price.
I'll check that out again.

#71 - January 23, 2019, 09:03:58 PM
« Last Edit: January 23, 2019, 09:06:57 PM by Francoisvs »

  • Jr. Member
  • Posts: 62
  • Points: 0
  • Likes Received: 14
  • Reputation: +1/-0
That logic is good but if you examine the screenshot it's not doing that. T
#72 - January 23, 2019, 09:16:16 PM

  • Sr. Member
  • Posts: 352
  • Points: 71
  • Likes Received: 150
  • Reputation: +11/-0
I have to ask.
The screenshot looks like a mobile device.

Did you load the EA on your PC, and then switched the PC off? 
I would like  to see the screenshot from your PC, especially the top left corner where the EA will update very important info, ie, the buy close target and sell close target.
#73 - January 23, 2019, 09:22:01 PM

  • Jr. Member
  • Posts: 62
  • Points: 0
  • Likes Received: 14
  • Reputation: +1/-0
You should ask because you are dealing with a computer idiot :-X... But no, I didn't turn it off this time. I'll carry on testing but I'm sure it is not closing as per your logic. T
#74 - January 23, 2019, 09:28:09 PM

  • Jr. Member
  • Posts: 62
  • Points: 0
  • Likes Received: 14
  • Reputation: +1/-0
Would a stop loss of gap x grid size work?
#75 - January 23, 2019, 09:39:51 PM

Members:

0 Members and 1 Guest are viewing this topic.