BUILDING AN EXPERT ADVISOR

 

It comes to my mind a number games.

I want to make an EA based on a simple moving average crosses

If there is no Open Order...

If the fast moving average crosses above the slow moving average, it will execute buy position using i.e 0.01 lotsize.

OR

If the fast moving average crosses below the slow moving average, it will execute the sell position using i.e. 0.01 lotsize

The target profit is i.e. 2.50.

If the profit >= target profit, close the order.

But, if the profit < the target profit... and the moving average crosses again, it will open another position (either a buy or a sell) using 0.02 lotsize (orig. lotsize x 2)

Again, if the profit>= target profit, automatically close all the open trades (2 open positions).

but, if the profit < target profit and the moving averages crosses again, it will open another position (either a buy or a sell) using 0.04 lotsize (orig. lotsize x 4)

if the profit >=target profit, automatically close the all the open trades ( 3 open positions).

but, if the < target profit and the moving averages crosses again, it will open another trade using 0.08 lotsize (orig. lotsize x 8)

and so on....and on...and on... 

I started studying how to code, I started it. I am now reaching in Moving Averages and itworks. My EA now make positions (buy or sell) without stop loss

Now, I dont know what to do next. I need to move to another that it can increase the lotsize by multiplying it by 2.

Then I will proceed to closing open all open positions when it reaches my target profit.


//my simple EA

extern double Lot = 0.01;

extern double Target = 2.50;

int FastMA, .....

int SlowMA....

and so on...

Please Help Me, I know my analysis will work even it will give a small profit but i know it will work. God Bless Us all


Sincerily,


NIECO PAMA

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...
 

You'd better start searching. I guess this alreday exits - no need to re-invent the wheel!

Top right you have the lense, enter "EA based on a simple moving average crosses" ...

 

But, are they changing the lot size? Moving Average crosses is simple and easy but changing the lotsize is not easy as well as closing all open position (buy and sell position) altogether at the same time. Ive read some EAs but they close sell only or buy and monitored the profit on buy only or sell only, not both buy and sell. I mean if the profit in the buy position reaches their target..then they close the buy position only. Then they monitor the sell position and if reaches their target they close the sell position only. But here, what i mean is both position. The total profit target is reached it will close all the open position in the same currency pair

for example:

the buy position, uses 0.01 lotsize

if it reach the target profit, close the position

if not, i am sure it will open another sell position, using 0.02 lotsize

i am sure it will cover up the losses in 0.01 lot because the lot is multiplied by 2 this time.

if it reach the target profit, close the two open position, the buy and the sell open position.

if not, i am sure it will open another buy position, but this time it will using 0.04 lotsize.

and i am sure it will cover up the loosing open sell because the 1st open buy trade is 0.01 and the next open buy trade is 0.04 with the total of 0.05 lotsize, while the loosing trade uses only 0.02 lotsize

and so on, and on..and on.... the lotsize will be multiplied by two if the position still added...

 
use the already available mt4 terminal EA on moving average ;D
 
I think those moving average ea uses a fixed lot with a fixed take profit and fixed stop loss. And my idea didnt fit in it. I know how make that simple ea. 
Reason: