Buy on certin dates, not on technical singal

Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • #228576 quote
    JS
    Participant
    Senior

    Hi,

    I’ve tried your code, including the timeframes, and I think it works as expected…

    (PRT+IB)

    Scherm­afbeelding-2024-02-22-om-15.14.18.png Scherm­afbeelding-2024-02-22-om-15.14.18.png
    #228601 quote
    Laliberte
    Participant
    New
    Hi PeterST, I’m struggling to get it working. Can you help me with the correct modification? This is the last test I did:
    
    // LONG open dates
    $myDateL[1]  = 20230316
    $myDateL[2]  = 20230328
    $myDateL[3]  = 20230411
    $myDateL[4]  = 20230424
    // LONG exit dates
    $myExitL[1]  = 20230321
    $myExitL[2]  = 20230403
    $myExitL[3]  = 20230417
    $myExitL[4]  = 20230428
    LastElementL = 4
    SLpercent    = 2             //2%  stop loss
    //
    IF Not OnMarket THEN
    FOR i = 1 TO (LastElementL)
    //LONG  trades
    IF i <= LastElementL THEN
    IF Date = $myDateL[i] THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP %LOSS SLpercent
    break
    ENDIF
    ENDIF
    // exit LONG  trades
    IF LongOnMarket  THEN
    FOR i = 1 TO LastElementL
    IF Date = $myExitL[i] THEN
    SELL AT MARKET
    break
    ENDIF
    NEXT
    ENDIF
    Thanks again for your input.
    #228602 quote
    Laliberte
    Participant
    New
    Thanks for testing the code. We get different results. I have PRT+IG, maybe that makes the difference.
    #228603 quote
    JS
    Participant
    Senior
    Hi, Try this one…  
    // LONG open dates
    $myDateL[1]  = 20230316
    $myDateL[2]  = 20230328
    $myDateL[3]  = 20230411
    $myDateL[4]  = 20230424
    // LONG exit dates
    $myExitL[1]  = 20230321
    $myExitL[2]  = 20230403
    $myExitL[3]  = 20230417
    $myExitL[4]  = 20230428
    LastElementL = 4
    SLpercent    = 2             //2%  stop loss
    //
    IF Not OnMarket Then
    FOR i = 1 TO (LastElementL) // Enter LONG Trades
    IF Date = $myDateL[i] THEN
    Buy 1 Contract at Market
    Set STOP %LOSS SLpercent
    Break
    EndIf
    Next
    EndIf
    
    // Exit LONG Trades
    IF LongOnMarket  THEN
    FOR i = 1 TO LastElementL
    IF Date = $myExitL[i] THEN
    SELL AT MARKET
    Break
    EndIf
    Next
    EndIf
    
    #228641 quote
    PeterSt
    Participant
    Master
    Hi PeterST, I’m struggling to get it working. Can you help me with the correct modification? This is the last test I did:
    Hello Fredrik, Can you please tell once again what exactly is not working with “the last test you did” ? Also, when you receive an error message, then it is good to know what the message is. 😉 Peter
    #228672 quote
    Laliberte
    Participant
    New
    It worked, thanks! 🙂
    #228673 quote
    Laliberte
    Participant
    New
    Hi again. it is solved. Will run one LONG test and one SHORT test separately, so the orders in the code (same day orders, different directions and close/open) does not cancel out each other. 🙂
Viewing 7 posts - 16 through 22 (of 22 total)
  • You must be logged in to reply to this topic.

Buy on certin dates, not on technical singal


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Laliberte @laliberte Participant
Summary

This topic contains 21 replies,
has 4 voices, and was last updated by Laliberte
1 year, 12 months ago.

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