[Journey] - trading bot that may actually work

francisirving

Registered Member
Joined
Dec 22, 2013
Messages
64
Reaction score
46
I poked around on other sites but decided to create this journey here. For the past year I've been working on 2 things:
1) learning how to day trade forex, eth/btc and indices on foreign exchange (hankotrade, hugosway, etc)
2) trying to get a simple python bot that can make trades for me based on indicators

I'm a network engineer, not a programmer or trader so I had to learn the basics of python and trading at the same time. My bots are crude; they use pyautogui to take a screenshot of whatever im trading on the standalone Tradingview app with whatever indicators I have been trying. I've tried all sort of things like RSI, MACD, VWAP, machine learning, EMA, SMA and combinations of all previously mentioned with little success. In March of this year, I stumbled across Nick Sean on Youtube and his style of support and resistance trading. It changed my life as watching his videos and being in his free Telegram channel slowly started showing me what it takes to trade, especially the mindset. That's not a plug, you can find all his stuff for free on youtube.

Getting back to the bot, I shifted my strategy away from trying to win trades, to a concept of 'win big on your winners and lose small on your losses'. Basically the Trading 101 stuff they teach you from the get-go. All my bot does is allow me to trade on a 1-minute timeframe 24x7. I currently am using 1 indicator called 'SWING TRADE SIGNALS' on tradingview. It's free.

I only changed the settings to get rid of the lines I dont use and just show the green arrow that tells me to buy and the red arrow that tells me to sell. Here's a screenie:
buysell.png

That's it, that's the strategy. I lose about 70% of the time and for the past week its made money everyday. It makes money because my risk/reward ratio most trading pair is about 3 or 5 to 1
I'm just keeping this journal as a sanity check for all the tweaking and adjustments I've been making on a daily basis for future tracking, and maybe hoping a lot smarter people then me have easier ways to do things.
 
Just a quick overview of my python bot:
- runs on an old Windows PC I have in my office.
- running on a demo account with ECN and 500x leverage
- 1 monitor that has the Tradingview app always up and the trading pairs i'm trading in a watchlist (like below)
1696285457179.png
- the python script is in 2 sections; the first section is the 'main' of the program. its a simple loop that does the following:
check and see if an open order for a certain pair exists
- if there is, skip that pair and go to the next trading pair after x seconds
if there isnt an order on that pair, go the logic file for that pair
the 2nd sections is the logic for the specific trading pair. each pair I trade has its own logic file that:
- clicks on the trading view screen for that pair via the watchlist (pyautogui)
- takes a screenshot of the current x coordinate for the latest price (roughly 12px wide) from the top of the screen to the bottom (pyautogui). if it see's the red/sell or green/buy arrow from my previous post, it opens a position in that direction
- go back to the 1st section and keep going down the list to check if there's an open order for the next trading pair and if not, go that that trading pairs logic. loops from top to bottom

as you can see from my screenshot, this was a 'buy' signal that opened a trade but then got 'stopped out' when it reached the bottom of the red section. I've observed that most of these trades dont putz around in the middle. They usually lose fast most of the time for a small loss, but if they when they win big. Well, they win big enough to keep the account value going up.

Right now I'm trading 3 pairs on a 1 minute timeframe:
ETHUSD - new today, tweaking and testing
XAUUSD (gold) - new today, tweaking and testing
NASUSD (nasdaq 100) - been doing good for the last few days. crap win/loss rate but 5.6R (at 0.01 lot size, $0.55'ish loss versus $3.50'ish win) has been keeping it in the green

doing some more stop loss(SL)/take profit(TP) tweaking on ETHUSD and XAUUSD pairs now. Here's a screenshot of the test account value:
1696286704061.png
rough day testing the new pairs, was about $311 this morning. Keep in mind I'm doing the bare minimum lot size (0.01) while testing. This is perfectly scalable by increasing the lot size to the max the account size will let you.
 
Do you have a git repo or your development id like to study your code and see if I can add implementation
 
Do you have a git repo or your development id like to study your code and see if I can add implementation
I'm going to work on that.the code is crap and constantly changing but ill get it cleaned up and find my git info
 
Good luck ! Seems like you have an interesting thing going on here. I’ve never really believed in trading bots but hey, if you can make it work then good for you!
 
Maybe an object-oriented analysis and design course/guide could help you improve your code. Even if you are not using OOP, it will surely be useful to you.

I don't know much about technical analysis, but in the first screenshot, the indicator you were using gave you a buy signal when a reversal pattern appeared, however it seems to work fine, curious.
 
github com/ firving58 / python-trading-bot
good luck, im not a programmer and im sure there are far easier ways to do this, but, meh works for me so far
 
Maybe an object-oriented analysis and design course/guide could help you improve your code. Even if you are not using OOP, it will surely be useful to you.

I don't know much about technical analysis, but in the first screenshot, the indicator you were using gave you a buy signal when a reversal pattern appeared, however it seems to work fine, curious.
its all just throwing rice at the wall with the indicator. i win some, lose many, its just a matter of seeing if I can make my winners worth far more than my losers
 
I'll have an update tomorrow. I made some adjustments to the EMA and SMA in the trading indicator, removed ETHUSD and adjusted the risk/reward a bit so I have to start the stats from scratch a little. I dont have the detailed wins losses but it was roughly:
US EST (10/3/2023 6pm est to 10/4/2023 9am est)
XAUUSD - 64 losses, 14 wins, $5.50 loss
NASUSD - 30 losses, 8 wins, $4.30 gain

I'll likely dump XAUUSD tomorrow depending on the outcome. NASUSD has been my big winner everyday, with lots of room for improvement.
I'm down overall because I've let the bot run during US EST trading hours (9ish to 5ish) the last 2 days and got decimated. Too much volatility. The bot seems to work better during slower market hours.
Making a slight tweak to the RR for NASUSD, restarting the bot at 6pm est and will check final results around 9am est tomorrow when I turn it off

1696449431498.png
 
its all just throwing rice at the wall with the indicator.
No indicator is going to give you correct signals all the time, otherwise everything would be very easy :p.

I remember that a while ago I saw an experiment with a bot that used the RSI strategy (and maybe the SMA crossover - I don't remember well) and it gave quite decent results.


winners worth far more than my losers
I think this is the first and most basic rule/goal in trading.
 
No indicator is going to give you correct signals all the time, otherwise everything would be very easy :p.

I remember that a while ago I saw an experiment with a bot that used the RSI strategy (and maybe the SMA crossover - I don't remember well) and it gave quite decent results.



I think this is the first and most basic rule/goal in trading.
Agreed. This isn't about a bot that's trying to determine winners, it's a strategy to manage risk. The bot simply allows me to make a lot of trades in a shorter period of time. The risk management comes in with how far I can stretch my risk to reward ratio and be profitable. I'd love to find an indicator strategy that gives me a 50/50 win ratio because with the right RR I'd be retired before you know it. I think in my first post I said I'm a big fan of Nick Sean on Youtube. He uses support and resistance as an 'indicator' and is constantly stating how he is only right half the time, if he is lucky. The profit comes from managing your risk. For now I'm using this simple breakout indicator. The point of the indicator is not to state 'the price is going to go up or down' but to state 'something could happen soon' and when if it swings your way you make more then you lose. We'll see how it goes over the next month.
 
For the 1st time NASUSD was a complete loss, no winners at all:

NASUSD
Losses 14 -$7.20
Wins 0

XAUUSD
Losses 24 -$8.93
Wins 3 $5.15

total losses overnight: -$10.98
just a sampling of some of the losses:
223.png
This was a very aggressive 10R, so if I had won at least 2 positions it would have made a profit. Looks like 6.5R was the sweet spot last night which would easily made it profitable. I haven't touched the stop loss of 5pips in days, its safe enough and doesn't make a huge difference at this point.
Not thrilled with XAUUSD, still not seeing a way to make it work, but I'll run it overnight again.
Moving on to the next night with some RR adjustments I suppose.

On a positive note, I have my new bot up and running right now during business hours and will run it overnight to see how it does.
I call it my 'a_to_b' bot. What it does is open a position once it sees a buy or sell indicator like I have been doing and keeps the position open until the opposite indicator pops up.
In a range like below it won't do much, hopefully just keep opening/closing positions at a small loss:

22range.png

But what I'm hoping it does is give me some nice profits when you get a runner, like so:

abbot.png

It's been testing nice today in the fact that I manually close the position when I want and have made profit. I might try this on a live account during the day since I shouldn't miss any or most openings. We'll see how it goes.
 
There’s a python lib for MetaTrader you can make use of. Of course if you are using metatrader as your trading platform.
 
really interested to see if you can make this profitable, good luck
 
There’s a python lib for MetaTrader you can make use of. Of course if you are using metatrader as your trading platform.
yessir I'm using it. MT5 with the python libraries. It's nice because not only can I extract data out of the trades I do my order submits and closes it with it.
 
yessir I'm using it. MT5 with the python libraries. It's nice because not only can I extract data out of the trades I do my order submits and closes it with it.
Why do you use PAG then? There is no point in driving mouse and keyboard in that case. You can pipe all data you get from meta to pandas, do some logic and execute trade afterwards.
 
Why do you use PAG then? There is no point in driving mouse and keyboard in that case. You can pipe all data you get from meta to pandas, do some logic and execute trade afterwards.
I'll look into that. I'd like to move to a 'headless' setup (no pag) but have been limited by time and ability.
 
Back
Top