How to get the 8am open price into the code

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #92351 quote
    garyoatengaryoaten
    Participant
    Average

    Is there a way to get the code to automatically work out the 8am open price in the code so it adjusts itself every day?

    #92357 quote
    robertogozzirobertogozzi
    Moderator
    Legend
    IF time = 080000 THEN
     .
     .      //write whatever you want to be done at 08:00am here
     .
    ENDIF
    #92360 quote
    garyoatengaryoaten
    Participant
    Average

    Thanks,

    Will give it a try.

    Harrys thanked this post
    #92370 quote
    garyoatengaryoaten
    Participant
    Average
    defparam cumulateorders=false
    
    // --- settings
    value = 7200 //daily FTSE 8am open price
    myTarget = 1.25 //target profit coefficient
    Capital = 25000 //capital at starting of the strategy
    Risk = 2 //risk in %
    StartTime = 080000
    EndTime = 163000
    // --- end of settings
    
    //indis
    ema20 = average[20,1]
    istd = std[20]
    bollup = ema20+(istd*2)
    bolldn = ema20-(istd*2)
    tcondition = (time>=StartTime and time<=EndTime) and (opendayofweek>=1 and opendayofweek<=5)
    
    if tcondition then
    //short orders
    if high-ema20>Value*0.0002 and low>bollup then
    //money managenemt
    sellentry = low-1*pointsize
    sellstoploss = high+2*pointsize
    StopLoss = sellstoploss-sellentry
    selltarget = StopLoss*myTarget
    equity = Capital + StrategyProfit
    maxrisk = round(equity*(Risk/100))
    PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
    //pending order
    sellshort PositionSize contract at sellentry stop
    set target profit selltarget
    set stop loss StopLoss
    endif
    
    //long orders
    if ema20-low>Value*0.0002 and high<bolldn then
    //money managenemt
    buyentry = high+1*pointsize
    buystoploss = low-2*pointsize
    StopLoss = buyentry-buystoploss
    buytarget = StopLoss*myTarget
    equity = Capital + StrategyProfit
    maxrisk = round(equity*(Risk/100))
    PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
    //pending order
    buy PositionSize contract at buyentry stop
    set target profit buytarget
    set stop loss StopLoss
    endif
    endif
    
    //graph high-ema20>value*0.2 and low>bollup
    
    
    #92371 quote
    garyoatengaryoaten
    Participant
    Average

    Roberto,

    I tried what you suggested but couldnt get it to do what I wanted? How do I get it to automatically work out the 8am open price of the FTSE so I dont have to manually put it in the “Value” of my settings before I start it in the mornings?

    Sorry but Im very new to programming

    Thanks,

     

    gary

    #92373 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    What do you want to di with the OPEN price at 8am ?

    Which TF are you using?

    #92377 quote
    garyoatengaryoaten
    Participant
    Average

    Hi,

    Its on the 5min TF and all I want is for the code to know what the 8am open price is so I dont have to manually adjust the “Value” setting each day.

    Thanks

    #92385 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    At line 11 add:

    IF time = 080000 THEN
       PriceAt0800 = open
    ENDIF

    then use variable PriceAt0800 whenever you need thet value.

    #92386 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    In case it is not the price you need replace TIME with OPENTIME.

    #92389 quote
    garyoatengaryoaten
    Participant
    Average

    Many thanks Roberto.

    Seems to work ok, good to learn so hopefully I will know a bit more for the future.

    robertogozzi thanked this post
Viewing 10 posts - 1 through 10 (of 10 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

How to get the 8am open price into the code


General Trading: Market Analysis & Manual Trading

New Reply
Author
author-avatar
garyoaten @garyoaten Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by garyoatengaryoaten
7 years, 7 months ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 02/26/2019
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...