How to exit from position

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #39306 quote
    enzo_52enzo_52
    Participant
    Senior
    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
    
    ID = high<high[1] and low>low[1]
    
    if ID then
    test = 1
    hh = highest[2](high)
    ll = lowest[2](low)
    
    endif
    
    if test = 1 then
    if time>=110000 and time <=120000 then
    BUY 1 SHARE AT hh STOP
    endif
    endif
    
    if test=1 then
    if time>=020000 and time <=050000 then
    sellshort 1 SHARE AT ll STOP
    endif
    endif
    
    if longonmarket and time >= 020000 and time<=050000then
    SELL AT ll STOP
    
    test = 0
    endif
    
    if shortonmarket and time>=110000 and time<=120000 then
    EXITSHORT AT hh STOP
    
    test = 0
    endif
    
    
    #39307 quote
    enzo_52enzo_52
    Participant
    Senior

    hi guys, i need help for to exit from long position or short position olso when the condition hh or ll do is not verified, i want exit ,if long at 050000,  if short at 120000

    thanks

    #39315 quote
    NicolasNicolas
    Keymaster
    Legend

    Wrong section of forum once again Enzo, please try to post to the correct section next time (ProOrder for automated strategy). Thank you. 👿

    Basically, you want your stoploss to be the size of the hh-ll range?

    #39424 quote
    enzo_52enzo_52
    Participant
    Senior

    Apologyse Nicolas, You are righe… Forgive me

    #39426 quote
    NicolasNicolas
    Keymaster
    Legend

    So if the answer to my question is “yes”, just use the SET STOP LOSS function with the hh-ll range, like this:

    SET STOP LOSS (hh-ll)
    #39481 quote
    enzo_52enzo_52
    Participant
    Senior

    Hi Nicolas,  no , the sell and exitshort signals are with 1 condiction: SELL AT ll  STOP  ,  EXITSHORT AT hh STOP, i want  that  if the price do not touch LL or HH level the trade long or short .stops.

    if  i am long close at 05 o clock ,    if i am short close  at  12 o clock

    i hope i was clear ..

     

    thanks

    #39513 quote
    NicolasNicolas
    Keymaster
    Legend

    Hmmm… I think we are lost in translation here 🙂

    Ok, so now if you want to exit your long position at 5 o’clock, let’s code it like this:

    if time=050000 and longonmarket then 
     sell at market 
    endif

    and do the opposite for your short orders.

    #39521 quote
    enzo_52enzo_52
    Participant
    Senior

    sorry for my english..be patient Nicolas :-),

    i want that my long position will be close if  in 02  to  05 o clock or at condition “LL” or if this condition is not  verified i want close my long position at 05 o clock.

    the same thing for short position

    thanks so much Nicolas

    #39563 quote
    enzo_52enzo_52
    Participant
    Senior
    hh = highest[4](high)
    if time>=020000 and time<=050000 and shortonmarket then
    
    EXITSHORT 1 share  AT hh  stop
    elsif  time=050000 then
    exitshort 1 share at market
    
    endif
    

    it do is not work…. Why?

    thanks

    #39645 quote
    NicolasNicolas
    Keymaster
    Legend

    Are you sure your “hh” level is below the current Close? I don’t think that possible. You should look 1 period ago instead, like this:

    hh = highest[4](high)
    
    if time>=020000 and time<050000 and shortonmarket then
     EXITSHORT 1 share  AT hh[1]  stop
    endif
    
    if shortonmarket and time=050000 then 
     exitshort at market
    endif
    #39670 quote
    enzo_52enzo_52
    Participant
    Senior

    hh  is a condition, if the price do is not go upper the “hh”  the trade continue to be short , but anyway at 050000 must be closed.

    if the price go is upper the hh between 020000 – 050000 then i want that trade must be closed

     

    i hope to be clear

    sorry for my english 🙂

    #39686 quote
    NicolasNicolas
    Keymaster
    Legend

    ok it’s clear, so the code posted in my previous message should work as intended.

    #39707 quote
    enzo_52enzo_52
    Participant
    Senior
    ID = high<high[1] and low>low[1]
    rang = range
    NR4 = rang<range[1] and rang<range[2] and rang<range[3]
     
    if ID and NR4 then
    test = 1
    hh = highest[4](high)
    ll = lowest[4](low)
    endif
    
    ID = high<high[1] and low>low[1]
    rang = range
    NR4 = rang<range[1] and rang<range[2] and rang<range[3]
     
    fi= ID and NR4
    
    hh = highest[4](high)
    ll = lowest[4](low)
    

    what do is it mean 1st code…and what is the difference ?

    #39708 quote
    enzo_52enzo_52
    Participant
    Senior

    no, Niclosa  it do is not work

     

    help me. please

    #39860 quote
    enzo_52enzo_52
    Participant
    Senior

    Hello  Nicolas ,

     

    when you have time , please try to answer me

     

    Thanks a lot

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

How to exit from position


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
enzo_52 @enzo_52 Participant
Summary

This topic contains 14 replies,
has 2 voices, and was last updated by enzo_52enzo_52
9 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/28/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...