prohibit trades when > supertrend

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #152698 quote
    UkDownUnder
    Participant
    Average
     supertrend" >DEFPARAM CUMULATEORDERS = false
    DEFPARAM PRELOADBARS = 200
    
    //bear
    bear = supertrend < close [12.28]
    bear2 = supertrend < close [3.10]
    //////////////////////////////////
    //bull
    bull = supertrend < close [30.210]
    
    
    a = High[0] - Low[0]
    b = Min(Open[0], Close[0]) - Low[0]
    c = b/a
    d = c*2
    
    //abcd = condition 
    
    // Conditions to enter long positions
    //IF NOT LongOnMarket AND a and b and c and d THEN
    //BUY 1 CONTRACTS AT MARKET
    //ENDIF
    
    // Conditions to exit long positions
    //If LongOnMarket AND YourConditions THEN
    //SELL AT MARKET
    //ENDIF
    
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND bear and bear2 and d THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    IF ShortOnMarket AND bull THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops and targets : Enter your protection stops and profit targets here
    SET STOP PTRAILING 82
    SET TARGET PROFIT 182
    Screenshot-5.png Screenshot-5.png
    #152707 quote
    Vonasi
    Moderator
    Master

    Is there a question?

    My first question would be why are you using decimal places in the CLOSE[x] in your code. You can’t get the info from a decimal part of a bar. ProRealCode will just round it.

    #152710 quote
    Vonasi
    Moderator
    Master

    Second question: ‘d’ will always be a positive value and so will always be true and so is not doing anything in your code.

    #152714 quote
    robertogozzi
    Moderator
    Master

    I think those brackets are intended for  SUPERTREND, but:

    • they must be put next to ST
    • a comma must be used to separate the two numbers, instead of a period.

    Line 1 is a bit messy.

    Have you had any chance to read documentation about SuperTrend?

    UkDownUnder thanked this post
    #152720 quote
    UkDownUnder
    Participant
    Average

    Sorry about line 1, please disregard that mistake, first time uplaoding to the Forum

    was also trying to streamline the supertrend as apposed to being

    indicator1 = SuperTrend[3,10]
    c1 = (close > indicator1)

    maybe that’s why the system is not acknowledging it

    #152724 quote
    UkDownUnder
    Participant
    Average
    DEFPARAM CUMULATEORDERS = false
    DEFPARAM PRELOADBARS = 200
    
    //bear
    bear = supertrend[12,28]
    c1 = (close < bear)
    
    bear2 = supertrend[3,10]
    c2 = (close < bear2)
    //////////////////////////////////
    //bull
    //bull = supertrend[30,210]
    //c3 = (close < bull)
    
    a = High[0] - Low[0]
    b = Min(Open[0], Close[0]) - Low[0]
    c = b/a
    d = c*2
    
    //abcd = condition
    
    // Conditions to enter long positions
    //IF NOT LongOnMarket AND a and b and c and d THEN
    //BUY 1 CONTRACTS AT MARKET
    //ENDIF
    
    // Conditions to exit long positions
    //If LongOnMarket AND YourConditions THEN
    //SELL AT MARKET
    //ENDIF
    
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND c1 and c2 and d THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    //IF ShortOnMarket AND c3 THEN
    //EXITSHORT AT MARKET
    //ENDIF
    
    // Stops and targets : Enter your protection stops and profit targets here
    SET STOP PTRAILING 82
    SET TARGET PROFIT 182
    #152725 quote
    UkDownUnder
    Participant
    Average

    Hi,

    Tided up some lo0se ends on that with advice taken onboard, thanks.

    Also added another condition

    bear3 = supertrend[36,211]
    c3 = (close < bear3)

    seems much better,

    Still would like to learn how to streamline the supertrend read code as an indicator/ condition, i will check the PRT manual,

    Regards and Thanks

    #152728 quote
    Vonasi
    Moderator
    Master

    ‘d’ is still doing absolutely nothing!

    a = High[0] - Low[0]
    b = Min(Open[0], Close[0]) - Low[0]
    c = b/a
    d = c*2
     
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND c1 and c2 and d THEN

    ‘d’ is just going to return (the lower shadow as a percentage of the range) x 2. It will always be a positive value so ‘and d’ will always be true.

    #152729 quote
    UkDownUnder
    Participant
    Average

     

    yes, just an inert example i throw in,

    that i’d seen somewhere in the past,

    maybe someone can put life into it,

    #152730 quote
    Vonasi
    Moderator
    Master

    Try something like:

    a = High[0] - Low[0]
    b = Min(Open[0], Close[0]) - Low[0]
    c = b/a
    d = c*100
     
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND c1 and c2 and d <= 25 THEN

    This sets a condition where the lower shadow must be less than or equal to 25% of the total range.

    UkDownUnder thanked this post
    #152736 quote
    UkDownUnder
    Participant
    Average

     

    Thanks,

    you nailed it, d was that originally.

    i should have never altered it!

    Its it possible to explain the function of <= 25

    does it relate to less that 25 bars?

    #152738 quote
    Vonasi
    Moderator
    Master

    No! 25 is the percentage. So the candles lower shadow is 25% or less of the candles total range.

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

prohibit trades when > supertrend


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
UkDownUnder @jamescoop Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by Vonasi
5 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/06/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...