anyone want to help me try to make this better?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #230944 quote
    SweZerk
    Participant
    Junior

    this is a daily system on almost any index, i just had an idea that i wanted to test and this is the first version of it.

    DEFPARAM cumulateOrders = false
    
    // Define parameters
    Len = 7
    Filter = 0.0
    ATRMultiplier = 1.5 // Multiplier for ATR to set stop loss
    
    // Calculate MBFX Timing
    ld24 = 50.0
    if (BarIndex > Len) then
    upSum = 0
    downSum = 0
    for i = 1 to Len do
    upMove = Max(Close[i] - Close[i - 1], 0)
    downMove = Max(Close[i - 1] - Close[i], 0)
    upSum = upSum + upMove
    downSum = downSum + downMove
    next
        
    RS = upSum / downSum
    ld24 = 100 - (100 / (1 + RS))
    
    // Trading signals
    A1 = (ld24 > ld24[1] - Filter) AND (ld24[1] < ld24[2]) // Buy when MBFX Timing increases
    A2 = (ld24 < ld24[1] + Filter) AND (ld24[1] > ld24[2]) // Sell when MBFX Timing decreases
    
    // Calculate ATR for stop loss
    ATRValue = AverageTrueRange[9]
    
    // Define entry and exit conditions
    IF A1 THEN
    BUY 1 CONTRACT AT MARKET // Buy 1 contract at market
    ENDIF
    
    IF A2 THEN
    SELL 1 CONTRACT AT MARKET // Sell 1 contract at market
    ENDIF
    
    // Exit if stop loss is hit
    IF LONGONMARKET AND close < close[1] - ATRMultiplier * ATRValue THEN
    SELL AT MARKET // Sell to close position at market
    ENDIF
    
    IF SHORTONMARKET AND close > close[1] + ATRMultiplier * ATRValue THEN
    BUY AT MARKET // Buy to cover position at market
    ENDIF
    endif
    
    
    SET STOP %LOSS 5
    #231338 quote
    GraHal
    Participant
    Master

    Line 36 – enter Short needs to be SellShort.

    Line 45 – exit Short needs to be ExitShort.

    So …

    IF A2 THEN
    SELLSHORT 1 CONTRACT AT MARKET // Sell 1 contract at market
    ENDIF
    
    IF SHORTONMARKET AND close > close[1] + ATRMultiplier * ATRValue THEN
    EXITSHORT AT MARKET // Buy to cover position at market
    ENDIF
    endif
    robertogozzi thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

anyone want to help me try to make this better?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
SweZerk @swezerk Participant
Summary

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

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