Announcement

Collapse
No announcement yet.

Comparing bars to another

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Comparing bars to another

    I copied this from my earlier posts. Tihs is very close to what I have modified in the last week.

    I run this script and works great (again many thanks!)
    I also would like to write another script that compares the first 2, 3 bars to the 9:30 bar. So if my chart is set for 9:30 to 1:00 then I want to compare to the 9:30 bar. Can I write that in (exactly that bar I want). So this script will only run for a few bars, and after the third bar is formed (after 9:30 then I really dont want the script to alert me, the conditions are alittle different for the first 3 bars that I track for the day, then the other ones for the rest of the day
    9:30 is start bar
    9:35 is next bar
    9:40 is third bar
    after that, I dont want the script to alert me. Confuse yet.


    so my statment would be meet this condition
    ((9:30BarHigh - 9:30BarLow) / 2) > (high(0) - low(0))




    Posted EARLIER in another post here
    //{{EFSWizard_Declarations
    var vLastAlert = -1;
    //}}EFSWizard_Declarations
    function preMain() {
    setComputeOnClose(true);

    //{{EFSWizard_PreMain
    setPriceStudy(true);
    setStudyTitle("");
    //}}EFSWizard_PreMain
    }

    function main() {

    setComputeOnClose(true);
    var BarTime = rawtime(0);
    var BarIndex = (getFirstBarIndexOfDay(BarTime)-getCurrentBarIndex());
    var FirstOpen = open(BarIndex);
    var FirstHigh = high(BarIndex);
    var FirstClose = close(BarIndex);
    var FirstLow = low(BarIndex);

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if (
    high(0) <= high(-1) &&
    close(0) >= open(0) &&
    ((high(-1) - low(-1)) / 2) > (high(0) - low(0))
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2 AGR1 Type Setup Bar has to be less than 50% of First Bar of day
    else if (
    high(0) <= high(-1) &&
    close(0) >= open(0) &&
    ((FirstHigh - FirstLow) / 2) > (high(0) - low(0))
    ) onAction2()
    //}}EFSWizard_Expression_2

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return null;
    //}}EFSWizard_Return

    }

    function postMain() {

    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1 Writes AGR to alert trader script has setup
    function onAction1() {
    drawTextRelative(0, low()-.005, "AGR", Color.RGB(255,255,0), Color.RGB(0,0,0), Text.FRAME, "Arial", 8);
    Alert.playSound("C:\Program Files\eSignal\Sounds\l10setup.wav");
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2 Writes AGR1 to alert trader script has setup
    function onAction2() {
    drawTextRelative(0, low()-.005, "AGR1", Color.RGB(255,255,0), Color.RGB(0,0,0), Text.FRAME, "Arial", 8);
    Alert.playSound("C:\Program Files\eSignal\Sounds\l10setup.wav");
    vLastAlert = 2;

  • #2
    PATRADER
    It is not clear if you want the conditions in your script evaluated only between 9:30 and 9:45 or only after 9:45.
    In the first case then you could enclose all your conditions inside the following statement
    PHP Code:
    if((getHour(0)*100)+getMinute(0)>930 && (getHour(0)*100)+getMinute(0)<945){
        
    //your conditions...

    If instead they are to be evaluated only after 9:45 then you would enclose your conditions in the following
    PHP Code:
    if((getHour(0)*100)+getMinute(0)>945){
        
    //your conditions...

    Hope this helps
    Alex

    Comment


    • #3
      Times are 9:30

      What I want to do is compare the first 3 bars
      09:30
      09:35
      09:40

      only these times will be looked at

      I will compare 09:35 to 09:30 and compare 09:40 to 09:35 for very simple conditions like this

      high(09:35 bar) <= high(09:30 bar) &&
      close(09:35 bar) > open(09:35) &&
      close(09:40 bar) >close(09:35 bar) &&
      ((09:30 High - 09:30 Low) / 2) > (high(09:35 bar) - low(09:35 bar))

      then alert me

      Comment

      Working...
      X