help coding a Break Out strategy on Gbp/Usd

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #156206 quote
    ullle73
    Participant
    Senior

    Hi, is this possible to code for a strategy? If so, would anyone be so kind and help out coding it ? 🙂

     

    1) At exactly 8am UK Time take the price of GBP USD
    2) Place a Buy stop at price +40 pips, stop loss 80 pips, take profit 240 pips, trailing stop 60
    pips
    3) Place a sell stop at price -40 pips, stop loss 80 pips, take profit 240 pips, trailing stop 60
    pips
    4) If trade entry level is hit, delete second trade order
    5) Close all trades at 6pm UK time

    #156216 quote
    robertogozzi
    Moderator
    Master

    Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’. Thank you 🙂

    I changed it.

    There you go:

    DEFPARAM CumulateOrders = FALSE
    ONCE EntryShort = 0
    ONCE EntryLong  = 0
    IF Time = 090000 THEN                 //currently LONDON is 1 hour behind CET
    EntryLong  = close + 40 * pipsize
    EntryShort = close - 40 * pipsize
    ENDIF
    IF OnMarket OR (StrategyProfit <> StrategyProfit[1]) THEN
    EntryLong  = 0
    EntryShort = 0
    ENDIF
    IF OnMarket AND Time = 190000 THEN    //currently LONDON is 1 hour behind CET
    SELL      AT Market
    EXITSHORT AT Market
    ENDIF
    IF EntryLong  THEN
    BUY 1 Contract AT EntryLong STOP
    SET STOP   pLOSS   80
    SET TARGET pPROFIT 240
    ENDIF
    IF EntryShort THEN
    SELLSHORT 1 Contract AT EntryShort STOP
    SET STOP   pLOSS   80
    SET TARGET pPROFIT 240
    ENDIF
    //************************************************************************
    //trailing stop function
    //
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    //
    trailingstart = 60   //trailing will start @trailinstart points profit
    trailingstep  = 60   //trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

help coding a Break Out strategy on Gbp/Usd


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ullle73 @jonas_rydqvist Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/04/2021
Status: Active
Attachments: No files
Logo Logo
Loading...