Cross Over Strategy HELP please

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #61121 quote
    crolakstrading
    Participant
    Senior

    Hi Roberto,

    its me again to bother you! 🙂

    I have been testing this manually and also try to create a strategy so i managed to get below ,i got this and try to change this from the forum but i really don’t know how to get the entry at 5pips above and below according to the indicator when the cross over happen.

    is this something you can help out?

    the numbers are just numbers.. i mean SL and targets etc.. hoping i can change this change!!

    Many Thanks

    Ro

     

    // Conditions to enter long positions
    i1 = exponentialaverage[9](close)
    i2 = exponentialaverage[40](close)
     
    long = i1 crosses over i2
    short = i1 crosses under i2
    IF NOT LongOnMarket AND long THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    If LongOnMarket AND short THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND short THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    IF ShortOnMarket AND long THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops and targets : Enter your protection stops and profit targets here
    // points based STOP LOSS and TRAILING STOP
    // initial STOP LOSS
    SET STOP pLOSS 30
     
    // trailing stop
    SET STOP pTRAILING 20
    #61123 quote
    crolakstrading
    Participant
    Senior

    please if you can add up and correct me, really appreciated!!

    #61127 quote
    robertogozzi
    Moderator
    Master

    I’ll take a look at your code tomorrow.

    crolakstrading thanked this post
    #61129 quote
    crolakstrading
    Participant
    Senior

    Thank you @robertogozzi

    #61158 quote
    robertogozzi
    Moderator
    Master

    Since you are now talking about a strategy I just moved the topic to ProOrder support.

    Back tomorrow for hints.

    #61189 quote
    robertogozzi
    Moderator
    Master

    You only have to change lines 8 and 18 as follows

    BUY       1 CONTRACTS AT close + (5 * pipsize) LIMIT
    SELLSHORT 1 CONTRACTS AT close - (5 * pipsize) LIMIT

    but, since a LIMIT/STOP order expires when the candle closes, do you want to place it again through the following candles? If yes, till when, maybe till the opposite crossing happens?

    Also, replacing LIMIT with STOP would do better, I guess.

    #61196 quote
    crolakstrading
    Participant
    Senior

    Thanks for this..for some reason it say this cannot be added because trailing stop are not enabled in my account..

    I have removed the trailing stop.

    just to make sure will this wait for 5bars then take the 5pips above or below highs/ lows as an entry?

    IF CrossOver[5] THEN

    IF summation[4](CrossOver OR CrossUnder) = 0 THEN
    TopLine = highest[5](high) + (5 * pipsize)

     

    how can we replace LIMIT with STOP?

    // Conditions to enter long positions
    i1 = exponentialaverage[9](close)
    i2 = exponentialaverage[40](close)
     
    long = i1 crosses over i2
    short = i1 crosses under i2
    IF NOT LongOnMarket AND long THEN
    BUY 1 CONTRACTS AT close + (5 * pipsize) LIMIT
    ENDIF
     
    // Conditions to exit long positions
    If LongOnMarket AND short THEN
    SELL AT MARKET
    ENDIF
     
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND short THEN
    SELLSHORT 1 CONTRACTS AT close - (5 * pipsize) LIMIT
    ENDIF
     
    // Conditions to exit short positions
    IF ShortOnMarket AND long THEN
    EXITSHORT AT MARKET
    ENDIF
     
    // Stops and targets : Enter your protection stops and profit targets here
    // points based STOP LOSS and TRAILING STOP
    // initial STOP LOSS
    SET STOP pLOSS 30
    #61203 quote
    crolakstrading
    Participant
    Senior

    not sure what you mean by  replacing LIMIT with STOP?

    another way is let say when its move 20pip on profit  stop to break even!!!

    #61206 quote
    robertogozzi
    Moderator
    Master

    Yes, your lines should do good.

    As for your stops I don’t know about your limits with IG, but I want to point out that, despite examples in the PRT manual, the first one (SET STOP pLOSS 30) would be overridden by the second one (SET STOP pTRAILING 20), since they cannot be set together.

     

    not sure what you mean by replacing LIMIT with STOP?

    LIMIT guarantees execution only at the price you decided (or a most favourable one) and is used when you BUY at a lower price or SELLSHORT at a higher one, while STOP guarantees execution no matter what price (provided the price you decided is reached) and is used when you BUY at a higher price or SELLSHORT at a lower one.

    #61207 quote
    crolakstrading
    Participant
    Senior

    ahh ok.. its a better idea! 🙂 where should i change?

    is possible to make the stop loss to Break even once its reach to a certain point too?

    #61210 quote
    robertogozzi
    Moderator
    Master

    As for Breakeven you should read, merge into your code and experiment with Nicols’ code (https://www.prorealcode.com/blog/learning/breakeven-code-automated-trading-strategy/).

    If you search Breakeven in the forum you’ll find plenty of code to to use and learn  from.

    I modified the BUY/SELLSHORT lines to accomodate for an evaluation of price, to check whether EntryPrice is more favourable (in order to use LIMIT) or not (in order to use STOP):

    // Conditions to enter long positions
    i1 = exponentialaverage[9](close)
    i2 = exponentialaverage[40](close)
     
    long  = i1 crosses over  i2
    short = i1 crosses under i2
    IF NOT LongOnMarket AND long THEN
       EntryPrice = close + (5 * pipsize)
       IF EntryPrice < close THEN
          BUY 1 CONTRACTS AT EntryPrice LIMIT
       ELSE
          BUY 1 CONTRACTS AT EntryPrice STOP
       ENDIF
    ENDIF
     
    // Conditions to exit long positions
    If LongOnMarket AND short THEN
       SELL AT MARKET
    ENDIF
     
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND short THEN
       EntryPrice = close - (5 * pipsize)
       IF EntryPrice > close THEN
          SELLSHORT 1 CONTRACTS AT EntryPrice LIMIT
       ELSE
          SELLSHORT 1 CONTRACTS AT EntryPrice STOP
       ENDIF
    ENDIF
     
    // Conditions to exit short positions
    IF ShortOnMarket AND long THEN
       EXITSHORT AT MARKET
    ENDIF
     
    // Stops and targets : Enter your protection stops and profit targets here
    // points based STOP LOSS and TRAILING STOP
    // initial STOP LOSS
    SET STOP pLOSS 30
    #61211 quote
    crolakstrading
    Participant
    Senior

    Thanks very much!! for the link too… will do some more testing to find a better way!!

    #61535 quote
    crolakstrading
    Participant
    Senior

    Hi Roberto,

    As i have been testing this past few days.. i think the best entry is the STOP. as its more like a breakout! it didnt give e the right entry according  to the indicator? as the for the indicator TOPLINE or the Bottomline

    if TOPLINE that should be the proper entry:

    IF CrossUnder[5] THEN
    IF summation[4](CrossOver OR CrossUnder) = 0 THEN
    BottomLine = lowest[5](low) - (5 * pipsize)
    DRAWTEXT("---#BottomLine#---",barindex-3,BottomLine,SansSerif,Bold,16)coloured(153,0,0)
    so i have managed to change this as below, and it gives  the entry according to the indicator
    IF NOT LongOnMarket AND long[5] THEN
    EntryPrice = highest[5](high) + (5* pipsize)
    BUY 1 CONTRACTS AT EntryPrice STOP
    ENDIF

    but its only trigger on the the 5th candle.. if after the 5th candle if its go up and the original entryprice wont get triggered?? is there a way to change this?? once we get the entry price.. it gets trigger any next 10 canldes once we get the original enterprice?

    full code below..

    // Conditions to enter long positions
    i1 = exponentialaverage[9](close)
    i2 = exponentialaverage[40](close)
     
    long  = i1 crosses over  i2
    short = i1 crosses under i2
    IF NOT LongOnMarket AND long[5] THEN
    EntryPrice = highest[5](high) + (5* pipsize)
    BUY 1 CONTRACTS AT EntryPrice STOP
    ENDIF
    
     
    // Conditions to exit long positions
    If LongOnMarket AND short THEN
    SELL AT MARKET
    ENDIF
     
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND short[5] THEN
    EntryPrice = lowest[5](low) - (5 * pipsize)
    SELLSHORT 1 CONTRACTS AT EntryPrice STOP
    ENDIF
     
    // Conditions to exit short positions
    IF ShortOnMarket AND long THEN
    EXITSHORT AT MARKET
    ENDIF
     
    // Stops and targets : Enter your protection stops and profit targets here
    // points based STOP LOSS and TRAILING STOP
    // initial STOP LOSS
    SET STOP pLOSS 30

     

    #61538 quote
    crolakstrading
    Participant
    Senior

    lets say the its going long.. once we get the enryprice 5 pip above etc (topline on the idicator) …and if it didnt get triggered on the 5th bar but it gets triggered on the 9th bar if it reach original entryprice?? please see attached pic!!!

    Capture_2018_02_05_10_44_07_394.png Capture_2018_02_05_10_44_07_394.png
    #61666 quote
    crolakstrading
    Participant
    Senior

    i mean how can we get the exact ToplLine or the Bottomline as an entry according to the indicator.. and entry price will act as a stop order when ever the market reach the entry price?? seems very complicated.. but i tried 100 ways didnt really work out 🙁

Viewing 15 posts - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.

Cross Over Strategy HELP please


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 22 replies,
has 2 voices, and was last updated by crolakstrading
8 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/31/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...