Problem with stop loss optimization.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #74565 quote
    Forexsake
    Participant
    New

    Hi , I am trying to learn hoe to code a programme and I am having some issues. I would like to try optimization , but I am not sure where to put my variable for a stop.

    My variable is called “stop” ,

    // Definition of code parameters 
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated 
    
    // Conditions to enter long positions 
    indicator1 = MACDline[12,26,9](close) 
    indicator2 = ExponentialAverage[9](indicator1) 
    c1 = (indicator1 CROSSES OVER indicator2) 
    
    IF c1 THEN
    BUY 1 PERPOINT AT MARKET 
    ENDIF 
    
    // Conditions to exit long positions 
    indicator3 = MACDline[12,26,9](close) 
    indicator4 = ExponentialAverage[9](indicator3) 
    c2 = (indicator3 CROSSES UNDER indicator4)
     
    IF c2 THEN 
    SELL AT MARKET 
    ENDIF 
    
    // Conditions to enter short positions 
    indicator5 = MACDline[12,26,9](close) 
    indicator6 = ExponentialAverage[9](indicator5) 
    c3 = (indicator5 CROSSES UNDER indicator6) 
    
    IF c3 THEN 
    SELLSHORT 1 PERPOINT AT MARKET 
    ENDIF 
    
    // Conditions to exit short positions 
    indicator7 = MACDline[12,26,9](close) 
    indicator8 = ExponentialAverage[9](indicator7) 
    c4 = (indicator7 CROSSES UNDER indicator8) 
    
    IF c4 THEN 
    EXITSHORT AT MARKET 
    ENDIF 
    
    // Stops and targets 
    SET stop pLOSS 30

     

    I have tried replacing the 30 with [stop] but it does not work. Any help really appreciated for a newbie.

    #74567 quote
    Vonasi
    Moderator
    Master

    Please use the ‘Insert PRT Code’ button when putting code in your posts. I have tidied up your post for you.

    Also in future posts please try to use a topic title that means something rather than just ‘Basic coding help’. I will change your topic title to something more meaningful.

    You can not use the variable name ‘stop’ as it is an instruction used in PRT code already. Change it to SL or something similar.

    The last line of your code would then be:

    set stop ploss SL
    #74569 quote
    Forexsake
    Participant
    New

    Perfect , thanks. And will make sure I do it right next time,

    Vonasi thanked this post
    #74578 quote
    GraHal
    Participant
    Master

    indicator7 = MACDline[12,26,9](close) indicator8 = ExponentialAverage[9](indicator7) c4 = (indicator7 CROSSES UNDER indicator8)   IF c4 THEN EXITSHORT AT MARKET ENDIF

    You sure you don’t want above to read CROSSES OVER ??

    Great username Forexsake btw! 🙂

    #74588 quote
    Forexsake
    Participant
    New

    Hi Grahal. I will have a look at that tonight thanks. I did think a lot about my username and I now use it for all forums etc.. I was quite impressed I came up with something a tad humorous..

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

Problem with stop loss optimization.


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Forexsake @forexsake Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Forexsake
7 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/27/2018
Status: Active
Attachments: No files
Logo Logo
Loading...