Announcement

Collapse
No announcement yet.

cant get it to not send signals

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

  • cant get it to not send signals

    i threw together a study so i could test sending signals to my broker, but when i load the EFS, it sends every signal that happened on historical bars, ive tried getting ti to not send signals that have already expired by using getBarState() == BARSTATE_NEWBAR, ive also tried getBarState() != BARSTATE_ALLBARS, but it still sends every single order that has already passed, does anyone know how to fix this?

    PHP Code:
    var State 0;
    var 
    10;
    var 
    50;

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setColorPriceBars(true);
        
    setStudyTitle("test");
        
    setCursorLabelName("Fast"0);
        
    setCursorLabelName("Slow"1);
        
    setCursorLabelName("State"2);
        
    setDefaultBarStyle(PS_SOLID0);
        
    setDefaultBarStyle(PS_SOLID1);
        
    setDefaultBarStyle(PS_SOLID2);
        
    setDefaultBarFgColor(Color.grey0);
        
    setDefaultBarFgColor(Color.darkgrey1);
        
    setDefaultBarFgColor(Color.grey2);
        
    setDefaultBarThickness(40);
        
    setDefaultBarThickness(41);
        
    setDefaultBarThickness(42);
        
    setPlotType(PLOTTYPE_LINE0);
        
    setPlotType(PLOTTYPE_LINE1);
        
    setPlotType(PLOTTYPE_LINE2);
    }

    function 
    main() {
    if (
    getBarState() == BARSTATE_NEWBAR && getBarState() != BARSTATE_ALLBARS) {
        if (
    sma(F) > ema(S) && State != 1) {
            
    Strategy.doLong(""Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT, 0);
            
    buyMarket(getSymbol(), 10)
            
    State 1;
        }

        else if (
    sma(F) < ema(S) && State != -1) {
            
    Strategy.doShort(""Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT, 0);
            
    sellShortMarket(getSymbol(), 10)
            
    State = -1;
        }
    }

    setPriceBarColor(Color.RGB(128,128,128))
    if (
    State == 1setPriceBarColor(Color.RGB(0,255,0));
    if (
    State == -1setPriceBarColor(Color.RGB(255,0,0));


    return new Array(
        
    sma(F),
        
    ema(S),
        
    String(State)
        );




  • #2
    i found my answer here http://forum.esignalcentral.com/show...threadid=31715

    Comment

    Working...
    X