ProBack test – Exit Trade during bar

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #186823 quote
    Paulg999Paulg999
    Participant
    New

    Hi,

    Is it possible to exit a trade when the ask price crosses a level rather than having to wait fore the closed price?

    If this is possible how do i modify this?

    // Conditions to exit long positions
    indicator28 = ExponentialAverage[50](close)
    c22 = ( CROSSES OVER indicator28)
    
    IF c22 THEN
    SELL AT MARKET
    ENDIF
    #186826 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    You can achieve that by using multiple time frames, so you can access, say 1-hour candle, every minute or every second.

    Searching this forum for MTF will return you many useful articles, examples and code snippets.

    Paulg999 thanked this post
    #186841 quote
    Paulg999Paulg999
    Participant
    New

    My coding is in its infancy along with my knowledge of Probacktest. I can’t seem to find what I’m looking for.

    Can you do this in the simplified or must you do it in creation by programming?

    Based on PRT attachement above my default timeframe is 2m.

    I want to exit the trade when price crosses the 20ema or a.s.a.p

    Am I write in thinking that I need to select a lower T/F (lets say 1 second) & we can use 1s closed bars to trigger the exit.

    How would this code be written?

    #186979 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    timeframe(default)	
    // Conditions to exit long positions
    indicator28 = ExponentialAverage[20](close)
    c22 = (CROSSES OVER indicator28)
    IF c22 THEN
       SELL AT MARKET
    ENDIF

    append it to your code and run it on a TF lower than 2 minutes (and of which 2 minutes is a multiple, say 10 secondfs or 1 second).

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

ProBack test – Exit Trade during bar


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Paulg999 @paulg999 Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/28/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...