Creating a stop at the low of a particular bar

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #32066 quote
    Stratus6
    Participant
    Junior

    Dear Forum,

    I’d be grateful for any help with the following straighforward coding problem.

     

    Once my trade is entered I want to set a stop at the low of the preceeding bar.

    Now I assumed it would just be

    Sell at Low[1] stop

    However, in backtest at least, this seems to change as Low[1] moves one bar forward with the creation of each new bar.

    Does anyone know the fix for this?

    Many thanks all

    Linden

    #32083 quote
    Wing
    Participant
    Veteran

    After the line of code where you buy, you need another line of code to save the low of the previous bar for future use. Example:

    once MyStop = 1
    
    If buyconditions=true and onmarket=0
        buy 1 lot at market
        MyStop = low[1]
    endif
    
    sell at MyStop stop
    #32106 quote
    GraHal
    Participant
    Master

    Thanks Wing, I understand above, except why we need …

    once MyStop = 1
    
    Thank You
    GraHal
    #32111 quote
    Stratus6
    Participant
    Junior

    Thanks Wing, thats really fantastic.

    Many thanks

    Linden

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Creating a stop at the low of a particular bar


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
Stratus6 @stratus6 Participant
Summary

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

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 04/14/2017
Status: Active
Attachments: No files
Logo Logo
Loading...