Stop loss based on bar close instead of position opening

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #197496 quote
    JodalJodal
    Participant
    New

    Hello All !

    I would like to set a stop loss based on the last bar close instead of the position opening.

    I am currently using an algo that stops once my current profit target is reached (thanks @robertogozzi !) but I often miss bigger profit opportunities when the trade keeps going in my direction.

    That is why I would like to tweak it a bit

    FROM

    “Once my daily target is reached, close position and stop for the day”

    TO

    “Once my daily target is reached, set a STOP LOSS 10 points below close and stop for the day once the strategyprofit is reached (will close when the next condition is met).

    That is what I use now (works well):

    ONCE MyGOAL = 50                    //50 pips Daily
    IF OnMarket AND (Tally + ((PositionPerf * PositionPrice / PipSize)) >= (MyGOAL * PipSize)) THEN
    SELL      AT Market
    EXITSHORT AT Market
    TradeON = 0

    I would like to replace it with 2 components that would be:

    ONCE MyGOAL = 60                    //60 pips Daily
    IF OnMarket AND (Tally + ((PositionPerf * PositionPrice / PipSize)) >= (MyGOAL * PipSize)) THEN
    SET STOP pLOSS (close - 10)
    ENDIF
    
    IF STRATEGYPROFIT > 50 THEN
    QUIT
    ENDIF

    2 questions
    – Would a STOP LOSS set up as above work? (“Close – 10”)? Or should I write “Close[1] – 10”?
    – Would the combination of both work the way I want it to?

    Your help would be appreciated!
    Enjoy your day

    #197525 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Replace line 3 of the second code snippet with this new instruction added a few months ago:

    Set Stop Price (close - 10*PipSize)
    Jodal thanked this post
Viewing 2 posts - 1 through 2 (of 2 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

Stop loss based on bar close instead of position opening


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Jodal @jodal Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
4 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/19/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...