Please forgive my ignorance with all of this. I have started to learn mql4 a couple of days ago and I have no previous coding experience. I was
very proud of my first script when I realised that I misunderstood how scripts work. Of course what I need is an EA. The basis of what I need it to
do is extremely simple, but I am getting very confused with trying to translate my -broken because they don't work how I thought they do-
script into a usable EA. When I try to backtest how I think it might work, I end up in infinite loops or with nothing happening at all. I think it
should be some simple extra functions which I need to input but I could use some guidance as I am getting frustrated.
Here is my very clunky code at the moment. Hopefully it is clear what I want to do.
extern int TakeProfit = 0;
extern int StopLoss = 200;
double price= 1.81550;
double lotsize1= 0.01;
StopLossLevel = price+0.0050 - StopLoss*Point;
ticket = OrderSend (Symbol(), OP_BUYSTOP,lotsize1,price,10,0,0,"Lot1",0,0,clrRed);
ticket2 = OrderSend (Symbol(), OP_BUYSTOP,lotsize1,price+0.0050,10,StopLossLevel,0,"Lot2",0,0,clrRed);
if(Ask > price+0.005)
Alert ("ticket modified");
res = OrderModify(ticket,price,StopLossLevel,0,0,clrNONE);
ticket3 = OrderSend (Symbol(), OP_BUYLIMIT,lotsize1,StopLossLevel+0.0002,10,0,0,"LotLimit1",0,0,clrRed);
I just want the EA to place 2 Buy stops. If the price reaches the second Buy Stop, I want the one lower to place a Stop
Loss in the same place as the second, as well as this I want a new Buy Limit to be activated 2 pips above the stop loss.
I only want this to be done once.Any help with how to go about this would be greatly appreciated.
Thanks so much.Fred
First, you should use OnTick() instead of OnStart().