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 all
So you want this to be done automatically by a code in your own automatic trading strategy?
Hi Nicolas, yes right.
It’s quite difficult to me to find a way to move the exit order during the candle development, that is what the trailing stop does.
Any suggestion?
thank you!
Ok, so the TRAILING STOP instruction should be exactly what you need, since once the trailing is set @ IG, their servers will do the rest.
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…
Fibonacci extensions calculated from which high and low levels?
High level: open price
Low level: the low of the previous bar
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 :/
thanks Nicolas, so let’s wait for the multitimeframe.
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…
Hi @barbagio,
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?
@nicolas
Hi Nicolas,
do you have a hint for this ?
Cheers
if not ONMARKET then
Buy positionSize CONTRACTS AT Market
TrailStop = fibo0 - div
endif
if LONGONMARKET then
if close > fibo236 then
TrailStop = fibo0
endif
if close > fibo236 and close < fibo382 then
TrailStop = fibo236
endif
if close > fibo382 and close < fibo500 then
TrailStop = fibo382
endif
if close > fibo500 and close < fibo618 then
TrailStop = fibo500
endif
if close > fibo618 and close < fibo764 then
TrailStop = fibo618
endif
if close > fibo764 and close < fibo100 then
TrailStop = fibo618
endif
if close > fibo100 then
SELL AT MARKET
endif
SELL at TrailStop stop
endif
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.
if not ONMARKET then
Buy positionSize CONTRACTS AT Market
TrailStop = fibo0 - div
endif
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??
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…
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)
- OR
- You need help further than the code you show above?