Help with Psosition perf( money mangement)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #40291 quote
    Kenneth Kvistad
    Participant
    Senior

    Hi..

     

    Can someone help me with the code I paste to make it by 3 contracts every time after a win and make it buy 1 contract after every loss.

    Lets say I loose 1 time I whant so short down to 1 contract until it wins the first time , then I whant it to by 3 contracts everytime as long as it wins until it looses again.

    After every loss=1 contract until first win

    After every win=3 contracts until first loss

    defparam cumulateorders = false
    
    av1 = average[3](close)
    av2 = average[20](close)
    av3 = average[50](close)
    x = 0.5
    bull = close> av1 and close >av2 and close > av3
    bear = close <av1 and close <av2 and close <av3
    //n= 1
    
    hammerup = min(open[1],close[1])>high[1]-(high[1]-low[1])/3 //and timeok
    hammerupnegated= max(open,close)<min(open[1],close[1]) and abs(open-close)/(high-low)>x
    cs = hammerup and hammerupnegated and bear
    hammerdown = max(open[1],close[1])<low[1]+(high[1]-low[1])/3 //and timeok
    hammerdownnegated = min(open,close)>max(open[1],close[1]) and abs(open-close)/(high-low)>x
    cl = hammerdown and hammerdownnegated and bull
    
    if cs then
    sellshort 2 contract at market
    endif
    
    if cl then
    buy 2 contract at market
    endif
    
    
    
    //TRAILING STOP
    TGL =30//32
    TGS= 20//32
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    PREZZOUSCITA = 0
    ENDIF
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close)
    if MAXPRICE-tradeprice(1)>=TGL*pointsize then
    PREZZOUSCITA = MAXPRICE-TGL*pointsize
    ENDIF
    ENDIF
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    if tradeprice(1)-MINPRICE>=TGS*pointsize then
    PREZZOUSCITA = MINPRICE+TGS*pointsize
    ENDIF
    ENDIF
    if onmarket and PREZZOUSCITA>0 then
    EXITSHORT AT PREZZOUSCITA STOP
    SELL AT PREZZOUSCITA STOP
    ENDIF
    
    
    
    SET STOP ploss 110////120//120
    SET TARGET pPROFIT 52//50
    #40314 quote
    Nicolas
    Keymaster
    Master

    Sorry, I will not answer your question today. PLEASE POST YOUR MESSAGE IN THE RIGHT FORUM AND USE THAT DAMN ‘INSERT PRT CODE’, FOR HOW LONG HAVE YOU BEEN ON THE WEBSITE? FOR 1 YEAR?? YOU MUST BE KIDDING ME! 👿 👿 👿

    #40318 quote
    Kenneth Kvistad
    Participant
    Senior

    Sorry Nicolas.

    I will remember this.

    What is the right forum?

     

    1. Should I post it under Fransisco78’s tradingstrategy post?
    #40321 quote
    tob107
    Participant
    Average

    I guess something like this should do it:

    NbrContracts = 2 //need a value for the first trade
    IF PositionPerf(1) < 0 THEN
    NbrContracts = 1
    ENDIF
    IF PositionPerf(1) > 0 THEN
    NbrContracts = 3
    ENDIF
    
    if cs then
    sellshort NbrContracts contract at market
    endif
     
    if cl then
    buy NbrContracts contract at market
    endif
    #40325 quote
    Kenneth Kvistad
    Participant
    Senior

    Thanx tob107

    I will try this later today.

    Tried something simular yesterday but used ordersize insted of nbrcontracts:-)

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

Help with Psosition perf( money mangement)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Kenneth Kvistad
8 years, 8 months ago.

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