I took some time since my last thread to go through the MQ4 tutorials and learn more about coding.
Thats my first attempt to code a EA from scratch, since the last one had some borrowed code on it.
The idea is to have a buy order open as soon as a "Bid" is detected above the 10MA and have another identical sell order open at the first "Ask" below the 10MA
Unfortunately it still does not work at all.
I'm not looking for somebody to code something for me but to point what I'm doing wrong since my goal is to learn how to code.
Thanks in advance for the help
Thats my first attempt to code a EA from scratch, since the last one had some borrowed code on it.
The idea is to have a buy order open as soon as a "Bid" is detected above the 10MA and have another identical sell order open at the first "Ask" below the 10MA
Unfortunately it still does not work at all.
I'm not looking for somebody to code something for me but to point what I'm doing wrong since my goal is to learn how to code.
Thanks in advance for the help
Inserted Code
double MA; double bid; int ticketbuy; int ticketsell; int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- bid=Bid; MA=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0); if (bid > MA && ticketbuy<0 ) //first bid above MA will trigger buy order //if buy order is not already open ticketbuy=OrderSend(Symbol(),Ask,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16001,0,Green);// trigger command if (Ask < MA && ticketsell<0 ) //first Ask below MA will trigger sell order //if sell order is not already open ticketsell=OrderSend(Symbol(),Bid,1,Bid,3,Bid-25*Point,Bid+25*Point,"My order #0",16000,0,Green);// trigger command if(ticketbuy<0) { Print("OrderSend failed with error #",GetLastError());//erros report return(0); if(ticketsell<0) { Print("OrderSend failed with error #",GetLastError());//erros report return(0); //---- return(0); } } } //+------------------------------------------------------------------+