Need help on the code closing positions

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #38000 quote
    ramarama
    Participant
    Senior

    I am using the following code

    (after opening initial position long or strong)

     

    ****************************************

    IF longonmarket and COUNTOFPOSITION <= 100 THEN
    buy 1 perpoint at tradeprice(1)+x2 stop

    endif

    IF shortonmarket and COUNTOFPOSITION <= 100 THEN
    sellshort 1 perpoint at tradeprice(1)-x2 stop
    endif

     

     

    profitstop =.9999*tradeprice(1)
    profitstop1 =1.0001*tradeprice(1)
    if longonmarket then
    sell at profitstop stop
    endif

     

    if shortonmarket then
    exitshort at profitstop1 stop
    endif

     

    ********************

    the code is working but not efficiently the I wanted.

     

    I want to sell my all open long postions if prices goes down by 2 points( on spread betting account)

    also I want to close my shot positions when price goes by 2 points

     

    I dont see any option  in PRT for this. ALL PRT just refers candles and time of current or previous, nth previous etc.

     

    can you provide me some logic?

    I tried the follwing also

     

    if (positionperf-positionperf)<=.00012 then

    sell at market

    endif

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Need help on the code closing positions


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rama @rama Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/10/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...