Why does strategy open positions repeatedly?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #86041 quote
    rama
    Participant
    Senior
    // Definition of code parameters
    DEFPARAM CumulateOrders = true // Cumulating positions deactivated
    if  time > 080800 and time < 210000 then
    // Conditions to enter long positions
    indicator2, indicator1 = CALL johne
    c1 = (indicator1 >= indicator2)
    x=6
    c11 = (indicator1[1] >= indicator2[1])
    c111 = (indicator1[2] >= indicator2[2])
    IF c1 or c11 or c111 and not onmarket THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    if longonmarket then
    
    buy 1 perpoint at POSITIONPRICE+x stop
    
    endif
    
    if shortonmarket then
    
    sellshort 1 perpoint at POSITIONPRICE-x stop
    
    endif
    // Conditions to enter short positions
    ignored, indicator3 = CALL johne
    indicator4, ignored = CALL johne
    c2 = (indicator3 CROSSES UNDER indicator4)
    
    c22 = (indicator3[1] CROSSES UNDER indicator4[1])
    
    c222 = (indicator3[2] CROSSES UNDER indicator4[2])
    IF c2 or c22 or c222 and not onmarket THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    
    if longonmarket  and c2 then
    
    sell at market
    
    endif
    
    if shortonmarket and c1 then
    
    exitshort at market
    
    endif
    
    endif
    
    set stop loss 40
    set target profit 28
    

    I am trying to place an order 2,3,4 at positionprice+x or -x

    where as the program is just place at market at every subsequent time

    say if I run the program once it is long for every 2 seconds just it adds one more

     

    I tried even tradeprice(0)+x or -x even that is also not working

    #86043 quote
    Vonasi
    Moderator
    Master

    I have changed the subject title of your topic as it was meaningless.

    The format for CALL is:

    myValue1, myValue2, myValue3 = CALL "myIndicator" [parameter1,parameter2]

    See here for more info:

    CALL

    I’m surprised that your code runs with the format that you have used.

    #86057 quote
    Nicolas
    Keymaster
    Master

    POSITIONPRICE is the average price of all open positions. In order to add new order at a set distance from the last one, you should use TRADEPRICE instead.

    #86063 quote
    Vonasi
    Moderator
    Master

    I think that the incorrectly written CALL instruction is resulting in indicator1 and indicator2 always equalling zero and so all the entry conditions are always being met. It seems odd that the incorrectly written CALL instruction does not flag up an error.

    I just tested it on my demo platform and it does:

    [attachment file=86064]

    rama – Are you sure that you have posted the correct code?

    #86067 quote
    Nicolas
    Keymaster
    Master

    The syntax error you have is normal because you don’t have this file into your platform.

    It is possible to use CALL like the way @rama did. Because there are no settings and the indicator name doesn’t have special characters.

    #86068 quote
    Vonasi
    Moderator
    Master

    because you don’t have this file into your platform.

    Of course – how stupid of me. Not enough cups of tea yet and trying to do five things at once are my excuses!

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

Why does strategy open positions repeatedly?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
rama @rama Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/29/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...