First attempt at creating a scalp EA help plz :D

 
Hello everyone, I have a trading strategy that I would like to put into an EA. I am new to programming/coding and plan on having the EA completed from start to finish in under 90 days. I have no prior programming knowledge and no resources aside from the internet to help me complete this task. I wonder if it would be easier to use the visual builder you can purchase to make this bot, but before I do, I'm wanting to know if the visual builder will allow me to create this type of strategy. I want to make a EA that will be able to identify tight points of consolidation and then take a trade on the breakout in either direction and have it set a stop (maybe a trailing stop) and a TP. I'm not sure about what time frames I would like to test it on, but I know that EA's dont really see candle sticks like we do, so I will need to somehow break it down to an average between numbers and times. For example, to identify consolidation maybe I could have the EA take a look at the previous hour or so of data on a 5m chart, if the EA can somehow identify a range of pips I have set (for example if the price fluctuated between 0.0090 and 0.0100 for 20 candles,or 1 hour of time straight, the goal would be when price breaks out of that consolidation to take the trade in either direction that price went and set a stop and TP accordingly. I have an idea in my head of what I want to be able to do, as well as the numbers for a set strategy. I know absolutely nothing about coding and programming and any help or examples and resources to learn from would be great. I believe the strategy I want to implement will have a 80+% success rate, but I will have to dedicate around 3 months of my life learning how to code. Thanks in advance everyone who is willing to help.  
 

Why do you want to re-event the wheel, while you can get ready made cars here?

Just type scalping in the search (the lens top right) and you will find more than 600 pages (only here): https://www.mql5.com/en/search#!keyword=scalping.

Pick one and amend it according your ideas!

Search - MQL5.community
Search - MQL5.community
  • www.mql5.com
Searching is based on morphology and is insensitive to case. All letters, no matter of their case, will be processed as lowercase. By default, our search engine shows pages, that...
 
Carl Schreiber:

Why do you want to re-event the wheel, while you can get ready made cars here?

Just type scalping in the search (the lens top right) and you will find more than 600 pages (only here): https://www.mql5.com/en/search#!keyword=scalping.

Pick one and amend it according your ideas!

To be 100% honest with you I would like to learn programming in general, and I don't know how to view the code of even the free scalp bots they have for download. I'd like this adventure to be the first item in my portfolio as a programmer. I appreciate the advice though, those bots sounds amazing. I want the knowledge to program my own in case all of the programmers in the world go extinct one day. I'm starting today at a hello world bot, and from this point will hopefully have the scalp bot of my dreams completed. 89 days to go.
 

Look at this:

https://www.mql5.com/en/code/20273

You may actually want to read John Bollinger's book on the Squeeze model (pirate copies are floating all over the net).

I myself trade something similar, except based on Bill Williams Fractals and Alligator and manual designation of squeezing and breaking out (you may read his books as well, also plenty of pirate copies available).

Look at ready made expert in Code Base for trade classes and implemented generic trade functions.

In general, look up the Code Base (and Documentation) for code similar to what you want. Most things are already written, you only need to understand them and copy-paste in your "own" code.

Whatever you don't understand look it up in Documentation. MQL Documentation is well written with lots of examples, it will offer the best explanations to most of your future questions. 

TTMS
TTMS
  • www.mql5.com
The Trade The Markets Squeeze indicator. The main idea is to trade only when Bollinger Bands are located within Keltner Bands and thus form trade zones. The indicator is drawn as a histogram with signal labels along the center line. It has seven configurable parameters: BB period - Bollinger Bands calculation period; BB deviation - Bollinger...
 
joethemoneygod:
To be 100% honest with you I would like to learn programming in general, and I don't know how to view the code of even the free scalp bots they have for download. I'd like this adventure to be the first item in my portfolio as a programmer. I appreciate the advice though, those bots sounds amazing. I want the knowledge to program my own in case all of the programmers in the world go extinct one day. I'm starting today at a hello world bot, and from this point will hopefully have the scalp bot of my dreams completed. 89 days to go.

In my opinion it is the best way to learn if you start from a working example and then you start to change this and that. You will be a lot faster than tapping into each trap and pitfall!

 
kypa:

Look at this:

https://www.mql5.com/en/code/20273

You may actually want to read John Bollinger's book on the Squeeze model (pirate copies are floating all over the net).

I myself trade something similar, except based on Bill Williams Fractals and Alligator and manual designation of squeezing and breaking out (you may read his books as well, also plenty of pirate copies available).

Look at ready made expert in Code Base for trade classes and implemented generic trade functions.

In general, look up the Code Base (and Documentation) for code similar to what you want. Most things are already written, you only need to understand them and copy-paste in your "own" code.

Whatever you don't understand look it up in Documentation. MQL Documentation is well written with lots of examples, it will offer the best explanations to most of your future questions. 

Thanks for the reply. I really appreciate the advice and the link. I was also wondering is there a huge difference between MQL4 and MQL5 language? I have heard that they are going to soon discontinue metatrader 4. I wonder if it would be smarter to just start building the EA in MQl5 just in case.
 

Also guys, I am really trying to create a EA based on strictly price action that involves no indicators. The equation would sound something like this.


I don't know how to put any of this into lines of code yet, but I will hopefully have it down in the next 90 days putting in 2 hours a day learning programming.

*The bot would scan the last 60 minutes of time that has passed every tick (I want to run the bot on the 5 minute time frame as well).

*IF (I just learned about ifthen else statements today as well lol). Anyways, IF the price has been stuck in a tight range, lets just say bouncing back and fourth between 8 pips (since I will be back testing the numbers until the bot is profitable.) I want the EA recognize that price has been stuck in that range for a certain period of time. (minimum amount of time being like 20 min or so like I said I will have to back test these numbers to produce maximum number of winning trades.) Then when price breaks out of that 8 pip range (long or short) that the bot has identified, I want the bot to immediately place an order on the direction it broke out in, as well as place a trailing stop 1 pip below entry and a TP 3 pips above entry. This is of course a rough draft.


Also I would like to somehow create a code that will not let the EA take a trade if the spread is too large. 


So far I have learned a tiny bit about MQL4 in the 3 hours I have spent studying the language. Many of the variables above such as the Stop loss, or trailing stop, and the TP levels I think I can put as "EXTERN INTERGERS" but I wonder if the bot will already know that I am talking about PIPS when I say I want take profit at 3 etc... I dont know lol, it really makes my head hurt right now thinking about all the other variables to the situation I will have to include but hopefully it will be well worth the headache.

I think I will make my bot open source and will be posting the code on here for help etc if need be, if that's allowed on the forums anyway.

Basic Principles - Trading Operations - MetaTrader 5
Basic Principles - Trading Operations - MetaTrader 5
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 

It's very hard to talk with words only.

Maybe you can post the code you have written so far or make a flow chart here: http://draw.io

draw.io - free flowchart maker and diagrams online
draw.io - free flowchart maker and diagrams online
  • draw.io
draw.io (formerly Diagramly) is free online diagram software. You can use it as a flowchart maker, network diagram software, to create UML online, as an ER diagram tool, to design database schema...
 
try this.. https://www.mql5.com/en/articles/4951
Visual strategy builder. Creating trading robots without programming
Visual strategy builder. Creating trading robots without programming
  • www.mql5.com
Algotrading and the ability to check trading ideas on historical data in the strategy tester are the most important functions of the MetaTrader5 trading platform. But in order to use the trading strategy in automatic trading mode on a real time chart or in a strategy tester, it needs to be programmed and turned into an executable file (Expert...
 
Alright, so here is my strategy. I want the EA to be able to identify when price is stuck in a tight range (consolidation) for a certain period of time (20 minutes or so.)

So lets say that on the 5M candle chart, the price consolidates between a 3 pip range. so for example like 110.820 to 110.850. I need to have the EA somehow be able to identify that price is stuck with in a tight price range. maximum being 3 pips or so. So with in the on tick function I will need to have the EA look at the highs and lows of the last 4 candles (or 20 minutes of time.) and Identify if the highs and lows have been stuck in a 3 pip range. I am struggling to be able to put this equation into a code as I dont fully understand the datetime/high,low functions and how to use them together.

After the EA identifies the there has been a tight range for atleast 20 minutes of time, on the tick that breaks out of this specific range, I want the EA to place a trade (long if the price breaks above the range, and short, if the price breaks below the range.) and set stop/take profit according to the eternal veriables set up before the bot runs.

This is simple enough to put into words but is very difficult to put into code (for me being enw anyways) I am going to start writing the actual EA code this weekend and see what I can come up with, but for now, I have the external variables I want to be able to manipulate for backtesting purposes without editing code as they will remain constant while the EA runs.

extern double TP = 3;
extern double Lots = 0.01;
extern double TrailingStop = 3;
extern double SL = 1
extern double piprange = 3
extern double timerange = 20 (minutes)
extern double maxspread = (undefined for now.)

There will be many more issues to deal with as I progress such as spread limits, open order counts etc, but we will cross those bridges one at a time.
 
Marco vd Heijden:

It's very hard to talk with words only.

Maybe you can post the code you have written so far or make a flow chart here: http://draw.ioThis is a 

This is a rough draft of what the idea is, maybe you could help me put it inot a code? I'll ay you to teach me lol



extern double TP = 3; 

extern double Lots = 0.01;

extern double TrailingStop = 3;

extern double SL = 1

extern double piprange = 3

extern double timerange = 20 (minutes)

// possible booleon var may include trailing stop of true/false.


//Init or start functions

void on tic

Get HL

High[1]

Low[1]

High[2]

Low[2]

High[3]

Low[3]

High[4]

Low[4]


Start Analysis1


If difference between High[1] and Low[1] <= 3*PIPS (or var pip range)


call Analysis2

Else start over on tic.


start Analysis2

If difference between High[2] and Low[2] <= 3*PIPS (or var pip range)


call Analysis3

Else start over Analysis1 on tic.


start Analysis3

If difference between High[3] and Low[3] <= 3*PIPS (or var pip range)


call Analysis4

Else start over Analysis1 on tic.


start Analysis4

If difference between High[4] and Low[4] <= 3*PIPS (or var pip range)


Call looktotrade function.


if price next tic is <= High[4] and >= Low[4]

then start Analysis1 fuction


if price > High[4], placeorder buy order with SL (or trailing SL) and TP

 

else if price < Low[4], placeorder sell order with SL (or trailing stops and TP)

Reason: