How do I open a position in the first bar of a newly started trading system ?

Viewing 14 posts - 16 through 29 (of 29 total)
  • Author
    Posts
  • #65790 quote
    verdi55
    Participant
    Veteran

    of course, I just meant your concept.

    You could say :

    If date = 20180320 and TIME = 073500 then
    buy 1 contract at market
    endif
    
    

    to open a position in a system in the 1 minute chart that was started between 7:34 and 7:35 and will have its first bar at 7:35.

    Agree ?

    #65792 quote
    verdi55
    Participant
    Veteran

    Problem may be if you start a system out of hours and there is accidentally no bar at 7:35, no position will be opened.

    So, the method with prelaodbars and barindex may be more reliable.

    #65800 quote
    Leo
    Participant
    Veteran

    I have posted a system that opens a position exactly at last minute of opened markets.

    As far I understand you want a code that opens a position exactly when it is activated and then controls the trade itself. I think is a very powerful tool for manual trading as default style of trading.

    By the way, once I test a code that opens stop and limit orders symulstaniously. Then the first try I had a copy paste problem the result was that it opened a trade “exactly at the moment of activation not at the end of the bar closing. That means for me that prorealtime runs the systems at the moment of activation like running the code at every closing bar.

    let us know your progress

    #65828 quote
    GraHal
    Participant
    Master

    to open a position in a system in the 1 minute chart that was started between 7:34 and 7:35 and will have its first bar at 7:35.

    It would be a pain having to open the System in the coding window and then enter date and starting Time then back to the system running window then delete the old system (without current date and time) and also you would lose your Performance History.  Or am I misunderstanding?

    Yes Leo I am also thinking this Snippet could form part as a semi-manual entry, auto close trading Strategy.

    Good Work Verdi55
    GraHal

    #66680 quote
    David
    Participant
    Veteran

    I use this:

    If not onmarket then
    buy 1 contract at market
    endif
    
    // Set Stops and Profits
    
    IF StrategyProfit <> 0 then
    QUIT
    ENDIF
    
    Andyswede thanked this post
    #66691 quote
    verdi55
    Participant
    Veteran

    Thanks. Or maybe we could say :

    If barindex = tradeindex then
    flag = 1
    endif
    
    If not onmarket and flag = 0 then
    buy 1 contract at market
    endif

    This would definitely open only 1 position, even if the result of the first position is accidentally zero.

    #67966 quote
    Leo
    Participant
    Veteran

    Here my code. I was not able to open a position exactly when the system is activated rather it opens a position in the next bar.

    My code is thought to be a standard

    DEFPARAM CumulateOrders = false // Cumulating positions deactivated
    DEFPARAM PreLoadBars = 100 //cargar informacion
    
    IF NOT ShortOnMarket THEN
    BUY 1 CONTRACTS AT MARKET
    SET STOP pLOSS 15
    SET TARGET pPROFIT 30
    ENDIF
    MySAR= SAR[0.005,0.01,0.7]
    IF shortonmarket then
    IF close crosses under MySAR THEN
    EXITSHORT AT MARKET
    ENDIF
    
    IF CLOSE-POSITIONPRICE > 7*PIPSIZE THEN
    SET STOP pLOSS 1
    ENDIF
    ENDIF
    
    IF shortonmarket[1] and not shortonmarket then
    QUIT
    ENDIF
    

     

    manual trade for me.

    #67968 quote
    verdi55
    Participant
    Veteran

    nonono

    #67969 quote
    Leo
    Participant
    Veteran
    #67971 quote
    verdi55
    Participant
    Veteran

    MySAR= SAR[0.9999,0.11111,0.222222]

    #67972 quote
    verdi55
    Participant
    Veteran

    Maybe as an Italian, you will better understand this :

    https://www.youtube.com/watch?v=UTO_KF04UiA

    #67985 quote
    Leo
    Participant
    Veteran

    I do not have any clue what are you talking about or why you are posting so weird videos.

    #67988 quote
    verdi55
    Participant
    Veteran

    What is more weird ? Speculating about 7*PIPSIZE

    or such videos ?

    #67991 quote
    Leo
    Participant
    Veteran

    So you were being sarcastic… I got it.

    Anyway.

    what about the code I posted? What’s your opinion apart of my costant values?

Viewing 14 posts - 16 through 29 (of 29 total)
  • You must be logged in to reply to this topic.

How do I open a position in the first bar of a newly started trading system ?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
verdi55 @verdi55 Participant
Summary

This topic contains 28 replies,
has 5 voices, and was last updated by Leo
7 years, 10 months ago.

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