Ledge ATR Strategy
Forums › ProRealTime English forum › ProOrder support › Ledge ATR Strategy
- This topic has 22 replies, 5 voices, and was last updated 7 years ago by
RoLaDay.
-
-
08/25/2017 at 2:49 PM #44636
Hello,
I would love to create a strategy for the ATR Ledge Indicator. Maybe someone is able to help? It is currently not working and I don’t know why..
1234567891011121314151617181920212223242526272829303132333435363738394041if time = 010500 thenATRperiod = 14// ---dTR = 0for i = 0 to ATRperioddTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))nextavg = dTR/ATRperiodhtr = Dlow(0)+avg[1]ltr = Dhigh(0)-avg[1]ab=(htr-ltr)/2*1+ltrb=(htr-ab)/4*2+abc=(htr-ab)/4*1+ab+0.0003d=(ab-ltr)/4*3+ltr-0.0003e=(ab-ltr)/4*2+ltrif not longonmarket and close<c thenbuy 1 share at c stopendifif not shortonmarket and close>d thensellshort 1 share at d stopendifif longonmarket thensell at b stopsell at d limitelsif shortonmarket thenexitshort at e stopexitshort at c limitendifendifThanks a lot!
08/28/2017 at 12:46 PM #44756I did not test your code, but the first thing I can tell you is that your pending orders (STOP and LIMIT ones) are only set at 010500 time and only for 1 bar.
Pending orders only last 1 bar and should be placed at market each new bar.
08/29/2017 at 9:02 AM #4479608/29/2017 at 9:19 AM #44800A market order will executed with the open of the next bar, so this should NOT be repeated every bar. Limit- and stop-orders on the other hand are only valid one bar and have to repeated if this is what you desire.
The only pending orders that do not have to repeated are the once you put with the set command (set stop loss for example).
08/29/2017 at 9:46 AM #44808ok I understand. But I really don’t have a clue how to solve the problem. If I change the code to “buy / sellshort 1 share at market” instead of “stop” it only buys at the particular time and it does ignore the other condition.
I want to buy if it’s over c and set a stop at d. Target would be b. And I want to sell if it’s under d and set stop at c. Target would be e.
I don’t have a clue how to change the stop order to something else.
08/29/2017 at 9:56 AM #44810123456789101112if close>c thenbuy 1 contract at marketelsif close<d thensellshort 1 contract at marketendifif longonmarket thensell at b limitsell at d stopelsif shortonmarket thenexitshort at e limitexitshort at c stopendifHere you go.
08/29/2017 at 10:47 AM #4481408/29/2017 at 11:08 AM #4482008/29/2017 at 11:30 AM #4482508/29/2017 at 11:30 AM #44826The problem is that the code above is not working. I want to use it for Forex. Nicolas said that my pending orders are only set at 010500. I want to change this that ithe system starts when the specific entry points are reached and not a specific time. Your code is looking good for me too but it doesn’t work
08/29/2017 at 11:39 AM #44828I don’t know for which instruments your strategy is, your code seems correct, but you should try to code it into 2 different parts instead: one that calculate the price levels for your pending orders at 010500 and one that continuously put your pending orders until one of them triggered.
08/29/2017 at 12:13 PM #44836Sounds complicated. Any recommendations or is there a guide how I can code it into 2 different parts?
There is a picture of the indicator attached. I want to buy at the first green line in the middle and sell at the second, vice versa sell at the first red line from the middle and target profit at the second red line.
08/29/2017 at 3:53 PM #44865I think you also want the only one position is open until it reaches the goal or the stop again? Would the market move to the first green line in a sideways movement, which could be fatal if strategy X opened positions?
I am quite good at developing strategies myself, but I have no idea of programming myself, I only manage to mend strategies from others.
08/29/2017 at 5:59 PM #4487308/30/2017 at 7:09 AM #44892 -
AuthorPosts
Find exclusive trading pro-tools on