Coding a looping function

 

Hello,

I'm trying to code a repeating (looping) function. I'm not looking for the entire program (EA), just the function that will do the following:

Buy at price A

Place stop at A-50

If stopped out buy again at A+50

Place new stop at A

If stopped out buy again at A+100

Place new stop at A-50

Keep repeating indefinitely.

As you can see, the stop is always a consistent distance behind the entry (in this case 50 pips)

Whenever we are stopped out a new order is placed a consistent distance above the price that was just stopped out. (in this case 100 pips)

Thanks in advance for the help.

Brian

 
You can't do that within a single function (easily). The start function is called every time there is a new price.
 
4000:

Hello,

I'm trying to code a repeating (looping) function. I'm not looking for the entire program (EA), just the function that will do the following:

Buy at price A

Place stop at A-50

If stopped out buy again at A+50

Place new stop at A

If stopped out buy again at A+100

Place new stop at A-50

Keep repeating indefinitely.

As you can see, the stop is always a consistent distance behind the entry (in this case 50 pips)

Whenever we are stopped out a new order is placed a consistent distance above the price that was just stopped out. (in this case 100 pips)

Thanks in advance for the help.

Brian


keep trying

for help show your attempt