Help with my stratery , keeps getting stopped

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #206661 quote
    Tapper13
    Participant
    Junior

    Hello, Happy new year!

    Wondering if anyone can help me out , trying out this stratergy but it keeps getting stopped.

    Tried to alter the stoploss but it doesnt help.

    Any ideas ?

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = True // Cumulating positions activated for HFT
    
    // Initialize variables
    entryPrice = 0
    takeProfit = 0
    maxDrawdown = 0
    BBup = BollingerUp[20](close)
    BBDn = BollingerDown[20](close)
    EMA10 = ExponentialAverage[10](close)
    EMA20 = ExponentialAverage[20](close)
    EMA50 = ExponentialAverage[50](close)
    EMA200 = ExponentialAverage[200](close)
    
    // Check for trend
    trend = EMA10 - EMA50
    trend2 = EMA20 - EMA200
    // Conditions to enter long positions
    if (close > EMA20 and trend > 0 and trend2 > 0) or (close > BBup and RSI[14](close) < 60)THEN
    // Set entry price, stop loss, and take profit
    entryPrice = close
    takeProfit = entryPrice * (1 + 0.03) // 3% take profit
    BUY 0.5 CONTRACT AT MARKET
    ENDIF
    // Conditions to enter short positions
    if (close < EMA20 and trend < 0 and trend2 < 0) or (close < BBDn and RSI[14](close) > 40)THEN
    // Set entry price, stop loss, and take profit
    entryPrice = close
    takeProfit = entryPrice * (1 - 0.03) // 3% take profit
    SELLSHORT 0.5 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pTRAILING (5 + 1.2)
    SET target profit takeProfit
    #206663 quote
    GraHal
    Participant
    Master

    BUY 0.5 CONTRACT AT MARKET SELLSHORT 0.5 CONTRACT AT MARKET

    What Instrument? Is 0.5 allowed?  What error message do you see when you click on the yellow disc after System has been stopped?

    Change to 1.0 and see if makes any difference?

    #206667 quote
    GraHal
    Participant
    Master

    SET STOP pTRAILING (5 + 1.2)

    Read the Topic on the link below to see why pTailing won’t work

    S&P500 Backtest shows different numbers than the Report

    #206680 quote
    Tapper13
    Participant
    Junior

    What Instrument? Is 0.5 allowed? What error message do you see when you click on the yellow disc after System has been stopped?

     

    Change to 1.0 and see if makes any difference?

    Hi GraHal thanks for the reply.
    Its on the Dax40 and yes i can use 0.5.

    Ok will check later

    #206688 quote
    JC_Bywan
    Moderator
    Master

    Hi, topic moved from probuilder to proorder forum for housekeeping. Please use probuilder forum for custom coded indicators, and proorder forum for strategies and backtests, thanks. Best Wishes for the new year.

    Tapper13 thanked this post
    #206695 quote
    Tapper13
    Participant
    Junior

    You where right. I deleted “SET target profit takeProfit” and only use SET STOP pTRAILING (5 + 1.2)

    Seems like the Stop and Target profit was conflicting one another. At the moment it didnt not stop

     

    Thanks for your help for now

    #206715 quote
    robertogozzi
    Moderator
    Master

    The main issue is not using SET target profit or not, it’s changing the variable takeProfit almost each bar. That’s because, even if you have limited your code to ONE open trade, conditions are still evaluated and, when met, takeProfit is changed (be it the same or the opposite direction).

    Add AND Not OnMarket to your conditions in both lines 19 and 26, to prevent the execution of lines 21-22 and 28-29 when a position is open.

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

Help with my stratery , keeps getting stopped


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Tapper13 @tapper13 Participant
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by robertogozzi
3 years, 1 month ago.

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