I have a thought. How might I execute it?

Discussion in 'Strategy Building' started by MrAgi1, May 15, 2021.

  1. MrAgi1

    MrAgi1

    I have a trading idea, but I don't know how to execute it in python. I am not really good at programming LOL. I am trying to backtest my trading idea in python or any other programming language.

    How can I write the codes to find fx pairs that meet certain conditions written below?

    First, I have to input certain parameters; the currency pair and a particular time. As an example: EURUSD and 9 AM EST.

    Next, I have to define variables; PipBlock=10 pips, DAYCounter=30 trading days, PassCounter=0, FailCounter=0.

    30 minutes candlestick chart is used here. In our example above we always start at the 9 AM EST candle every trading day for the last 30 trading days.
    H=high, O=open, L= low

    ***NOTE: When I move to the next 30 minutes candle I always retain the Open value of the initial candle(i.e the 9 AM Open candle value). The High and Low values would change to the current candle values.

    Now the logic for the trade is the four blocks below:



    if (H-O>10 and O-L<10)
    {PassCounter++
    Move to the next trading day}
    #The above is block 1, and it starts with the 9 AM candle. Then moves to the next 9 AM candle on the next day.



    if (H-O<10 and O-L<10)
    {Move to next candle, on same trading day}
    #The Above is block 2, start with the 9 AM candle the next candle we move to is the 9:30 AM candle.




    if (H-O<10 and O-L>10)
    {Move to the next candle, on the same trading day}
    #The Above is block 3, start with the 9 AM candle the next candle we move to is the 9:30 AM candle.





    if (H-O>10 and O-L>10)
    {Move to the next candle, on the same trading day}
    #The Above is block 4, start with the 9 AM candle the next candle we move to is the 9:30 AM candle.




    ***NOTE: If any of block 2, block 3, or block 4 occurs first and subsequently block 2 keeps occurring the program would keep moving from candle to candle(i.e 9 AM, 9:30 AM, 10 AM, 10:30 AM e.t.c) until the end of the trading day 9 PM EST then FailCounter++, and the analysis ends for that trading day and move to another trading day. However, if block 3 or block 4 occurs twice at any time past 9 AM, End the analysis immediately for that trading day and Failcounter++, and move to another trading day.

    ***Since DAYCounter is 30 days, once we end the analysis for the trading day we would check the same condition for another trading day. The program would keep doing this until the last 30 trading days.
    Finally after the 30 days analysis, Print the FailCounter and PassCounter values for that particular currency over the last 30 days.