How to get the 8am open price into the code

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #92351 quote
    garyoaten
    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
    robertogozzi
    Moderator
    Master
    IF time = 080000 THEN
     .
     .      //write whatever you want to be done at 08:00am here
     .
    ENDIF
    #92360 quote
    garyoaten
    Participant
    Average

    Thanks,

    Will give it a try.

    Harrys thanked this post
    #92370 quote
    garyoaten
    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
    garyoaten
    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
    robertogozzi
    Moderator
    Master

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

    Which TF are you using?

    #92377 quote
    garyoaten
    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
    robertogozzi
    Moderator
    Master

    At line 11 add:

    IF time = 080000 THEN
       PriceAt0800 = open
    ENDIF

    then use variable PriceAt0800 whenever you need thet value.

    #92386 quote
    robertogozzi
    Moderator
    Master

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

    #92389 quote
    garyoaten
    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.

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 garyoaten
7 years ago.

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