1 Min Trading Strategy

Viewing 15 posts - 121 through 135 (of 220 total)
  • Author
    Posts
  • #47378 quote
    raphaelopilski
    Participant
    Senior

    WORKS!!! PERFECT!!! Thank you!!

    I will give you guys Information after runnig it a while.

    #47380 quote
    mamio
    Participant
    Veteran

    @raphaelopilski Please sumbmit the complete code. I can’t get it to run.

    #47381 quote
    raphaelopilski
    Participant
    Senior

    //————————————————————————-
    // Hauptcode : LongONLY
    //————————————————————————-
    //————————————————————————-
    // Hauptcode : Long ONLY
    //————————————————————————-
    //Stategy: Scalping Candles
    //Market: DAX
    //Timeframe: 1min
    //Spread: 1
    //Author: Juan Jacobs (Jd3gjacobs@gmail.com)

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False
    DEFPARAM FLATBEFORE = 090000
    DEFPARAM FLATAFTER = 220000
    noEntryBeforeTime = 090000
    timeEnterBefore = time >= noEntryBeforeTime
    noEntryAfterTime = 173000
    timeEnterAfter = time < noEntryAfterTime
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0

    SL = 50 // 50
    TP = 55 // 55
    TS = 10 // 10

    If longonmarket and close < positionprice and (barindex-tradeindex) > 650 Then
    Sell at market
    ElsIf shortonmarket and close > positionprice and (barindex-tradeindex) > 60 then
    Exitshort at market
    EndIf

    body=close-open
    abody=abs(body)
    if (range+0.0000001)>0 then
    ratio=abody/(range+0.0000001)
    else
    ratio=0
    endif

    middle=(open+close)/2
    bodytop=max(open, close)
    bodybottom=min(open, close)
    shadowtop=high-bodytop
    shadowbottom=bodybottom-low
    longcandle= (ratio>0.6)

    Bull = 0

    //Bullish Signals

    MorningStar=(body[2]<0 and body>0 and longcandle[2] and open[1]<close[2] and open>close[1] and ratio[1]<0.3 and abody[1]<abody[2] and abody[1]<abody and low[1]<low and low[1]<low[2] and high[1]<open[2] and high[1]<close)
    if MorningStar then
    Bull = 1 //Positive

    endif

    PiercingLine=(body[1]<0 and body>0 and longcandle[1] and longcandle and open<low[1] and close>middle[1] and close<open[1])
    if PiercingLine then
    Bull = 1 //None
    endif

    AbandonedBabyBottom=(body[2]<0 and body>0 and longcandle[2] and ratio[1]<0.3 and high[1]<low[2] and high[1]<low)
    if AbandonedBabyBottom then
    Bull = 1 //None
    endif

    ThreeInsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishHarami[1] and close>close[1])
    if ThreeInsideUp then
    Bull = 1 //Positive
    endif

    ThreeOutsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishEngulfing[1] and close>close[1])
    if ThreeOutsideUp then
    Bull = 1 //Positive
    endif

    ThreeWhiteSoldiers=(body[2]>0 and body[1]>0 and body>0 and high[1]>high[2] and high>high[1] and close[1]>close[2] and close>close[1] and open[1]>open[2] and open[1]<close[2] and open>open[1] and open<close[1])
    if ThreeWhiteSoldiers then
    //Bull = 1 //Increase Drawdown
    endif

    ConcealingBabySwallow=(body[3]<0 and body[2]<0 and body[1]<0 and body<0 and ratio[3]>0.8 and ratio[2]>0.8 and ratio>0.8 and open[1]<close[2] and high[1]>close[2] and shadowtop[1]>0.6*(abody[1]+shadowbottom[1]) and bodybottom<bodybottom[1] and bodytop>high[1])
    if ConcealingBabySwallow then
    Bull = 1 //None
    endif

    BullishHarami=(body[1]<0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])
    if BullishHarami then
    //Bull = 1 //Negative Impact
    endif

    HomingPigeon=(body[1]<0 and body<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])
    if HomingPigeon then
    Bull = 1 //None
    endif

    BullishEngulfing=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)
    if BullishEngulfing then
    Bull = 1 //Positive
    endif

    LastEngulfingBottom=(body[1]>0 and body<0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)
    if LastEngulfingBottom then
    Bull = 1 //None
    endif

    DragonflyDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>3*abody and shadowtop<shadowbottom/3)
    if DragonflyDojiBottom then
    Bull = 1 //None
    endif

    GravestoneDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>3*abody and shadowbottom<shadowtop/3)
    if GravestoneDojiBottom then
    Bull = 1 //None
    endif

    DojiStarBottom=(body[1]<0 AND longcandle[1] AND low<low[1] AND open<close[1] AND ratio<0.3 AND range<0.3*range[1])
    if DojiStarBottom then
    Bull = 1 //None
    endif

    BullishHaramiCross=(body[1]<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1] and ratio<0.3 and range<0.3*range[1])
    if BullishHaramiCross then
    Bull = 1 //None
    endif

    ThreeStarsInTheSouth=(body[2]<0 and body[1]<0 and body<0 and shadowtop[2]<range[2]/4 and shadowbottom[2]>abody[2]/2 and low[1]>low[2] and high[1]<high[2] and abody[1]<abody[2] and shadowtop[1]<range[1]/4 and shadowbottom[1]>abody[1]/2 and low>low[1] and high<high[1] and abody<abody[1] and shadowtop<range/4 and shadowbottom<range/4)
    if ThreeStarsInTheSouth then
    Bull = 1 //None
    endif

    BullishBreakaway=(body[4]<0 and body[3]<0 and body>0 and open[3]<close[4] and close[2]<close[3] and close[1]<close[2] and longcandle and close<close[4] and close>open[3])
    if BullishBreakaway then
    Bull = 1 //None
    endif

    Hammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>2*abody and shadowtop<0.3*abody)
    if Hammer then
    Bull = 1 //None
    endif

    InvertedHammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>2*abody and shadowbottom<0.3*abody)
    if InvertedHammer then
    Bull = 1 //None
    endif

    RisingThreeMethods=(body[4]>0 and body[3]<0 and body[1]<0 and body>0 and longcandle[4] and longcandle and close[2]<close[3] and close[1]<close[2] and high[2]<high[3] and high[1]<high[2] and low[1]>low[4] and open>close[1] and close>high[4] and close>high[3] and close>high[2] and close>high[1])
    if RisingThreeMethods then
    Bull = 1 //None
    endif

    BullishThreeLineStrike=(body[3]>0 and body[2]>0 and body[1]>0 and body<0 and longcandle[3] and longcandle[2] and longcandle[1] and close[2]>close[3] and close[1]>close[2] and open>close[1] and close<open[3])
    if BullishThreeLineStrike then
    Bull = 1 //None
    endif

    BullishMatHold=(body[4]>0 and body[3]<0 and body[1]<0 and body>0 and longcandle[4] and close[3]>close[4] and close[2]<close[3] and close[1]<close[2] and high[2]<high[3] and high[1]<high[2] and low[1]>low[4] and open>close[1] and close>high[4] and close>high[3] and close>high[2] and close>high[1])
    if BullishMatHold then
    Bull = 1 //None
    endif

    BullSash=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>close[1] AND open<open[1] AND close>open[1] AND shadowtop<0.1*abody)
    if BullSash then
    Bull = 1 //Positive
    endif

    BullSeparatingLine=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop<0.1*abody)
    if BullSeparatingLine then
    Bull = 1 //None
    endif

    BullishCounterAttack=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND close<=close[1])
    if BullishCounterAttack then
    Bull = 1 //None
    endif

    BullishKicking=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop=0 AND shadowbottom=0)
    if BullishKicking then
    Bull = 1 //None
    endif

     

    If hour = 1 Then

    Trade = 0 //resets the variable every morning

    EndIf

    If Trade = 0 Then

    positionsize = 1 //the day will always start allowing the first trade

    ElsIf Trade >= 2 and positionperf(1) > 0 and positionperf(2) > 0 Then

    positionsize = 0

    EndIf

     

     

     

    //Entry/Exit Criteria
    NearMA = Average[7,2](close)
    If countofposition = 0 and Bull = 1 and NearMA[1] > NearMA[3] and RSI[2](close) > 60 and NearMA > Average[150,2](close) and timeEnterBefore and timeEnterAfter and not daysForbiddenEntry Then
    //If shortonmarket Then
    //Exitshort at market
    //EndIf
    Buy positionsize contract at market
    Trade=Trade+1
    EndIf

    If countofposition = 0 and NearMA[1] < NearMA[3] and RSI[2](close) < 25 and NearMA < Average[150,2](close)and timeEnterBefore and timeEnterAfter and not daysForbiddenEntry Then
    //If longonmarket Then
    //Sell at market
    //EndIf
    //Sellshort positionsize contract at market
    EndIf

    //trailing stop
    trailingstop = TS
    if not onmarket then
    MAXPRICE = 0
    priceexit = 0
    endif

    //LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
    endif
    endif

    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif

    Set Target pProfit TP
    Set Stop pLoss SL

    mamio thanked this post
    #47386 quote
    Despair
    Blocked
    Master

    @Juanj: I see there in your code commands like:

    x=average[7,2](close)

    I’m not familiar with this notation. What does the second parameter in the first bracket stand for. 7 is the period of the MA but what is this ,2 after the 7?

    #47391 quote
    juanj
    Participant
    Master

    It’s the Moving Average Type

    0 = Simple
    1 = Exponential
    2 = Weighted
    3 = Wilder’s Smoothed
    4 = Triangular
    5 = End Point
    6 =Time Series.

    Despair thanked this post
    #47417 quote
    Despair
    Blocked
    Master

    Results improve significantly if you omit trades on both mondays and thursdays. This is for the dax.

    #47418 quote
    juanj
    Participant
    Master

    Interesting. Wonder why that would be.

    I use to optimize all my strategies to only run on certain days (based on backtesting) but it always seemed to only work for a little while as the market ‘no-no’ days seem to change over time.

    But suppose if you use WF and only a fraction of your data to confirm the bias it might be more relevant going forward.

    #47420 quote
    Despair
    Blocked
    Master

    I ran several OOS-tests with it and the bias was confirmed. Of course our history for 1min is so little that the bias can vanish whenever. At least it persisted to all history we have.

    A german analyst I once had a chat with had the option that the Dax is always searching for its direction on mondays and usually tests on mondays both highs and lows. This would make the market prone to intraday reversals on mondays which than would cause losing trades.

    This would be an attempt to explain why mondays are bad days but when I tested thursday were the worse (even worse than mondays) and actually the only weekday that lost money on average, mondays had a tiny plus (0.06%). For thursdays I have no explanation. But well, we don’t have to understand it to be able to trade it. 😛

    #47426 quote
    reb
    Participant
    Master

    @raphaelopilski

    Hallo

    When I try to test the version you posted #47381 for DAX,  strategy doesn’t take any position.

    Do you know where the issue could be ?

    Danke im Voraus

    Reb

    #47432 quote
    Despair
    Blocked
    Master

    Has anybody made the short side work for this?

    #47440 quote
    Huw
    Participant
    Average

    Hi everyone. Has anyone tried using a moving average of daily highs and lows as entry criteria for long or short trades? Example take the highest daily high of a long number of periods (roughly 10000) then take a moving average of this. If the price is above this then we know on a higher time frame the trend should be upwards.

    #47478 quote
    Despair
    Blocked
    Master

    Open a new thread and give it a try.

    #47497 quote
    Inertia
    Participant
    Master

    Short version doesn’t work…

    I tried several things but nothing appeared to be good enough… (EMA filter, differents TF, filtered by days etc…)

    #47498 quote
    juanj
    Participant
    Master

    I think if you are really determined to get the short side working, start by disabling all the bearish candle setups (//Bear = 1) and then enable them one by one, keeping only those that improve performance above the long-only version. Not all candlestick patterns are created equally. Maybe you stumble upon 2 or 3 that actually give good high-quality triggers.

    Andre Vorster thanked this post
    #47499 quote
    Inertia
    Participant
    Master

    Ok Boss…Let’s see…I will post the best result I’ll manage to get. Thx

    Andre Vorster thanked this post
Viewing 15 posts - 121 through 135 (of 220 total)
  • You must be logged in to reply to this topic.

1 Min Trading Strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
juanj @juanj Participant
Summary

This topic contains 219 replies,
has 29 voices, and was last updated by Leo
8 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/13/2017
Status: Active
Attachments: 65 files
Logo Logo
Loading...