Posts

Showing posts from December, 2024

Momentum

 01/01/25     12:38 As per our discussion I altered the way the lines were being identified by using the 0 or 1 reference built in to MT4 and this seemed to eliminate many of the clusters of bad sell trades that were losing money and consequently after the optimisation took the profit up to over $2400.  And now I will be working on adding momentum detection to the lines crossover to allow the trades to initialise earlier.  With strong momentum the line difference criteria for trade entry can be smaller and therefore closer to the crossover point. The primary indicator is the angle of the lines - closer to a 45 degree the more likely to continue and separate into a larger trend.  The AI suggested factor is magnitude , which is how many bars the direction has been consistent for.  So combining these will give an industry standard indication of momentum that can then be used to reduce the minLineDifference and open trades earlier.  I'm thinking that...

Stops and line based entry validation

 22/12/24      12:55pm Now that the robot is buying and selling at relatively the right time, this morning has been about working on parameters for the minimum line difference setting.  This is what is being used to determine trend.  There are still a lot of small intermediate trades that I am trying to eliminate with this setting.  Initally starting at 0.00025 this has been increased greatly to 0.04 then 0.05 on the advice of the AI after feeding it the logs and trade results from all the tests.  A lot of small trades are still hitting stop loss early so working on that by implementing what you suggested - raising stops only after certain level of profit has been reached and by increasing the size of the trailing stop.  I know you said not to have a trailing stop but after discussion with the AI it said not having one was practically the same as just increasing the size of it so it doesn't interfere with trades but still has protection from ...
 19/12/24     09:25am Had a quick look this morning before I head out.  Just ran the test this morning after last nights changes that enabled it to operate on the core logic properly and for the first time ever it made a profit!  The test ran from the 1st of November until the present and closed at $10024, a profit of $24!  Might not seem much but once I filter out all the intermediary trades and get it reading the PV2 lines more accurately and ignoring the spikes it should be considerably better.  That is also not including coding for the flat periods, just: White > Red = Buy and White < Red = Sell The biggest profit of the tes was $83.84 and the biggest loss was $-15.84. Which is considerate since when I first started $30 - $40 losses were common. So I am very happy with this data and I think this is a milestone to be remembered.

Strip back to core functionality

 18/12/24     10:40 am Universality for any chart added. 7:41 pm Stripped out all excess entry filters and parameters to focus solely on the White above red functionality and line difference and still wasn't trading properly.  Deactivated the line difference also so the single parameter of white above or below red was the only determining factor for entering trades which revealed issues with how the code is interpreting the data from the White/Red buffers (values) so currently isolating and exploring this code to get it to open a buy when white is above red and then close the buy and open a sell when white crosses below.  So not including the line difference or any other parameters to get this core functionality perfect.  As it is the robot is putting a ton of excess trades on in large clusters and when zooming in looks like it is affected  by spikes in the data or in the price data which it should not be looking at. Obviously there are no spikes in th...

Moved house

 17/12/24     12:17 Well I have moved into my new house and am able to get some time on the computer.  Had a little look at the robot this evening after getting it running properly. And it looks to befunctioning relatively correctly.  It is looking to make trades but rejecting them because of the criteria for entry being too strict.  Which is ok for now, I just wanted to make sure it was functioning properly, which it is.  Over the next few days I'll be looking at refining the entry criteria to mirror as accurately as possible the entry conditions you showed me with the spreading of the red and white lines and use that as the indicator of trend to enter buy/sell positions.

Problem fixed

 13//12/2024 21:45 Ok, I have found and fixed the problem.  After isolating it down to the most basic function that the EA could possibly perform and having it not able to undertake that task showed that it really had to be something in MT4 itself.   So I downloaded a generic copy of MT4 and had a look at the difference between the two and when I compared their options I found the difference.  I thought I had ticked the check box for 'Allow automated trading' but apparently I hadn't and so I ticked the box and abracadabra it all works fine now.  The strange thing is I'm sure I remember ticking the box and I even had the EA trading automatically earlier!  It was only when I started to implement logging that it stopped working.  So who knows how the box got unticked or if it has been unticked all along but at least now it is working fine again and I can get on with building the robot.  Hallelujah!
 11/15/24 17:11 Spent the morning and early arvo still troubleshooting the logging system but to no avail.  Tried to write to different locations in C:\ and the user documents directory but still nothing.  All permissions are correct but still nothing.  Simplified it to the bare bones and still nothing.  So wierd considering it was working fine earlier which points to the problem being in the code..  So considering the AI has exhausted all practical pathways for isolating the problem I have deleted all the logging data and am starting again, relatively.  I have transferred all the logging to be printed in the terminal window instead of being written to a created file.  Immediately encountering problems with printing to the terminal window relating to code relating to detection of bars in the OnTick fucntion.  Could be the root cause of everything, could be unrelated. will know soon. 18:13 Some responses from the AI: We're still not seeing the...
7/12/24 10:14 Well yesterday wasn't much better than the day before.  I have needed to get some robust logging functions into the code but there have been issues with creating directories, filenames, timestamps, one thing after another.  Finally got there though and have some logs being created that record the specific data I need to diagnose issues.  That was pretty much the whole day.  Managed to get a little bit of parameter tuning in at the end but didn't really get anywhere with it, however it did highlight a very important issue with the indicator readings and how they are interpreted by the code which is what I will look at today. 11:31 On the indicator there is a zero line.  So sometimes the indicator readings are both negative, both positive, or one degative and the other positive.  Took a while to figure all this out but we got there eventually.  All sorted now.  Moved on to getting some trades happening and investigating what is prevent...
 4/12/24  11:30pm Ugh terrible day today, made some code alterations in the morning which broke the code and wasn't able to get the EA to make any trades at all for the rest of the day.  Spent the rest of the day tracking down the problems.  It all resulted from the AI making code alterations without first analysing and understanding the code to ensure core functionality is maintained.  I thought this bug had been fixed in Claude since it had not done it so far but no it is still an issue.  So to account for this I have provided detailed instructions for Claude to follow when analysing and making code suggestions as a permanent artifact (reference file). Hopefully a better day tomorrow. On the upside I did learn a bit more about the trading filters the code is using (standard trading indicators) to improve trade entry such as RSI (Relative Strength Index,  measures the speed and magnitude of price changes ), ADX (Average Directional Index, measures tre...
3/12/24  4:32 Spent most of the day working through the errors and getting to base functionality.  It is now making actual trades on the demo account.  I am using the last three months of the NZDJPY to test it and now it seems to be working fine.  Certainly not profitable but its is working.  I have tweaked some of the parameters based on the AI feedback of the MT4 strategy tester log files but it is still nowhere near profitable (based on the 85 point spread the changed SL from 50 to 200, TP from 100 to 400, and trailing stop to 200 to match the stop loss)  But at least it is working as it should, it is reading the values from the indicator and making trades.  There are many suggestions for improvement from the AI and I have just implemented some entry filter code to reduce the number of quick reversals.... we'll see how that goes before progressing with some of the other suggestions. 10:30pm After much testing and retesting throughout the day with re...

Code alterations

3/12/24 09:09 Key changes made: Removed all news-related code (don't know why it added that anyway) Removed horizontal market detection (redundant if trend analysis and stops are set correctly) Added new trend analysis based on: TrendLength parameter MinRateThreshold parameter MinLineDifference parameter for red/white line separation Modified main trading logic to: First check if red line is above white line by minimum difference Calculate rate of change over trend length period Open positions based on trend direction if threshold is met Maintained all risk management features: Stop loss and take profit Trailing stop functionality Position sizing options Kept core trading hours functionality (possibly unnecessary but leave for now) Maintained logging and reporting system The main trading logic is now in OnTick(): First checks if red line is sufficiently above white line If not, closes all positions If yes, calculates trend strength and direction Opens ...

Testing result

3/12/2024 08:00 Testing result was a fail. Reported that  3600 passes were done with 3600 results discarded as insignificant. Simplified it down to a single variable, the trend consistency period, which ran 12 passes and again all discarded as insignificant. I switched to the moving average robot to test the strategy tester and sure enough it brought back some profitable results so nothing wrong with the tester. I did notice something about the PV trend last night and had some realisations that could simplify and improve the algorithm which I will discuss with you... and the AI. Back into it this morning. 

Testing the Robot

Spent the afternoon and evening testing and optimising the robot on the 2023 data for the NZDJPY. There are/were many input variables being tested, so many and on such a large amount of data that the test was only half way through at 11pm so I will leave it running through the night. Optimisation tests a range of parameters for each given variable so will iterate through every possible combination finding the most successful configuration. There are other variables that could be tested  but the ones currently included are the main ones. Ranges also could be expanded but I've kept it close to the AI defaults.