Open more positions

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #112622 quote
    Stefanb
    Participant
    Senior

    Want some help with a code.

    If an algo takes a long position and lies back 20 points, I want a new position to take too long.

    After all, in my manual trade, I usually take 3-4 positions to get in “right”.

    Another question.

    If my algo takes a long position in DAX with 0.5 contract and I want to open a long position to can I take an even smaller position then?

    0.25 contract?

    My total position will then be 0.75 contract.

    Know that minimum position is 0.5 contract but if you already have a position of 0.5 and add on it then it should work or?

    #112656 quote
    Stefanb
    Participant
    Senior

    Found this from Vonasi

    But, i want to buy if my position go at the wrong way with 20 points.

    DEFPARAM CumulateOrders = true
     
    IF not OnMarket and (your conditions) then
    Buy 1 contract at market
    ENDIF
     
    IF OnMarket and (your conditions) and close > PositionPrice then
    Buy 1 contract at market
    ENDIF
    #112657 quote
    Stefanb
    Participant
    Senior
    This code should do the trick..or?  
    DEFPARAM CumulateOrders = true
    
    POSITIONSIZE=1
    
    // Conditions to enter long positions
    IF (my conditions)  then
    BUY POSITIONSIZE CONTRACTS AT MARKET
    ENDIF
    
    if longonmarket and close - tradeprice < 20*pointsize then
    buy 1 contract at market
    endif

    #112670 quote
    Vonasi
    Moderator
    Master
    So you want to open a long position and then average down every time price drops at least 20 from your last trade price?
    DEFPARAM CumulateOrders = true
    
    POSITIONSIZE=1
    
    // Conditions to enter long positions
    IF not onmarket and (my conditions)  then
    BUY POSITIONSIZE CONTRACTS AT MARKET
    ENDIF
    
    if longonmarket and close < tradeprice - 20 then
    buy 1 contract at market
    endif
      As for opening smaller positions after the initial trade. You can only do this if the position size is greater than the minimum position size allowed by your broker. All orders are treated separately and must be at or above the minimum size allowed.
    #112677 quote
    Stefanb
    Participant
    Senior
    Thanks Vonasi Suspected that it was so regarding position size. If I want to limit to a maximum of 1 extra order. Can i use Max position = 2 then
    #112680 quote
    Vonasi
    Moderator
    Master
    DEFPARAM CumulateOrders = true
    
    POSITIONSIZE=1
    maxpositions = 2
    
    // Conditions to enter long positions
    IF not onmarket and (my conditions)  then
    BUY POSITIONSIZE CONTRACTS AT MARKET
    ENDIF
    
    if longonmarket and close < tradeprice - 20 and countofposition < maxpositions then
    buy 1 contract at market
    endif
    #112682 quote
    Stefanb
    Participant
    Senior
    Thanks Vonasi 🙂 Now that you are heated up:) When I do a back test I see that in the tick mode tab I have a figure of over 50. I think that is because buy and sell takes place in the same bar. What is the code to avoid it?
    #112698 quote
    Vonasi
    Moderator
    Master
    Yes that is because buy and sell takes place in the same bar. The only way to change it is by changing your exit conditions! Perhaps you have a very close stop loss or take profit target? If so then these will look great in back testing but in real life your broker will reject all your orders and your strategy will fall to pieces.
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Open more positions


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Stefanb @stefanb Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/12/2019
Status: Active
Attachments: No files
Logo Logo
Loading...