how to code takeprofit and stoploss?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #39546 quote
    CHIFHE
    Participant
    Junior

    how do i write a code  to take a profit on long when prices moves up 250 pips

    and on short 250 pips and then stop loss on both when prices moves against the trade 250.

     

    ratio is 1:1

    #39554 quote
    GraHal
    Participant
    Master
    Set stop pprofit 250
    Set stop ploss 250
    #39558 quote
    CHIFHE
    Participant
    Junior

    Thank you very much

    #39562 quote
    CHIFHE
    Participant
    Junior

    grahal, i am still having an error on my program, can you please assists

     

    // Conditions to enter long positions
    indicator1 = Cycle(close)
    c1 = (indicator1 CROSSES OVER -20)
    indicator2 = CCI[20]
    c2 = (indicator2 CROSSES OVER -100)
    indicator3 = Cycle(close)
    c3 = (indicator3 CROSSES OVER 0)
    
    IF c1 OR c2 OR c3 THEN
    BUY 2 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    Set stop Pprofit 250
    Set stop ploss 250
    
    
    
    endif
    
    // Conditions to enter short positions
    indicator5 = Cycle(close)
    c5 = (indicator5 CROSSES UNDER 20)
    indicator6 = CCI[20]
    c6 = (indicator6 CROSSES UNDER 100)
    indicator7 = Cycle(close)
    c7 = (indicator7 CROSSES UNDER 0)
    
    IF c5 OR c6 OR c7 THEN
    SELLSHORT 2 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    Set stop Pprofit 250
    Set stop ploss 250
    
    ENDIF
    #39565 quote
    GraHal
    Participant
    Master

    You’ve got two IFs and 4 EndIfs … is that the problem?

    Also please use the <> Insert PRT Code button to add code to this page as then your code will be formatted and also in colour and will then be so much easier to read 🙂

    Nicolas thanked this post
    #39646 quote
    Nicolas
    Keymaster
    Master

    GraHal is right, your 2 ENDIF at lines 19 and 37 should not be present.

    #39675 quote
    CHIFHE
    Participant
    Junior

    Thanks guys, now is perfect. I appreciate your help.

    #39681 quote
    GraHal
    Participant
    Master

    Also it should be (target not stop) my mistake, sorry.

    Set target pprofit 250
    
     
    
    #39691 quote
    GraHal
    Participant
    Master

    What Market and Timeframe is this Strategy optimised for please CHIFHE? I’m developing an affinity for it now! 🙂

    Thanks
    GraHal

    #39698 quote
    CHIFHE
    Participant
    Junior

    is SA40 Grahal, I was doing trial and error on it. May be you can help to achieve more that 65 % on back testing it. is a 2hrs time frame.

     

    Regards

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

how to code takeprofit and stoploss?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
CHIFHE @tshivhmc1 Participant
Summary

This topic contains 9 replies,
has 3 voices, and was last updated by CHIFHE
8 years, 8 months ago.

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