Cross over but no trigger

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #191203 quote
    Carter
    Participant
    Junior

    Hi Everyone,

    I need a little help understanding whats happening with a simple cross over using the smooth stochastic.

    I trade the us500 on 10min and dont seem to be always getting a buy single on the cross over of 28. Please refer code.

    While a lot of the triggers seem correct some I believe are missed.

    Any ideas would be appreciated.

    Regards

    Carter

    US500-No-Stop-SS-Cross.itf
    #191223 quote
    robertogozzi
    Moderator
    Master

    Do not embed files in your post. Use the SELECT FILE button only for attachments.

    Thank you 🙂

    It works like a charm, it skips crossovers when there are 2 positions open, as C5 (line 17) makes sure there are less than 2 positions to add another one.

    #191291 quote
    Carter
    Participant
    Junior

    Hi Robert.

    Thank you for your reply.

    I have checked what you have mentioned but I dont believe this is the issue. I have picked a couple of recent dates where a trigger is expected and there are no open positions. 4/4/22 and 17/1/22.

    Thanks

    Carter

    //-------------------------------------------------------------------------
    // Main code : US500 Multiple entry multiple exit
    //-------------------------------------------------------------------------
    
    DEFPARAM CumulateOrders = true // Cumulating positions activated
    defparam preloadbars = 5000
    
    // Conditions to enter long positions
    i1 = SmoothedStochastic[509,80](close)//505,80
    
    c1 = i1 crosses over 28//37
    c5 = countoflongshares < 2
    c6 = longonmarket = 0
    
    IF c1 and c5 and c6 then
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    c7 = (positionprice - close) > 1
    
    if c1 and c5 and c7 then
    buy 1 contract at market
    endif
    
    
    //Trailing Stop
    if barindex > 30 then
    i10 = close - positionprice
    if i10 > 68 then
    llowest = 228//228
    else
    llowest = 352
    endif
    i11 =  (llowest - (i10 * 3))//409,3 - 4700,30
    i12 = round(i11)
    
    
    i16 = max(1,i12)
    i17 = lowest[1](i16)//6
    i18 = lowest[i17](low)
    
    C19 = i10 > 17//20
    c18 = close crosses under i18[2]//10
    IF c18 and c19 THEN
    SELL AT MARKET
    endif
    endif
    
    //tp = a * AverageTrueRange[b](close)
    set target pprofit 93
    #191304 quote
    robertogozzi
    Moderator
    Master

    Replace line 27 with this one:

    if barindex > 30 and OnMarket then

    because if you don’t check if you are already on market, it will execute BUY, then SELL, thus invalidating the trade.

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

Cross over but no trigger


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Carter @carmac Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/05/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...