Code Library / Grid Trading
MQL4 Grid Trading EA
Simple grid trading EA placing buy and sell orders at fixed intervals.
Language: MQL4 · Category: Grid Trading · Tags: grid, MQL4, EA, grid trading, automated
Source code
input double GridSize=20; input double LotSize=0.01; input int GridLevels=5;
void PlaceGrid() {
double pt=MarketInfo(Symbol(),MODE_POINT), step=GridSize*pt;
for(int i=1;i<=GridLevels;i++) {
OrderSend(Symbol(),OP_BUYLIMIT,LotSize,Ask-step*i,3,Ask-step*(i+1),Ask-step*(i-1),"Grid");
OrderSend(Symbol(),OP_SELLLIMIT,LotSize,Bid+step*i,3,Bid+step*(i+1),Bid+step*(i-1),"Grid");
}
}How to use this snippet
This is a building block, not a finished trading system. Paste it into your own MQL4 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.