Buy 2% from opening price

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #98855 quote
    MA CåMA Cå
    Participant
    New

    hi

    first post from sweden.

    im looking for a code to do the following:

    Buy stock when up 2,2% from openening price the same day and then has retracted down below a moving average of my choosing during a specefic timeframe say the first 60 min from market open.

    I have tryied coding it whotout succses, having problems whit getting the % up to work.

    Thanks for the help.

    br marcus, sweden.

    #98967 quote
    NicolasNicolas
    Keymaster
    Legend

    You can try with the below code, the “trigger” variable is the one used to test the gap percent at the first opening hour. “endtime” is the time limit to test the price retraction below the moving average. There is no stop and limit in the code.

    defparam cumulateorders=false
    
    trigger = 0.5 //trigger in percent 
    
    timeframe(daily)
    percent = Variation(close)
    
    timeframe(default)
    endtime = 100000
    MAperiod = 10
    
    if day<>day[1] then 
    todayvar = percent 
    todaystart=barindex
    endif 
    
    MA = average[MAperiod](close)
    
    if time<=endtime and todaystart<>start and todayvar>=trigger and close crosses under MA then  
    start=todaystart
    buy at market 
    endif 
    
    //graph time<=endtime and todaystart<>start and todayvar>=trigger
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

Buy 2% from opening price


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
MA Cå @ma_ca Participant
Summary

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

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