Define the current price of my open position

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #25354 quote
    barbagio
    Participant
    Average

    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:

    1. identify current price of my open position
    2. 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

    #25358 quote
    Nicolas
    Keymaster
    Master

    So you want this to be done automatically by a code in your own automatic trading strategy?

    #25373 quote
    barbagio
    Participant
    Average

    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!

    #25374 quote
    Nicolas
    Keymaster
    Master

    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.

    #25385 quote
    barbagio
    Participant
    Average

    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…

    #25398 quote
    Nicolas
    Keymaster
    Master

    Fibonacci extensions calculated from which high and low levels?

    #25403 quote
    barbagio
    Participant
    Average

    High level: open price

    Low level: the low of the previous bar

    #25438 quote
    Nicolas
    Keymaster
    Master

    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 :/

    #25671 quote
    barbagio
    Participant
    Average

    thanks Nicolas, so let’s wait for the multitimeframe.

    #93878 quote
    Meta Signals Pro
    Participant
    Veteran

    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
    
    
    #93883 quote
    Vonasi
    Moderator
    Master

    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.

    #93933 quote
    GraHal
    Participant
    Master
    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??

    #93939 quote
    Vonasi
    Moderator
    Master

    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…

    #93974 quote
    GraHal
    Participant
    Master

    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?
Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.

Define the current price of my open position


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
barbagio @barbagio Participant
Summary

This topic contains 13 replies,
has 5 voices, and was last updated by GraHal
6 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/17/2017
Status: Active
Attachments: No files
Logo Logo
Loading...