Define the current price of my open position
02/17/2017 at 1:44 AM #25354
Dear all, my name’s Giovanni and this is my first post in this forum.
I was wondering if, using an automatic trading system, I can manage my open position in this way:
- identify current price of my open position
- move an order accordingly to my actual price, without waiting the end of the bar.
let me give an example: I run my system with a timeframe = 1 day and when market opens, I open a long position and define a stop as a sell order “stop” at level L1 (obviously < of opening price).
If market goes up in the same day, let’s say 20 pips up, I want to move up my sell order of 20 pips, to set risk to zero.
Again in the same day, price moves up 15 pips again, and I want to move up my stop order by 15 pips and so on.
just to recap: I’d like to simulate a trailing stop in the same bar, managing the stop level at my will.
Does anybody has faced a similar issue and found a solution?
thank you all02/17/2017 at 9:00 AM #2535802/17/2017 at 10:31 AM #2537302/17/2017 at 10:45 AM #2537402/17/2017 at 11:36 AM #25385
ok, but the TRAILING STOP give me a well defined and always equal movement.
in this way the stop is moved closer to the price at each pip variation, correct?
in case of a long position: what if I want a Trailing stop moving from a Fibonacci’s level to the following one, only when the price touch an higher fibonacci level?
e.g. initial stop at the bottom of the previous candle (simple to set). The price moves up, touching the first Fibo extension (138%), I want to move my stop to the open price, to eliminate the trading risk. The price moves again up, touching the second extension (161%) and I want to move my stop to the first Fibo extension (138%) and so on…02/17/2017 at 1:28 PM #2539802/17/2017 at 2:13 PM #2540302/17/2017 at 5:13 PM #25438
Ok but doing calculation and moving the stoploss accordingly to the Fibonacci levels will not be done inside a bar. Until we do not have multitimeframe support (which will come in the first half of this year hopefully), we can’t do much more here :/02/20/2017 at 1:10 AM #2567103/17/2019 at 12:08 AM #93878
e.g. initial stop at the bottom of the previous candle (simple to set). The price moves up, touching the first Fibo extension (138%), I want to move my stop to the open price, to eliminate the trading risk. The price moves again up, touching the second extension (161%) and I want to move my stop to the first Fibo extension (138%) and so on…
have you been able to code this trailing stop; I coded this but it does not work in IG; the trailing Stop il not following the levels of Fibo ;-( do you have any clue why?
do you have a hint for this ?
Cheers1234567891011121314151617181920212223242526272829303132333435363738if not ONMARKET thenBuy positionSize CONTRACTS AT MarketTrailStop = fibo0 - divendifif LONGONMARKET thenif close > fibo236 thenTrailStop = fibo0endifif close > fibo236 and close < fibo382 thenTrailStop = fibo236endifif close > fibo382 and close < fibo500 thenTrailStop = fibo382endifif close > fibo500 and close < fibo618 thenTrailStop = fibo500endifif close > fibo618 and close < fibo764 thenTrailStop = fibo618endifif close > fibo764 and close < fibo100 thenTrailStop = fibo618endifif close > fibo100 thenSELL AT MARKETendifSELL at TrailStop stopendif03/17/2019 at 8:48 AM #93883
You don’t need lines 6 and 38. This will stop the pending sell order from being placed until the bar you enter the market on has closed. Maybe you intend for it the trailing stop not to be activated until one bar has closed?
I’m not sure if this is the reason why it is not working as you think it should though. I would double check your fibo levels using GRAPHONPRICE.03/18/2019 at 10:58 AM #939331234if not ONMARKET thenBuy positionSize CONTRACTS AT MarketTrailStop = fibo0 - divendif
Is there more code we are not seeing? Is my coffee not working? 🙂
You have not defined the fibo levels (fibo236, 382 etc) or the div??03/18/2019 at 12:01 PM #93939
Is there more code we are not seeing?
Simple answer = yes! Kris75 has not included the calculations for the fibonacci levels, the position size or the value of div. However we can see the basics of his idea for setting stop levels which should work once one bar has closed so my guess is that the fibonacci levels are not correctly calculated or there is something else in the code that we can’t see. Sharing the complete code would be helpful but as we know not everyone likes sharing complete codes!
Have another coffee…03/18/2019 at 6:09 PM #93974
Sharing the complete code would be helpful but as we know not everyone likes sharing complete codes!
This may be a good one to work on collaboratively as it’s not as if Fib levels are any of our own ideas.
Also I can understands the code / strategy (surprisingly! 🙂 ) which is why I was asking as I think @Kris75 has not worked out the fib levels calcs and he is asking for help?
So which is it Kris75 …
- You have coded up the full strategy (but it’s not working)
- You need help further than the code you show above?