Announcement

Collapse
No announcement yet.

Choosing Signal Bars

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

  • Choosing Signal Bars

    I have an EFS script where i print a symbol on the top/bottom of the bar the first time a bar closes above/below the bollinger bands, ie, if it closes above the top bollinger, then give me the opposite signal the next time a bar closes below the bottom bollinger. The problem i have is i want to be able to mark the signals i like, so i want to be able to click on the bar giving me a signal and have an image/shape placed ontop/below, depending on the signal given. This also means that if i click on a bar that has no signal, nothing should be printed on the chart. I've used a variable in my code to try to accomplish this but it doesn't seem to want to print at all.
    Does anyone know wat i'm doing wrong and be able to point me in the right direction??
    Thanks in advance,
    Attached Files

  • #2
    I don't have time to help you fix this code (yet). I'm busy the next 4+ days but will check in here on Friday. But....

    Here's your solution...

    The mouse click functions return the BAR and PRICE you click on. The bar returns a bar number. You use this to match the signal bars..

    First, you need to count the bars as they form on the chart - keep a running total.

    Next, you need to create a array to store the signal bars. If you want to keep track of different types of signals (bull/bear), then you need to use this array to store OBJECTS of each signal (holding more data).

    Kinda like this

    PHP Code:

    //  Create the array outside of main() - as a global variable
    var SignalBarArray = new Array();

    //  Use this type of code to populate the array/signals for comparison.
    if (current bar is bullish signal bar Condition) {
      if (
    getBarState() == BARSTATE_NEWBAR) {
         var 
    vObj = new Object;
           
    vObj.BarNumber nBarCounter;
           
    vObj.SigType 1;  // 0 = flat, 1 = bullish, -1 = bearish
         
    SignalBarArray.push(vObj);
      } else {
         
    SignalBarArray[(SignalBarArray.length-1)].SigType Sig_Return;
      }
    }
    if (
    current bar is bearish signal bar Condition) {
      if (
    getBarState() == BARSTATE_NEWBAR) {
         var 
    vObj = new Object;
           
    vObj.BarNumber nBarCounter;
           
    vObj.SigType = -1;  // 0 = flat, 1 = bullish, -1 = bearish
         
    SignalBarArray.push(vObj);
      } else {
         
    SignalBarArray[(SignalBarArray.length-1)].SigType Sig_Return;
      }
    }


    //----------------------------------------------------------------------------------//  Mouse Functions
    function onLButtonDownbarIndex,  yValue) {

    //debugPrintln("LeftDown: " + barIndex + ", " + yValue);
    updateClickInfo(barIndexyValue);

    }


    function 
    updateClickInfo(barIndexyValue) {
          var 
    vHLOffset = (high(barIndex)-low(barIndex))/2;
          var 
    SignalBarIndex isSignalBar(barIndexyValue);
          
      
    //  Draw Pointer on chart
          
    drawLineRelative(barIndexyValue+vHLOffsetbarIndexyValue-vHLOffsetPS_SOLID1Color.blue"Vline"); 
          
    drawLineRelative(barIndex-1yValuebarIndex+1yValuePS_SOLID1Color.blue"Hline"); 
          
    drawShapeRelative(barIndexyValueShape.DIAMONDnullColor.blueShape.ONTOP Shape.RIGHT Shape.TOP"Ptr"); 

    //debugPrintln("LeftDown: " + barIndex + ", " + yValue+" 

        
    if (SignalBarIndex >= 0) {
          
    //  If this is true, then it found a signal on the bar you click on.  
        
    }


    }


    function 
    isSignalBar(vBarvPrice) {
    var 
    v_x 0;
    var 
    vFoundOrder = -1;

     if ((
    SignalBarArray.length) > 0) {
       
    v_x SignalBarArray.length-1;
       
        while ((
    vFoundOrder 0) && (v_x >= 0)) {
           if (
    SignalBarArray[v_x].Bar == (vBar+nBarCounter))  ) {
             
    vFoundOrder =  (vBar+nBarCounter);
           }
           
    v_x--;
        }
     }
     return 
    vFoundOrder;

    Last edited by Doji3333; 03-11-2009, 08:24 PM.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment

    Working...
    X