Resting Limit Orders: sell/buy at touch of MA

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

    Hi Guys,

    Looking for some coding help…. I’m interested in developing a code which:

    • Can be switched on / off for a chosen market
    • Once on, creates a limit order fixed to a moving average, limit to sell/buy at touch of MA +/- 1 tick/point.
    • Limit order to auto calculate trade size based on following factors: Account balance, risk %, 1 ATR ie:
      • Account balance eg 10,000
      • Risk 1% account balance ie 100
      • 1 ATR of market eg 580 points
      • Trade size = $10,000 * 1% = $100 / 580 points = 0.17 lots
    • Limit order will run until switched off, ie each day will recalculate the resting limit order based on today’s account balance, MA value and ATR value

    Is this possible in the ProRealtime autotrade environment?

    M

    #145259 quote
    robertogozzi
    Moderator
    Master

    There you go (for the Daily TF):

    DEFPARAM CumulateOrders = false
    TradeON = 1                           //1=on,  0=off
    MinLotti= 0.5                         //0.5 Minimun lot size
    Capital = 10000
    Balance = Capital + StrategyProfit
    Risk    = 1                           //1%  risk
    Offset  = 1 * pipsize
    Entry   = average[30,0](close)
    EntryL  = Entry + Offset
    EntryS  = Entry - Offset
    MyATR   = AverageTrueRange[14](close)
    LotSize = max(MinLotti,(Balance * Risk / 100) / MyATR)
    IF OnMarket THEN
       Entry  = 0
       EntryL = 0
       EntryS = 0
    ENDIF
    IF Not OnMarket AND TradeON THEN
       IF close > EntryL THEN
          BUY       LotSize CONTRACTS AT EntryL LIMIT
       ELSE
          BUY       LotSize CONTRACTS AT EntryL STOP
       ENDIF
       IF close > EntryS THEN
          SELLSHORT LotSize CONTRACTS AT EntryS STOP
       ELSE
          SELLSHORT LotSize CONTRACTS AT EntryS LIMIT
       ENDIF
    ENDIF
    SET TARGET pPROFIT 300
    SET STOP   pLOSS   100
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Resting Limit Orders: sell/buy at touch of MA


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/29/2020
Status: Active
Attachments: No files
Logo Logo
Loading...