Wait for Price over/under code help!

Forums ProRealTime English forum ProOrder support Wait for Price over/under code help!

Viewing 11 posts - 1 through 11 (of 11 total)
  • #47990

    Hi Guys,

    I just wanted to ask for a little bit of help adding something to my SMA system.

    Here is my current system –

     

    I am hoping to add the following to this.

    When c1 occurs then wait x number of bars and if the price is above the price at the SMA crossover then buy, if price is under then no trade. And likewise for C2.

    Basically, waiting to see if a trend becomes established by waiting x number of bars and cutting down the number of losing trades.

    I hope that makes sense.

    #48003

    Automatic trading support go to ProOrder support… and please add code within the <> code button please! 😐

    Ok, so firstly we save the BARINDEX of the bar that saw the moving averages cross. Before buying or selling, we verify if the trend if still the right one (no contrarian cross over have occurred since) and if we have sufficient bar elapsed since the cross over/under. You can adapt this bar quantity with the ‘barquantity’ variable in the code.

    I did not test the code, please make your own tests and make feedback here.

    I did not test it, please make your own tests and give feedback.

    #48023

    Hi Nicolas,

     

    Thanks so much for coming back to me, oh no sorry was this in the wrong place? and I am sorry I will add the code using the button next time. I am still very much a newbie.

    I will do some testing on the code and let you know. Thanks.

    Matt

    #48025

    Hi Nicolas,

    Thanks again, I had a go with the above and it’s not quite right. It’s taking a trade on every single bar!?

    #48028

    Just add this line of code at the top of the program:

    It will prevent to add orders while we are already on market.

    #48039

    Thanks again Nicolas.

     

    Something still doesn’t seem right. It is taking more trades than without your additional code. I can’t figure why that would be

    #48070

    If you restrict the length of each trade it is not so strange that the number of trades increases. Sometimes the new version with restriction takes a new trade when the old version is still on market with the first trade. Think about it.

    #48081

    Because there are more than 1 order for a single MA cross: If the first order is stopped by its stoploss, the trading conditions are still true and another order will be launched at that time.

    #48089

    Ok thank again for the response.

    On my original code there would only be one trade taken for any MA cross over. Either C1 or C2. Why is it now launching more than one trade?

    Maybe i’ve not explained it correctly. I don’t want to restrict the length of the trade.

    I’ll explain again more clearly. When a cross over occurs I want to wait x number of candles sticks to see if the price is above the price it was when the cross over occurred. If it is then the system should take the trade at that moment, if it isn’t then don’t take a trade and wait for the next cross over to occur. Other than that I don’t want anything else to change to the system, if a trade is taken it should then continue until either my stop loss is hit or the exit condition is met.

    #48121

    On my original code there would only be one trade taken for any MA cross over. Either C1 or C2. Why is it now launching more than one trade?

    Because code has changed a bit to reflect your strategy..

    So, in this new version, I added only one trade per cross and if the Close is above / below the cross price when all other conditions are ok.

     

    Please note that in this version, orders are still exited by contrarian condition (a SELLSHORT is exited if new BUY conditions are met).

    #49033

    Thanks very much for your help with this.

     

Viewing 11 posts - 1 through 11 (of 11 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login