Buy or Sell at set time and price change on any market.

Forums ProRealTime English forum General trading discussions Buy or Sell at set time and price change on any market.

Viewing 15 posts - 1 through 15 (of 18 total)
  • #236742

    Hello.

    I don’t know coding to write the code for this idea. I will appreciate help on this one please.

    The idea I have.
    As you know when the US market opens the volumes are high and moves fast in any direction.
    Have code that will open 2 x short OR 2 x long positions depending on the price direction.

    The positions opens on price change at a set time(market open time) Or opens positions at a candle count after market open.
    With the time set or candle count one can start trades on any market and on any time frame even on a 10sec time frame.

    Can apply this strategy on any market on any time frame. The market and time frame can then be any of your choice.
    If this can work this can work in Bull and Bear market.

    On market open and the price goes higher that what the price was at open. Open 2 x Long positions.
    LONG:
    1.) Buy 1 contract – set profit for $20 or 20 Points (20 = example/variable)
    Close this trade automatically when set profit is reached.
    Set Trailing stop at $10 or 10 points (10 = example/variable)
    2.) Buy 1 contract with $10/10 points trailing stop so this one can run (10 points = example)

    SHORT:
    The same applies as the above if the price moves lower on market open.
    1.) Short 1 contract – set profit for $20 or 20 Points (20 = example/variable)
    Close this trade when profit set is reached.
    Set Trailing stop at $10 or 10 points (10 = example/variable)
    2.) Short 1 contract with $10/10 points trailing stop so this one can run (10 points = example)

    Thank you.

     

    #236760

    This is what chatgtp made of it.

     

     

    #236761

    And now I would like to see the backtest.

    #236772

    Thank you for this.

    May be I’m missing something but the code does not open any positions. I changed the TimeMarketOpen, TP & TS values but still no results.
    Used the code like one would test any strategy. My PRT is working and have no issues there.

    #236779

    line 14

     MarketOpenPrice = Close

    line 19 and line 27

    MarketOpenPrice cannot be different from close

     

    #236780

    fifi743
    Thank you for the input.

    Your comment is the same as in the original code. What do you suggest?
    line 14 – MarketOpenPrice = Close

    What do you mean? I don’t understand (because I can’t code)
    line 19 and line 27
    MarketOpenPrice cannot be different from close

     

    Thank you

    #236781

    line 14

     MarketOpenPrice =open

    #236783

    Still no trades opened.

    #236784

    line 13

    IF (Time = StartTime ) THEN
    line 14
    MarketOpenPrice = Close
    #236785

    Ah.! Now it takes positions.
    Thank you.

    But it keeps on opening positions. I want it just to take positions and then stop.
    Example: When the market opens it should take positions buy/sell then exit the code/market.

    #236791

    by adding at the top of the code

    defparam cumulateorders =false

    #236946

    It still opens trades at any time.
    Does not start at set time and end when set target profit is reached.

    Thanks you.

    #236948

    Try this version:

    the last SET TARGET and SET STOP always override the previous ones. It’s not possible to set two different STOPs or TARGETs.

     

    #236957

    This one works. Thank you Robert.

    Profit not as much as I thought it might be but I’ll keep on playing with the TS and TP and see which combination gives best results.

    Question:
    See att image. What are the differences between the highlighted amounts?

    #236967
    JS

    The difference is simply because of the “Starting Capital” with which the “backtest” starts… (you can set up starting capital)

    Starting capital=100 (your equity curve start at 100)

    Profit=158,80

    Equity(curve): 258.80

Viewing 15 posts - 1 through 15 (of 18 total)

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