in Search

how to test in 30 min chart for the price of open

Last post 06-24-2008, 12:40 by norwayturtle. 7 replies.
Sort Posts: Previous Next
  •  05-15-2008, 9:39 27186

    how to test in 30 min chart for the price of open

    Hi!

    I am coding a system now. I need to find the highest price with the opening and test the current close against it. I use 30 min chart. How can i do it.

    I have this code:

    Ref(CLOSE,0) > Ref(HIGH,-1)

    Please help:)

  •  05-15-2008, 18:48 27187 in reply to 27186

    Re: how to test in 30 min chart for the price of open

    Hi NorwayTurtle,

    Welcome to the Forum.

    I don't fully understand what you are looking to achieve, but hopefully, "On an intraday chart, compare the latest CLOSE price with the highest HIGH price since the first bar that trading day" comes close?


    Code:

    {identify the start of the trading day}
    newDay:=dayofmonth()<>Ref(dayofmonth(),-1) or cum(1)=2;

    {find the highest high so far this trading day}
    highestHigh:=highestsince(1,newDay,H);

    {compare the latest close with the highest high}
    {look for a higher close}
    C > Ref(highestHigh,-1);



    Hope this helps.

    wabbit Big Smile [:D]


    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status : wabbit.com.au SkyPE online status
    My SkyPE account : wabbit.com.au

  •  05-16-2008, 4:35 27188 in reply to 27187

    Re: how to test in 30 min chart for the price of open

    Thats very nice, Wabbit! Thanks!

    Do you know how I can only get the first signal from the Expert adviser on this code? Now I getting many signals,hehe.

  •  05-16-2008, 5:21 27189 in reply to 27188

    Re: how to test in 30 min chart for the price of open

    There are plenty of instances where you can find examples on how to achieve a counter... this is just one...

    Code:

    {identify the start of the trading day}
    newDay:=dayofmonth()<>Ref(dayofmonth(),-1) or cum(1)=2;

    {find the highest high so far this trading day}
    highestHigh:=highestsince(1,newDay,H);

    {compare the latest close with the highest high}
    {look for a higher close}
    x:=C > Ref(highestHigh,-1);

    {count and reset}
    count:=cum(x);
    reset:=newDay;
    counter:=count - valuewhen(1,reset,count);

    {signal/alert}
    counter=1 and Alert(counter=0,2);



    Hope this helps.

    wabbit Big Smile [:D]


    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status : wabbit.com.au SkyPE online status
    My SkyPE account : wabbit.com.au

  •  05-16-2008, 8:50 27192 in reply to 27189

    Re: how to test in 30 min chart for the price of open

    Great, Wabbit! I wanna kiss you, but I think your a boy, so I'll pass:)hehe

    I am pretty good in trading, but not in coding.

    Thanks again:)

    Best regards

    Norwayturtle
  •  05-30-2008, 0:27 27265 in reply to 27189

    Re: how to test in 30 min chart for the price of open

    I am getting the signal for buy and sell everytime the price changes in realtime. How can I code it, so the signal every 30 min says buy only one time when the conditions is met??
  •  05-31-2008, 0:21 27275 in reply to 27265

    Re: how to test in 30 min chart for the price of open

    With respect to real time data feeds into MS and the generation of multiple alets on the last bar when new ticks arrive, the simplest solution is to disable live-bars and only generate signals once the entire bar has been completed; another involves setting a trap so that all signals are computed on the second last bar, but the alert is displayed on the very last bar (so it will only ever display once)...

    These solutions often don't match the requirement of the RT traders, especially over longer time frames such as 30 minutes or longer.  There is a method using external functions which allows RT ticks to be received and alert conditions and indicators etc computed.  It counts the times the condition is true on each tick for the last bar, then returns the counter to MS with the number of times the condition has been met and you can set the alert function to trigger as you like.  This solution cannot be implemented in MSFL and requires the use of external functions.


    wabbit Big Smile [:D]


    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status : wabbit.com.au SkyPE online status
    My SkyPE account : wabbit.com.au

  •  06-24-2008, 12:40 27503 in reply to 27275

    Re: how to test in 30 min chart for the price of open

    Hi again!
    Now I need to program the same code to check for the 30 min close over the highest first bar with x ticks.

    For example: C > highest with 2 tick

    How can I program it?
View as RSS news feed in XML