barindex trouble

Viewing 2 posts - 16 through 17 (of 17 total)
  • Author
    Posts
  • #54978 quote
    Leo
    Participant
    Veteran

    WOW !

    Now I noticed that your will never work beacuse a moving avearage never intersect a previous highest high!

    how would you rewrite my code in post 1, to make it actually trade if the close[0] > highest high in past 20 candles?

    Here’s your code

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated 
    DEFPARAM preloadbars=100
     
    // Conditions to enter long positions
    buy1 = highest[20](high)
    sell1 = lowest[20](low)
     
    buysignal = buy1[1] < close
    sellsignal = sell1[1] > close
    if buysignal then
    buy 1 contract at market
    elsif sellsignal then
    sellshort 1 contract at market
    endif
     
     
    if longonmarket and Close < Close[2]  then
    sell at market
    endif
    
    IF shortonmarket and Close> Close[2] then
    exitshort at market
    endif
    
    #55043 quote
    jebus89
    Participant
    Master

    @Leo,  thanks, makes much more sense now. Im not pushing anything out in live hehe just trying to understand 🙂 

Viewing 2 posts - 16 through 17 (of 17 total)
  • You must be logged in to reply to this topic.

barindex trouble


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
jebus89 @jebus89 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/05/2017
Status: Active
Attachments: No files
Logo Logo
Loading...