buy lotsize contract at high-(range*.5) stop

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #198890 quote
    josward1
    Participant
    New

    Hi, could somebody please explain what the following lines of coding mean:

    if not longonmarket and buyc2 then
    if range>SignalLargerThan*pointsize Then
    buy lotsize contract at high-(range*.5) stop

     

    and

     

    if not shortonmarket and sellc2 then
    if range>SignalLargerThan*pointsize Then
    sellshort lotsize contract at low+(range*.5) stop
    else

     

    I think i get the most of it it’s just these parts i don’t understand…  buy lotsize contract at high-(range*.5) stop

    sellshort lotsize contract at low+(range*.5) stop

     

    If i change the (range*.5) to (range*.0) i get different results…  I’m trying to get my head around exactly how the code is executing trades on a backtest.

    #198893 quote
    robertogozzi
    Moderator
    Master

    RANGE*0.5 is just a variable offset to enter a trade. You can write a fixe4d value, such as 20*PipSize.
    It means that it will BUY at HIGH – x or SELLSHORT at LOW + x.
    You can use any expression of your choice, could be ATR or any other valid offset.

    #198906 quote
    josward1
    Participant
    New

     

    Thanks for your response

    Does this mean it creates a market order + x or – x from the close of the previous  candle? And the x value is however much I want the offset to be?

    so if I don’t want an offset and set it to .0 will the trades be executed immediately?

    #198912 quote
    robertogozzi
    Moderator
    Master

    Yes, 0 will remove the offest.

    The offeset is based on the RANGE of the candle, so it is not fixed.

    #198923 quote
    josward1
    Participant
    New

    Ok thanks. In this case what would the relationship be between the range of the candle and where the market order gets placed?

    is it based on the range of the candle which produces the signal?

    I have the: if range>SignalLargerThan*pointsize  set to 0 in variable optimisation

    #198926 quote
    robertogozzi
    Moderator
    Master

    is it based on the range of the candle which produces the signal?  Yes 

    what would the relationship be between the range of the candle and where the market order gets placed?  It’s the multiplier x.x, be it 0 or 0.5

    If SignalLargerThan is set to 0, then the condition  IF RANGE >… will always be true.

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

buy lotsize contract at high-(range*.5) stop


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
josward1 @josward1 Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/10/2022
Status: Active
Attachments: No files
Logo Logo
Loading...