opening a pos on a specific price

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #209099 quote
    miric94miric94
    Participant
    New
    Hello! I want to backtest a few lines I have identified as good r/s levels but am an utter noob when it comes to coding. Say I want to test 11500 on NQ, when the price comes from above I want to long. doing this with the help of MA14. But I’m not sure what to use to specify the level, as I understand “close” it needs to actually close on that level, is there anything I can use for a touch? Don’t know if this makes any sense. 😀   In essence, I want to find out the best SL and TP for trading my levels.
    #209102 quote
    robertogozzirobertogozzi
    Moderator
    Legend
    Touch is when either LOW or HIGH reach or break that level, such as:
    If low  <= 11500 then //touched from above
    If high >= 11500 then //touched from below
    miric94 thanked this post
    #209103 quote
    miric94miric94
    Participant
    New
    Thanks Roberto! This really helped, when it reaches tp for example, it opens a new order the bar after as long as price is above my level, which I understand from the code is correct. How do I set it to not keep adding while above? So one buy per touch, if it touches again, buy.
    #209104 quote
    JSJS
    Participant
    Master

    If you do not want to open cumulative orders, you must place the following line at the beginning of your code:

    DefParam CumulateOrders=False

    An alternative is to use:

    If High CrossesOver Average[14](Close) then

    Buy 1 contract at Market

    EndIf

    If Low CrossesUnder Average[14](Close) then

    SellShort 1 contract at Market

    EndIf

    With the latter option, you only buy / sell when the price crosses with the average…

    miric94 thanked this post
    #209117 quote
    miric94miric94
    Participant
    New
    Yea sure that could work but I want to be really specific, which I understand is difficult. high >= “value” tp = 20 sl = 5 when either of those is hit and price is high >= the algo will keep opening positions. I really just want it to open a position when the line is touched. attached is a really bad example on s&p, there will be bad trades and these would be 2 of them, I still would like it to work but I can’t figure out how to open exactly on the line, and only then. Maybe smaller TF and maybe lesser MA. Any other ideas?
    terrible_example.jpg terrible_example.jpg
    #209119 quote
    JSJS
    Participant
    Master

    You could use Limit orders:

    If Close < Resistance then

    SellShort 1 contract at Resistance Limit

    EndIf

    If Close > Support then

    Buy 1 contract at Support Limit

    EndIf

Viewing 6 posts - 1 through 6 (of 6 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

opening a pos on a specific price


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
miric94 @miric94 Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by JSJS
3 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/04/2023
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...