How to average down ?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #204165 quote
    frdriancre
    Participant
    New

    Hey, I wanted to know how to average down the position once i entered a trade through the code. That is, when It falls 1.5% of the price (of entry) and goes into losses how to make the code buy again there.

    #204182 quote
    robertogozzi
    Moderator
    Master

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums. Thank you  🙂

    I moved the topic from the Spanish forum.

    There you go (tested on DAX, Daily TF):

    DEFPARAM CumulateOrders = True
    //
    // code to spot any new entry
    //
    NewTrade = (LOngOnMarket AND ShortOnMarket[1]) OR (LOngOnMarket[1] AND ShortOnMarket) OR (OnMarket AND Not OnMarket[1])
    //
    // check how many positions are currently open
    //
    MyPositions = abs(CountOfPosition)
    //
    // store the new trading price of any additional position
    //
    IF NewTrade OR (MyPositions > MyPositions[1]) THEN
       EntryPrice = TradePrice
    ENDIF
    //
    // clear variables when not OnMrket
    //
    IF Not OnMarket THEN
       EntryPrice = 0
    ENDIF
    //
    // average down whenever a 1.5% drop occurs
    //
    IF LongOnMarket THEN
       IF close <= EntryPrice * 0.985 THEN    //1.5% drop
          BUY 1 CONTRACT AT Market
       ENDIF
    ELSIF ShortOnMarket THEN
       IF close >= EntryPrice * 1.015 THEN    //1.5% drop
          SELLSHORT 1 CONTRACT AT Market
       ENDIF
    ENDIF
    //
    // example of a strategy (just to test the above code)
    //
    IF close crosses over average[20,0](close) and not OnMarket THEN
       buy 1 Contract at Market
    endif
    IF close crosses under average[20,0](close) and not OnMarket THEN
       sellshort 1 Contract at Market
    endif
    //
    // target profit
    //
    SET TARGET pPROFIT 100
    //
    // monitor the entry price
    //
    graphonprice EntryPrice coloured("Green")
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

How to average down ?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
frdriancre @frdriancre Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
3 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/14/2022
Status: Active
Attachments: No files
Logo Logo
Loading...