Initial balance condition

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #177547 quote
    egyptiantrader
    Participant
    Junior

    Hi. I’ve edited some code I found on here to create a simple initial balance indicator “Balance 15m NASDAQ”. See below.

    //15 min Time frame
    //Initial Ballance calculation
    //First Hour in the morning form 8:00-9:00 GMT+1 on DAX

    starttime = 143000
    endtime = 153000

    If Time = endtime then
    upper=highest[4](high)
    lower=lowest[4](low)
    dif=round(abs(lower-upper))

    endif

    RETURN dif

     

    I want to use the following code as another condition before entering a trade

    //Initial balance
    myBalance15mNASDAQ = CALL “Balance 15m NASDAQ”
    c9 = (myBalance15mNASDAQ <50)

    But when I back test the results are unaffected? Even when I change to <5 for example?

    What am I doing wrong please?

     

    Tried it like this too, same result?

    //Initial balance
    myBalance15mNASDAQ = CALL “Balance 15m NASDAQ”

    //Conditions to enter long positions
    indicator1 = ExponentialAverage[7.8](close)
    indicator2 = ExponentialAverage[12.6](close)
    c1 = (indicator1 CROSSES OVER indicator2)

    IF c1 AND myBalance15mNASDAQ <50 AND not daysForbiddenEntry THEN
    BUY 0.5 CONTRACT AT MARKET
    ENDIF

    #177561 quote
    robertogozzi
    Moderator
    Master

    My code works fine.

    Indicator:

    //     MyInd indicator
    //15 min Time frame
    //Initial Ballance calculation
    //First Hour in the morning form 8:00-9:00 GMT+1 on DAX
    starttime = 143000
    endtime   = 153000
    If Time = endtime then
       upper=highest[4](high)
       lower=lowest[4](low)
       dif=round(abs(lower-upper))
    endif
    RETURN dif

    Strategy:

    //Initial balance
    myBalance15mNASDAQ = CALL "MyInd"
    
    //Conditions to enter long positions
    indicator1 = ExponentialAverage[7.8](close)
    indicator2 = ExponentialAverage[12.6](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    
    IF c1 AND myBalance15mNASDAQ <50 AND not OnMarket THEN
       BUY 0.5 CONTRACT AT MARKET
    ENDIF
    set target pProfit 100
    set stop ploss 100
    graph myBalance15mNASDAQ

    I think your code actually opened a trade, but it was left open as no SL or TP were planned (test it again and check among opened orders).
    Adding SL and TP should work it out.

    egyptiantrader thanked this post
    #177580 quote
    egyptiantrader
    Participant
    Junior

    Thank you.

    Did you have to change anything? I’ll have a go at inserting your code tomorrow. This is only a section of the code, I have a SL set and exit parameters too further down.

     

    Thanks again I really appreciate this, I’m very new to this with lots to learn .

    #177586 quote
    egyptiantrader
    Participant
    Junior

    I’ve got it working as part of my algo now. I’m not sure why it wasn’t working originally? Must have been syntax?

    Thanks again.

    #179852 quote
    juju333
    Participant
    Average

    Hi there,

    I’ve tried a very close piece of code, but can’t manage to open a position. It might be easy however. Any adea ? thanks for your help.

    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    
       
    //Settings
    once IBup=0
    once IBdown=0
    starttime = 080500
    endtime = 090000
     
    If Time = endtime then
    IBup = highest[12](high)
    IBdown = lowest[12](low)
    IBdif = IBup - IBdown
    IBp100 = IBup + IBdif
    IBp200 = IBup + IBdif + IBdif
    IBm100 = IBdown - IBdif
    IBm200 = IBdown - IBdif - IBdif
    Endif
    
    If not onmarket and time >=090500 and Time <=153000 and close CROSSES OVER IBup then
    BUY 1 CONTRACT AT MARKET
    SET STOP LOSS IBdif
    SET TARGET PROFIT IBdif
    ENDIF
    
    #179858 quote
    egyptiantrader
    Participant
    Junior

    Everything looks ok to me. Maybe try removing the “>=090500 and Time <=153000″ and maybe use “close > IBup” instead of “close CROSSES OVER IBup”

    I’m very new to this, so this is my best guess.

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

Initial balance condition


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by egyptiantrader
4 years, 4 months ago.

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