IF LONGONMARKET THEN / IF SHORTONMAKRET THEN

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5481 quote
    David
    Participant
    Veteran

    I have an inconsistency in execution of code and am wondering if some could test and get the same results.

    IF LONGONMARKET THEN SET STOP pLOSS SET TARGET pPROFIT – Doesn’t work

    IF SHORTONMAKRET THEN SET STOP pLOSS SET TARGET pPROFIT – Does work

    Maybe someone can explain why there’s this inconsistency

     

    //***** EXAMPLE 1: LONGONMARKET *****
    
    //*****STOP pLOSS AND TARGET pPROFIT DON'T WORK****
    
    // Definition of code parameters
    DEFPARAM CumulateOrders = FALSE // Cumulating positions
    
    // Conditions to enter long positions
    indicator1 = close
    indicator2 = Average[20](totalPrice) //
    c1 = (indicator1 CROSSES OVER indicator2)
    
    IF c1 THEN
     BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    
    IF LONGONMARKET THEN
     SET TARGET pPROFIT 45 //
     SET STOP pLOSS 40 //
    ENDIF

     

    //***** EXAMPLE 2: SHORTONMARKET *****
    
    //*****STOP pLOSS AND TARGET pPROFIT DON'T WORK****
    
    // Definition of code parameters
    DEFPARAM CumulateOrders = FALSE // Cumulating positions
    
    // Conditions to enter short positions
    indicator1 = close
    indicator2 = Average[20](totalPrice) //
    c1 = (indicator1 CROSSES OVER indicator2)
    
    IF c1 THEN
     SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    
    IF SHORTONMARKET THEN
     SET TARGET pPROFIT 45 //
     SET STOP pLOSS 40 //
    ENDIF

     

    Thank you.

    #5485 quote
    Nicolas
    Keymaster
    Master

    Well, I got no idea right now why it doesn’t work. But this code should solve your issue :

    IF c1 THEN
     SELLSHORT 1 CONTRACT AT MARKET
     SET TARGET pPROFIT 45 //
     SET STOP pLOSS 40 //
    ENDIF

     

    Let me know if it’s alright now!

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

IF LONGONMARKET THEN / IF SHORTONMAKRET THEN


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
David @dwgfx Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
9 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/16/2016
Status: Active
Attachments: No files
Logo Logo
Loading...